<?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; bigWig</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/bigwig/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>wig、bigWig和bedgraph文件详解</title>
		<link>http://www.bio-info-trainee.com/1815.html</link>
		<comments>http://www.bio-info-trainee.com/1815.html#comments</comments>
		<pubDate>Tue, 26 Jul 2016 14:53:16 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[CHIP-seq]]></category>
		<category><![CDATA[bedgraph]]></category>
		<category><![CDATA[bigWig]]></category>
		<category><![CDATA[UCSC]]></category>
		<category><![CDATA[wig]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1815</guid>
		<description><![CDATA[我们一般会熟悉sam/bam格式文件，就是把测序reads比对到参考基因组后的文 &#8230; <a href="http://www.bio-info-trainee.com/1815.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>我们一般会熟悉sam/bam格式文件，就是把测序reads比对到参考基因组后的文件！bam或者bed格式的文件主要是为了追踪我们的reads到底比对到了参加基因组的什么区域，而UCSC规定的这几个文件格式(wig、bigWig和bedgraph)用处不一样，仅仅是为了追踪参考基因组的各个区域的覆盖度，测序深度！而且这些定义好的文件，可以无缝连接到UCSC的Genome Browser工具里面进行可视化！</div>
<div>这个网站提供了这几种数据格式的构造及转换脚本：<a href="http://barcwiki.wi.mit.edu/wiki/SOPs/coordinates">http://barcwiki.wi.mit.edu/wiki/SOPs/coordinates</a></div>
<div>对SE数据，可以用macs2 pileup --extsize 200 -i $sample.bam -o $sample.bdg 把bam文件转换为bedgraph文件，不需要call peaks这一步骤。</div>
<div>而UCSC的ftp里面可以下载bedGraphToBigWig $sample.bdg ~/reference/genome/mm10/mm10.chrom.sizes $sample.bw 把bedgraph文件转换为bw文件，其余的转换工具都可以下载。</div>
<p><span id="more-1815"></span></p>
<div>具体文件格式定义请直接看UCSC的官网，下面是我基于自己的理解来翻译的，没什么特殊的，建议大家看原文，然后自己翻译一个，跟我比较！</div>
<div><b>Wiggle Track Format (WIG)：</b><a href="http://genome.ucsc.edu/goldenPath/help/wiggle.html">http://genome.ucsc.edu/goldenPath/help/wiggle.html</a></div>
<div><b>bigWig Track Format ：</b><a href="http://genome.ucsc.edu/goldenPath/help/bigWig.html">http://genome.ucsc.edu/goldenPath/help/bigWig.html</a></div>
<div><b>BedGraph Track Format ：</b><a href="http://genome.ucsc.edu/goldenPath/help/bedgraph.html">http://genome.ucsc.edu/goldenPath/help/bedgraph.html</a></div>
<div>这3种文件格式都是UCSC规定的，所以它提供了系列工具进行互相转换，可以直接下载可执行版本程序：<a href="http://hgdownload.cse.ucsc.edu/admin/exe/">http://hgdownload.cse.ucsc.edu/admin/exe/</a></div>
<div>常见的工具如下：</div>
<div>
<ul>
<li><code>bigWigToBedGraph</code> — this program converts a bigWig file to ASCII <a href="http://genome.ucsc.edu/FAQ/FAQformat.html#format1.8">bedGraph</a> format.</li>
<li><code>bigWigToWig</code> — this program converts a bigWig file to <a href="http://genome.ucsc.edu/FAQ/FAQformat.html#format6">wig</a> format.</li>
<li><code>bigWigSummary</code> — this program extracts summary information from a bigWig file.</li>
<li><code>bigWigAverageOverBed</code> — this program computes the average score of a bigWig over each bed, which may have introns.</li>
<li><code>bigWigInfo</code> — this program prints out information about a bigWig file.</li>
</ul>
</div>
<div>其实对我们的bam文件，用samtools软件也可以很容易得到基因组区域的覆盖度和测序深度，比如：</div>
<div>
<div>samtools depth -r <span style="color: #ff0000;"><b>chr12:126073855-126073965</b></span>  Ip.sorted.bam</div>
<blockquote>
<div>chr12    126073855    5</div>
<div>chr12    126073856    15</div>
<div>chr12    126073857    31</div>
<div>chr12    126073858    40</div>
<div>chr12    126073859    44</div>
<div>chr12    126073860    52</div>
<div>~~~~~~~~~其余省略输出~~~~~~~~~</div>
</blockquote>
</div>
<div>这其实就是wig文件的雏形，但是wig文件会更复杂一点！</div>
<div>首先它不需要第一列了，因为全部是重复字段，只需要在每个染色体的第一行定义好染色体即可。</div>
<div>首先需要设置这个wig文件在UCSC的Genome Browser工具里面显示的属性：</div>
<div>
<pre><b>track type</b>=wiggle_0 <b>name</b>=<i>track_label</i><b>description=</b><i>center_label</i><b>visibility=</b><i>display_mode</i><b>color=</b><i>r,g,b</i><b>altColor=</b><i>r,g,b</i><b>priority=</b><i>priority</i><b>autoScale=</b><i>on|off</i><b>alwaysZero=</b><i>on|off</i><b>gridDefault=</b><i>on|off</i><b>maxHeightPixels=</b><i>max:default:min</i><b>graphType=</b><i>bar|points</i><b>viewLimits=</b><i>lower:upper</i><b>yLineMark=</b><i>real-value</i><b>yLineOnOff=</b><i>on|off</i><b>windowingFunction=</b><i>mean+whiskers|maximum|mean|minimum</i><b>smoothingWindow=</b>off|2-16</pre>
<pre><b>type</b>=wiggle_0 这个是默认的， 而且到目前为止，必须是这样的！其余的都是可选参数，自己读官网说明</pre>
<p>这些参数一般不用管，除非你很熟悉了UCSC的Genome Browser工具</p>
</div>
<div>然后需要设置每条染色体的属性，几个比较重要的参数是：</p>
<pre><b>fixedStep</b><b>chrom=</b><i>chrN</i><b>start=</b><i>position</i><b>step=</b><i>stepInterval</i><b>[span=</b><i>windowSize</i><b>]</b></pre>
</div>
<div>
<div><b>下面是wig的一个具体例子：</b></div>
<blockquote>
<div><b>track type=print wiggle_0 name=hek  description=hek</b></div>
<div><b>variableStep chrom=chr1 span=10</b></div>
<div>10008    7</div>
<div>10018    14</div>
<div>10028    27</div>
<div>10038    37</div>
<div>10048    45</div>
<div>10058    43</div>
<div>10068    37</div>
<div>10078    26</div>
<div>~~~~~~~~~其余省略输出~~~~~~~~~</div>
</blockquote>
</div>
<div>UCSC也提供了一个wig文件：<a href="http://genome.ucsc.edu/goldenPath/help/examples/wiggleExample.txt">http://genome.ucsc.edu/goldenPath/help/examples/wiggleExample.txt</a></div>
<div>可以看到我设置的参数很少很少，而且我是直接对sort后的bam文件用脚本变成wig文件的。</div>
<div>那么bigwig格式文件就没什么好讲的了，它就是wig格式文件的二进制压缩版本，这样更加节省空间。</div>
<div>我们只需要用UCSC提供的工具把自己的wig文件转换一下即可，步骤如下：</div>
<blockquote>
<div>
<ul>
<li>Save this <a href="http://genome.ucsc.edu/goldenPath/help/examples/wigVarStepExample.gz">wiggle file</a> to your machine (this satisfies <em>steps 1</em> and <em>2</em> above).</li>
<li>Save this <a href="http://genome.ucsc.edu/goldenPath/help/hg19.chrom.sizes">text file</a> to your machine. It contains the chrom.sizes for the human (hg19) assembly (this satisfies <em>step 4</em> above).</li>
<li>Download the <code>wigToBigWig</code> utility (see <em>step 3</em>).</li>
<li>Run the utility to create the bigWig output file (see <em>step 5</em>):<br />
<code><b>wigToBigWig</b> wigVarStepExample.gz hg19.chrom.sizes myBigWig.bw</code></li>
</ul>
</div>
</blockquote>
<div></div>
<div>最后我们讲一下BedGraph格式文件，它是BED文件的扩展，是4列的BED格式，但是需要添加UCSC的Genome Browser工具里面显示的属性，但是一般就定义有限的几个属性即可。</div>
<div>
<blockquote>
<pre><b>track type=bedGraph name=</b><i>track_label</i><b>description=</b><i>center_label</i><b>        visibility=</b><i>display_mode</i><b>color=</b><i>r,g,b</i><b>altColor=</b><i>r,g,b</i><b>        priority=</b><i>priority</i><b>autoScale=</b><i>on|off</i><b>alwaysZero=</b><i>on|off</i><b>        gridDefault=</b><i>on|off</i><b>maxHeightPixels=</b><i>max:default:min</i><b>        graphType=</b><i>bar|points</i><b>viewLimits=</b><i>lower:upper</i><b>        yLineMark=</b><i>real-value</i><b>yLineOnOff=</b><i>on|off</i><b>        windowingFunction=</b><i>maximum|mean|minimum</i><b>smoothingWindow=</b>off|2-16</pre>
</blockquote>
<p>有一点需要注意：<b> </b>These coordinates are <a href="http://genome.ucsc.edu/FAQ/FAQtracks.html#tracks1">zero-based, half-open</a>.</p>
</div>
<div> Chromosome positions are specified as 0-relative. The first chromosome position is 0. The last position in a chromosome of length N would be N - 1. Only positions specified have data.</div>
<div> Positions not specified do not have data and will not be graphed.</div>
<div>All positions specified in the input data must be in numerical order.</div>
<div>我这里有一个MACS对CHIP-seq数据call peaks附带的BedGraph文件，也可以用工具直接从bam格式文件得到：</div>
<div>
<blockquote>
<div><span style="color: #ff0000;"><b>track type=bedGraph name="hek_treat_all" description="Extended tag pileup from MACS version 1.4.2 20120305"</b></span></div>
<div>chr1    9997    9999    1</div>
<div>chr1    9999    10000   2</div>
<div>chr1    10000   10001   4</div>
<div>chr1    10001   10003   5</div>
<div>chr1    10003   10007   6</div>
<div>chr1    10007   10010   7</div>
<div>chr1    10010   10012   8</div>
<div>chr1    10012   10015   9</div>
<div>chr1    10015   10016   10</div>
<div>chr1    10016   10017   11</div>
<div>chr1    10017   10018   12</div>
<div></div>
</blockquote>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1815.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
