<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; BayesPeak</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/bayespeak/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>用R包BayesPeak来对CHIP-seq数据call peaks</title>
		<link>http://www.bio-info-trainee.com/1749.html</link>
		<comments>http://www.bio-info-trainee.com/1749.html#comments</comments>
		<pubDate>Tue, 05 Jul 2016 15:25:46 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[基础软件]]></category>
		<category><![CDATA[BayesPeak]]></category>
		<category><![CDATA[CHIP-seq]]></category>
		<category><![CDATA[Peak]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1749</guid>
		<description><![CDATA[BayesPeak也是peaks caller家族一员，用的人也不少，我这次也试 &#8230; <a href="http://www.bio-info-trainee.com/1749.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>BayesPeak也是peaks caller家族一员，用的人也不少，我这次也试了一下，因为是R的bioconductor系列包，所以直接在R里面安装就好，但是有几个点需要注意，我比对的基因组不只是Chr1~22,X,Y,M，还有一些contig和scaffold，需要在bam文件里面去除的，而且BayesPeak比较支持读取BED文件，可以直接转为GRanges对象，虽然它号称可以使用多核，但是计算速度还是非常慢。<span id="more-1749"></span></p>
<p>### step6.7 peak calling by BayesPeak(R bioconductor package)<br />
# Bayesian Analysis of ChIP-seq data<br />
## BayesPeak fits a Markov model to the data (the aligned reads) via Markov Chain Monte Carlo (MCMC) techniques.</p>
<p># 有博客里面提到I've used BayesPeak running in R. It is much easier to install than MACS (failed for me), which require some (strange to me) files.<br />
# 首先要把bowtie2比对好的alignment文件bam格式转换为bed格式： http://bedtools.readthedocs.io/en/latest/content/tools/bamtobed.html<br />
## In particular, the chromosome, start position, end position and DNA strand appear in the 1st, 2nd, 3rd and 6th columns respectively.<br />
#### software : http://bioconductor.org/packages/release/bioc/html/BayesPeak.html<br />
#### readme: http://bioconductor.org/packages/release/bioc/vignettes/BayesPeak/inst/doc/BayesPeak.pdf<br />
学习R的bioconductor系列包很容易，先看看例子即可examples:</p>
<p>library(BayesPeak) ## 一般例子都会读取包自带的测试文件<br />
tFile=file.path(system.file(package='BayesPeak'),'extdata','H3K4me3reduced.bed')<br />
cFile=file.path(system.file(package='BayesPeak'),'extdata','Inputreduced.bed')</p>
<p>raw.output &lt;- bayespeak(tFile, cFile, chr = "chr16", start = 9.2E7, end = 9.5E7, job.size = 6E6)<br />
output &lt;- summarize.peaks(raw.output, method = "lowerbound")<br />
## the function summarize.peaks will do : Filtering of unenriched jobs/Filtering of unenriched bins/Assembly of enriched bins/Conversion of bins to peaks</p>
<p>write.table(as.data.frame(output), file = "H3K4me3output.txt", quote = FALSE)<br />
## write.csv(as.data.frame(output), file = "H3K4me3output.csv", quote = FALSE)<br />
## 可以借助多线程来加快运行速度：<br />
library(parallel)<br />
## <span style="color: #ff0000;">还需要 检查pp这个阈值的选取</span> # A “potentially enriched” bin is defined as any bin with PP &gt; 0.01.<br />
The output of the algorithm is the Posterior Probability (often abbreviated to PP) of each bin being enriched.<br />
The PP value is useful not only for calling the peaks, but could also be used in downstream analyses - for<br />
example, to weight observations when searching for a novel transcription factor motif. The PP value is not<br />
to be confused with the p value from hypothesis testing</p>
<p>&gt; min.job &lt;- min(raw.output$peaks$job)<br />
&gt; max.job &lt;- max(raw.output$peaks$job)<br />
&gt; par(mfrow = c(2,2), ask = TRUE)<br />
&gt; for(i in min.job:max.job) {plot.PP(raw.output, job = i, ylim = c(0,50))}<br />
When the coverage is sparse and therefore less information is available, the PP values tend to be more<br />
uniformly spread over the interval [0,1], as above. This means that the distinction between peaks and<br />
background is harder to make, which is usually a result of poor enrichment,</p>
<p>raw.output &lt;- bayespeak(tFile, cFile,use.multicore = TRUE, mc.cores = 4)<br />
i &lt;- 324<br />
plot.PP(raw.output, job = i, ylim = c(0,50))</p>
<p>看完了例子，就可以开始处理自己的数据啦：</p>
<blockquote><p>############ first change bam files to bed files :<br />
ls *sorted.bam |while read id ;do ~/biosoft/bedtools/bedtools2/bin/bedtools bamtobed -i $id &gt; ${id%%.*}.bed ;done<br />
<span style="color: #ff0000;">但是要过滤掉特殊染色体(chr6_cox_hap2,chrUn_gl000214)，仅仅保留CHR1-22,X,Y,M</span><br />
ls *bed |while read id ;do grep -v "_" $id &gt;${id%%.*}.clean_bed;done</p></blockquote>
<p>下面是我处理自己的数据的完整代码，很简单：</p>
<blockquote><p>############ Then do peak calling in R by BayesPeak<br />
library(BayesPeak)<br />
library(parallel)<br />
workdir=getwd()<br />
tFile=file.path(workdir,'SRR1042593.clean_bed')<br />
cFile=file.path(workdir,'SRR1042594.clean_bed')<br />
raw.output &lt;- bayespeak(tFile, cFile,use.multicore = TRUE, mc.cores = 8)<br />
output &lt;- summarize.peaks(raw.output, method = "lowerbound")<br />
write.table(as.data.frame(output), file = "Xu_MUT_rep1.txt", quote = FALSE)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1749.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自学CHIP-seq分析第六讲~寻找peaks</title>
		<link>http://www.bio-info-trainee.com/1745.html</link>
		<comments>http://www.bio-info-trainee.com/1745.html#comments</comments>
		<pubDate>Tue, 05 Jul 2016 12:17:31 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[tutorial]]></category>
		<category><![CDATA[BayesPeak]]></category>
		<category><![CDATA[CHIP-seq]]></category>
		<category><![CDATA[macs2]]></category>
		<category><![CDATA[PeakRanger]]></category>
		<category><![CDATA[peaks]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1745</guid>
		<description><![CDATA[CHIP-seq测序的本质还是目标片段捕获测序，跟WES不同的是，它不是通过固定 &#8230; <a href="http://www.bio-info-trainee.com/1745.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>
<p>CHIP-seq测序的本质还是目标片段捕获测序，跟WES不同的是，它不是通过固定的芯片探针来固定的捕获基因组上面特定序列，而是根据你选择的IP不同，你细胞或者机体状态不同，捕获到的序列差异很大！而我们研究的重点，就是捕获到的差异。而我们对CHIP-seq测序数据寻找peaks的本质就是得到所有测序数据比对在全基因组之后在正个基因组上面的测序深度里面寻找比较突出的。比如对WES数据来说，各个外显子，或者外显子的5端到3端，理论上测序深度应该是一致的，都是50X~200X，画一个测序深度曲线，应该是近似于一条直线。对我们的CHIP-seq测序数据来说，在所捕获的区域上面，理论上测序深度是绝对不一样的，应该是近似于一个山峰。而那些覆盖度高的地方，山顶，就是我们的IP所结合的热点，也就是我们想要找的peaks，在IGV里面看到大致是下面这样：</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/07/chipseq-0-peakdetection-large-IGV.png"><img class="alignnone size-full wp-image-1756" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/07/chipseq-0-peakdetection-large-IGV.png" alt="chipseq-0-peakdetection-large-IGV" width="786" height="478" /></a></p>
<p>可以看到测序的reads分布是绝对的不均匀的！我们通常说的CHIP-seq测序的IP，可以是各个组蛋白的各个修饰位点对应的抗体，或者是各种转录因子的抗体，等等</p>
<p>如何定义热点呢？通俗地讲，热点是这样一些位置，这些位置多次被测得的read所覆盖（我们测的是一个细胞群体，read出现次数多，说明该位置被TF结合的几率大）。那么，read数达到多少才叫多？这就要用到统计检验喽。假设TF在基因组上的分布是没有任何规律的，那么，测序得到的read在基因组上的分布也必然是随机的，某个碱基上覆盖的read的数目应该服从二项分布。</p>
<p>具体统计学原理直接看原创吧：<a href="http://www.plob.org/2014/05/08/7227.html">http://www.plob.org/2014/05/08/7227.html</a></p>
</div>
<p><span id="more-1745"></span>为了达到作者文献里面的结果，我换了8个软件：<b><span style="color: #ff0000;">MACS2</span></b>/HOMER/SICERpy/PePr/SWEMBL/SISSRs/<b>BayesPeak/PeakRanger，我这里就不一一介绍peaks caller软件的安装以及使用了，因为MACS2是最常用的，我就简单贴一下我关于MACS2的学习代码：</b></p>
<blockquote>
<div><b>## step6 : peak calling<br />
### step6.1: with MACS2<br />
## 我先看了看说明书：<br />
macs2 callpeak -t TF_1.bam -c Input.bam -n mypeaks<br />
We used the following options:<br />
-t: This is the only required parameter for MACS, refers to the name of the file with the ChIP-seq data<br />
-c: The control or mock data file<br />
-n: The name string of the experiment<br />
MAC2 creates 4 files (mypeaks peaks.narrowPeak, mypeaks summits.bed, mypeaks peaks.xls and mypeaks model.r)<br />
# MACS首先的工作是要确定一个模型，这个模型最关键的参数就是峰宽d。这个d就是bw(band width)，而它的一半就是shiftsize。</b></div>
<div><b><b>### 然后根据文章确定了下载的测序数据的分类<br />
GSM1278641 Xu_MUT_rep1_BAF155_MUT        SRR1042593<br />
GSM1278642 Xu_MUT_rep1_Input        SRR1042594<br />
GSM1278643 Xu_MUT_rep2_BAF155_MUT        SRR1042595<br />
GSM1278644 Xu_MUT_rep2_Input        SRR1042596<br />
GSM1278645 Xu_WT_rep1_BAF155        SRR1042597<br />
GSM1278646 Xu_WT_rep1_Input        SRR1042598<br />
GSM1278647 Xu_WT_rep2_BAF155        SRR1042599<br />
GSM1278648 Xu_WT_rep2_Input         SRR1042600<br />
## 这里有个很奇怪的问题，input的测序数据居然比IP的测序数据多？？？<br />
848M Jun 28 14:31 SRR1042593.bam<br />
2.7G Jun 28 14:52 SRR1042594.bam<br />
716M Jun 28 14:58 SRR1042595.bam<br />
2.9G Jun 28 15:20 SRR1042596.bam<br />
1.1G Jun 28 15:28 SRR1042597.bam<br />
2.6G Jun 28 15:48 SRR1042598.bam<br />
1.2G Jun 28 15:58 SRR1042599.bam<br />
3.5G Jun 28 16:26 SRR1042600.bam<br />
## 我没有想明白为什么<br />
## http://www2.uef.fi/documents/1698400/2466431/Macs2/f4d12870-34f9-43ef-bf0d-f5d087267602<br />
## http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3120977/</b></b>我首先用的是下面这些代码<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042594.bam -t SRR1042593.bam -f BAM -B -g hs -n Xu_MUT_rep1 2&gt;Xu_MUT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042596.bam -t SRR1042595.bam -f BAM -B -g hs -n Xu_MUT_rep2 2&gt;Xu_MUT_rep2.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042598.bam -t SRR1042597.bam -f BAM -B -g hs -n Xu_WT_rep1 2&gt;Xu_WT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042600.bam -t SRR1042599.bam -f BAM -B -g hs -n Xu_WT_rep2 2&gt;Xu_WT_rep2.masc2.log &amp;<br />
得到的peaks少的可怜，我第一次检查，以为是因为自己没有sort 比对的bam文件导致<br />
## forget to sort the bam files:<br />
## 首先把bam文件sort好，构建了inde，然后继续运行！<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042594.sorted.bam -t SRR1042593.sorted.bam -f BAM -B -g hs -n Xu_MUT_rep1 2&gt;Xu_MUT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042596.sorted.bam -t SRR1042595.sorted.bam -f BAM -B -g hs -n Xu_MUT_rep2 2&gt;Xu_MUT_rep2.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042598.sorted.bam -t SRR1042597.sorted.bam -f BAM -B -g hs -n Xu_WT_rep1 2&gt;Xu_WT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042600.sorted.bam -t SRR1042599.sorted.bam -f BAM -B -g hs -n Xu_WT_rep2 2&gt;Xu_WT_rep2.masc2.log &amp;<br />
##此时得到peaks跟上面为sort的bam文件得到的peaks一模一样，看来不是这个原因</p>
</div>
<div>##然后我怀疑是不是作者上传数据的时候把input和IP标记反了，所以我认为的调整过来</div>
<div><b><b>## Then change the control and treatment<br />
nohup time ~/.local/bin/macs2 callpeak -t SRR1042594.sorted.bam -c SRR1042593.sorted.bam -f BAM -B -g hs -n Xu_MUT_rep1 2&gt;Xu_MUT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -t SRR1042596.sorted.bam -c SRR1042595.sorted.bam -f BAM -B -g hs -n Xu_MUT_rep2 2&gt;Xu_MUT_rep2.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -t SRR1042598.sorted.bam -c SRR1042597.sorted.bam -f BAM -B -g hs -n Xu_WT_rep1 2&gt;Xu_WT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -t SRR1042600.sorted.bam -c SRR1042599.sorted.bam -f BAM -B -g hs -n Xu_WT_rep2 2&gt;Xu_WT_rep2.masc2.log &amp;</b></b></div>
<div><b><b>##结果，压根就没有peaks了！！！！看了作者并没有搞错<br />
</b></b></p>
<div><b>##接下来我怀疑是自己用samtools view -bhS -q 30   处理了sam文件，这个标准太严格了！！</b></div>
<div><b>## </b></div>
<p><b>## then just use the sam files.<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042594.sam -t SRR1042593.sam -f SAM -B -g hs -n Xu_MUT_rep1 2&gt;Xu_MUT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042596.sam -t SRR1042595.sam -f SAM -B -g hs -n Xu_MUT_rep2 2&gt;Xu_MUT_rep2.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042598.sam -t SRR1042597.sam -f SAM -B -g hs -n Xu_WT_rep1 2&gt;Xu_WT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042600.sam -t SRR1042599.sam -f SAM -B -g hs -n Xu_WT_rep2 2&gt;Xu_WT_rep2.masc2.log &amp;<br />
## 也没有多几个peaks，最后我只能想到是我的p值太严格了<br />
## then chang the criteria for p values :</p>
<p>https://github.com/taoliu/MACS/</p>
<p>nohup time ~/.local/bin/macs2 callpeak -c SRR1042594.sam -t SRR1042593.sam -f SAM -p 0.01 -g hs -n Xu_MUT_rep1 2&gt;Xu_MUT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042596.sam -t SRR1042595.sam -f SAM -p 0.01 -g hs -n Xu_MUT_rep2 2&gt;Xu_MUT_rep2.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042598.sam -t SRR1042597.sam -f SAM -p 0.01 -g hs -n Xu_WT_rep1 2&gt;Xu_WT_rep1.masc2.log &amp;<br />
nohup time ~/.local/bin/macs2 callpeak -c SRR1042600.sam -t SRR1042599.sam -f SAM -p 0.01 -g hs -n Xu_WT_rep2 2&gt;Xu_WT_rep2.masc2.log &amp;<br />
##我大大减小了P值的标准，结果是输出一大堆的peaks<br />
18919 Xu_MUT_rep1_peaks.xls<br />
36277 Xu_MUT_rep2_peaks.xls<br />
32494 Xu_WT_rep1_peaks.xls<br />
56080 Xu_WT_rep2_peaks.xls<br />
问题是这些peaks根本就都是假阳性！！！<br />
我手动的check了几个之前严格过滤条件下的peaks，的确可以看到测序深度是两个山峰形状的曲线<br />
## check some peaks 手动的 ## chr1 121484235 121485608<br />
## masc results :<br />
samtools depth -r chr10:42385331-42385599 SRR1042593.sorted.bam<br />
samtools depth -r chr10:42385331-42385599 SRR1042594.sorted.bam<br />
samtools depth -r chr20:45810382-45810662 SRR1042593.sorted.bam<br />
samtools depth -r chr20:45810382-45810662 SRR1042594.sorted.bam<br />
##我也check了paper里面得到的peak，但是在我的比对文件里面，肉眼看起来根本不像，所以我很纠结~~~~<br />
paper results:<br />
chr20 45796362 46384917<br />
chr1 121482722 121485861<br />
samtools depth -r chr1:121482722-121485861 SRR1042593.sorted.bam<br />
samtools depth -r chr1:121482722-121485861 SRR1042594.sorted.bam<br />
samtools depth -r chr20:45796362-46384917 SRR1042593.sorted.bam<br />
samtools depth -r chr20:45796362-46384917 SRR1042594.sorted.bam </b></p>
</div>
</blockquote>
<div>很不幸，最后还是没能达到作者的结果，我没搞清楚是为什么，我还用了<b>BayesPeak/PeakRanger这两个软件，结果也不咋地。</b></div>
<div></div>
<div>peak finder软件大全： <a href="http://wodaklab.org/nextgen/data/peakfinders.html">http://wodaklab.org/nextgen/data/peakfinders.html</a></div>
<div>
<div>Peak Calling for ChIP-Seq :　<a href="http://epigenie.com/guide-peak-calling-for-chip-seq/">http://epigenie.com/guide-peak-calling-for-chip-seq/</a></div>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1745.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
