美文网首页chip-seqDNase-seqChip-seq
wig、bigWig和bedgraph文件详解

wig、bigWig和bedgraph文件详解

作者: 超级无敌大蜗牛 | 来源:发表于2020-02-19 11:46 被阅读0次

    from 生信菜鸟团(http://www.bio-info-trainee.com/1815.html

    我们一般会熟悉sam/bam格式文件,就是把测序reads比对到参考基因组后的文件!bam或者bed格式的文件主要是为了追踪我们的reads到底比对到了参加基因组的什么区域,而UCSC规定的这几个文件格式(wig、bigWig和bedgraph)用处不一样,仅仅是为了追踪参考基因组的各个区域的覆盖度,测序深度!而且这些定义好的文件,可以无缝连接到UCSC的Genome Browser工具里面进行可视化!

    这个网站提供了这几种数据格式的构造及转换脚本:http://barcwiki.wi.mit.edu/wiki/SOPs/coordinates

    对SE数据,可以用macs2 pileup --extsize 200 -i sample.bam -osample.bdg 把bam文件转换为bedgraph文件,不需要call peaks这一步骤。

    而UCSC的ftp里面可以下载bedGraphToBigWig sample.bdg ~/reference/genome/mm10/mm10.chrom.sizessample.bw 把bedgraph文件转换为bw文件,其余的转换工具都可以下载。

    具体文件格式定义请直接看UCSC的官网,下面是我基于自己的理解来翻译的,没什么特殊的,建议大家看原文,然后自己翻译一个,跟我比较!

    Wiggle Track Format (WIG):http://genome.ucsc.edu/goldenPath/help/wiggle.html

    bigWig Track Format :http://genome.ucsc.edu/goldenPath/help/bigWig.html

    BedGraph Track Format :http://genome.ucsc.edu/goldenPath/help/bedgraph.html

    这3种文件格式都是UCSC规定的,所以它提供了系列工具进行互相转换,可以直接下载可执行版本程序:http://hgdownload.cse.ucsc.edu/admin/exe/

    常见的工具如下:

    • bigWigToBedGraph — this program converts a bigWig file to ASCII bedGraph format.
    • bigWigToWig — this program converts a bigWig file to wig format.
    • bigWigSummary — this program extracts summary information from a bigWig file.
    • bigWigAverageOverBed — this program computes the average score of a bigWig over each bed, which may have introns.
    • bigWigInfo — this program prints out information about a bigWig file.

    其实对我们的bam文件,用samtools软件也可以很容易得到基因组区域的覆盖度和测序深度,比如:

    samtools depth -r chr12:126073855-126073965 Ip.sorted.bam

    chr12 126073855 5

    chr12 126073856 15

    chr12 126073857 31

    chr12 126073858 40

    chr12 126073859 44

    chr12 126073860 52

    这其实就是wig文件的雏形,但是wig文件会更复杂一点!

    首先它不需要第一列了,因为全部是重复字段,只需要在每个染色体的第一行定义好染色体即可。

    首先需要设置这个wig文件在UCSC的Genome Browser工具里面显示的属性:
    track type=wiggle_0 name=track_labeldescription=center_labelvisibility=display_modecolor=r,g,baltColor=r,g,bpriority=priorityautoScale=on|offalwaysZero=on|offgridDefault=on|offmaxHeightPixels=max:default:mingraphType=bar|pointsviewLimits=lower:upperyLineMark=real-valueyLineOnOff=on|offwindowingFunction=mean+whiskers|maximum|mean|minimumsmoothingWindow=off|2-16

    type=wiggle_0 这个是默认的, 而且到目前为止,必须是这样的!其余的都是可选参数,自己读官网说明

    这些参数一般不用管,除非你很熟悉了UCSC的Genome Browser工具

    然后需要设置每条染色体的属性,几个比较重要的参数是:

    fixedStepchrom=chrNstart=positionstep=stepInterval[span=windowSize]

    下面是wig的一个具体例子:

    track type=print wiggle_0 name=hek description=hek

    variableStep chrom=chr1 span=10

    10008 7

    10018 14

    10028 27

    10038 37

    10048 45

    10058 43

    10068 37

    10078 26

    UCSC也提供了一个wig文件:http://genome.ucsc.edu/goldenPath/help/examples/wiggleExample.txt

    可以看到我设置的参数很少很少,而且我是直接对sort后的bam文件用脚本变成wig文件的。

    那么bigwig格式文件就没什么好讲的了,它就是wig格式文件的二进制压缩版本,这样更加节省空间。

    我们只需要用UCSC提供的工具把自己的wig文件转换一下即可,步骤如下:

    • Save this wiggle file to your machine (this satisfies steps 1 and 2 above).
    • Save this text file to your machine. It contains the chrom.sizes for the human (hg19) assembly (this satisfies step 4 above).
    • Download the wigToBigWig utility (see step 3).
    • Run the utility to create the bigWig output file (see step 5):
      **wigToBigWig** wigVarStepExample.gz hg19.chrom.sizes myBigWig.bw

    最后我们讲一下BedGraph格式文件,它是BED文件的扩展,是4列的BED格式,但是需要添加UCSC的Genome Browser工具里面显示的属性,但是一般就定义有限的几个属性即可。
    track type=bedGraph name=track_labeldescription=center_label visibility=display_modecolor=r,g,baltColor=r,g,b priority=priorityautoScale=on|offalwaysZero=on|off gridDefault=on|offmaxHeightPixels=max:default:min graphType=bar|pointsviewLimits=lower:upper yLineMark=real-valueyLineOnOff=on|off windowingFunction=maximum|mean|minimumsmoothingWindow=off|2-16
    有一点需要注意:These coordinates are zero-based, half-open.

    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.

    Positions not specified do not have data and will not be graphed.

    All positions specified in the input data must be in numerical order.

    我这里有一个MACS对CHIP-seq数据call peaks附带的BedGraph文件,也可以用工具直接从bam格式文件得到:

    track type=bedGraph name="hek_treat_all" description="Extended tag pileup from MACS version 1.4.2 20120305"

    chr1 9997 9999 1

    chr1 9999 10000 2

    chr1 10000 10001 4

    chr1 10001 10003 5

    chr1 10003 10007 6

    chr1 10007 10010 7

    chr1 10010 10012 8

    chr1 10012 10015 9

    chr1 10015 10016 10

    chr1 10016 10017 11

    chr1 10017 10018 12

    相关文章

      网友评论

        本文标题:wig、bigWig和bedgraph文件详解

        本文链接:https://www.haomeiwen.com/subject/kjtafhtx.html