美文网首页可变剪接
wig、bigWig(bw)和bedgraph(bdg)文件详解

wig、bigWig(bw)和bedgraph(bdg)文件详解

作者: Z_bioinfo | 来源:发表于2022-05-28 15:29 被阅读0次

    前言

    1. wig文件格式
      1.1 variableStep格式wig
      1.2 fixedStep格式wig
      1.3 注意
    2. bigwig格式
    3. bedgraph
      3.1 属性设置
      3.2 格式说明
    4. 格式转化工具
      4.1 bam文件转化为bigwig
      4.2 wig/bw/bedgraph相互转换工具

    先放一张关系图及格式转化工具

    image.png

    前言

    我们比对完fastq文件后,我们可以拿到bam文件,但是bam文件非常的大,处理起来很不方便。如果我们只是想知道这些read都比对到了基因组的什么区域,以及基因组上每个区域有多少read存在,此时用wig/bw/bdg则会更加方便。

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

    samtools depth -r chr12:126073855-126073965  example.sorted.bam
    
    chr12    126073855    5
    chr12    126073856    15
    chr12    126073857    31
    chr12    126073858    40
    chr12    126073859    44
    chr12    126073860    52
    ~~~~~~~~~其余省略输出~~~~~~~~~
    

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

    它不需要第一列了,因为全部是重复字段,只需要在每个染色体的第一行定义好染色体即可。下面我们来说明这些不同的格式是怎么记录测序深度的。

    1. wig文件格式

    wig文件全称叫Wiggle Track Format,用来绘制基因组上的图形轨迹的文件格式。wig格式是较老的格式,用来显示密集且连续的数据,比如GC含量,概率分数,转录组数据等。

    wig数据有两种类型:

    variableStep:基因组window大小不定

    fixedStep:基因组window大小相同

    1.1 variableStep格式wig

    声明行:

    单词variableStep开头

    染色体

    window大小(span):基因组上window大小,默认为1

    数据行:两列,分别包含染色体和测序深度值。

    举例说明:

    variableStep chrom=chr19 span=150
    49304701 10.0    #chr19:49304701-49304851范围内深度为10.0
    49304901 12.5    #chr19:49304901-49305051范围内深度为12.5
    49305401 15.0    #chr19:49305401-49305551范围内深度为15.0
    

    1.2 fixedStep格式wig
    声明行:

    单词fixedStep开头

    染色体

    起始坐标

    步长(step):相邻window起点之间的距离

    window大小(span):基因组上window大小,默认为1

    数据行:一列,包含测序深度值。

    举例说明:

    fixedStep chrom=chr19 start=49307401 step=300 span=200
    1000    #chr19:49307401-49307601范围内深度为1000
     900    #chr19:49307701-49307901范围内深度为900
     800    #chr19:49308001-49308201范围内深度为800
    

    1.3 注意

    上述介绍了wig数据部分,其实wig还有一部分是设置展示图形的参数,这里不做过多解释。

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

    browser position chr19:49304200-49310700
    browser hide all
    #    150 base wide bar graph at arbitrarily spaced positions,
    #    threshold line drawn at y=11.76
    #    autoScale off viewing range set to [0:25]
    #    priority = 10 positions this as the first graph
    #    Note, one-relative coordinate system in use for this format
    track type=wiggle_0 name="variableStep" description="variableStep format" visibility=full autoScale=off viewLimits=0.0:25.0 color=50,150,255 yLineMark=11.76 yLineOnOff=on priority=10
    variableStep chrom=chr19 span=150
    49304701 10.0
    49304901 12.5
    49305401 15.0
    49305601 17.5
    49305901 20.0
    49306081 17.5
    49306301 15.0
    49306691 12.5
    49307871 10.0
    #    200 base wide points graph at every 300 bases, 50 pixel high graph
    #    autoScale off and viewing range set to [0:1000]
    #    priority = 20 positions this as the second graph
    #    Note, one-relative coordinate system in use for this format
    track type=wiggle_0 name="fixedStep" description="fixedStep format" visibility=full autoScale=off viewLimits=0:1000 color=0,200,100 maxHeightPixels=100:50:20 graphType=points priority=20
    fixedStep chrom=chr19 start=49307401 step=300 span=200
    1000
     900
     800
     700
     600
     500
     400
     300
     200
     100
    

    2. bigwig格式

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

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

    wigToBigWig:http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/wigToBigWig

    3. bedgraph

    BedGraph格式文件,它是BED文件的扩展,是4列的BED格式(正常BED文件只有3列或者6列),但是需要添加UCSC的Genome Browser工具里面显示的属性,但是一般就定义有限的几个属性即可。

    3.1 属性设置

    track type=bedGraph name=track_label description=center_label visibility=display_modecolor=r,g,baltColor=r,g,b priority=priority autoScale=on|off alwaysZero=on|off gridDefault=on|off maxHeightPixels=max:default:min graphType=bar|points viewLimits=lower:upper yLineMark=real-valuey LineOnOff=on|off windowingFunction=maximum|mean|minimum smoothingWindow=off|2-16
    
    ##type=bedGraph是必须的,其他的可改
    

    3.2 格式说明

    和bed文件基本一致,只是多了:

    最后第1行的设置信息

    第4列的测序深度信息

    track type=bedGraph name="BedGraph Format" description="BedGraph format" visibility=full color=200,100,0 altColor=0,100,200 priority=20
    chr19 49302000 49302300 -1.0
    chr19 49302300 49302600 -0.75
    chr19 49302600 49302900 -0.50
    chr19 49302900 49303200 -0.25
    chr19 49303200 49303500 0.0
    chr19 49303500 49303800 0.25
    chr19 49303800 49304100 0.50
    chr19 49304100 49304400 0.75
    chr19 49304400 49304700 1.00
    

    4.如何转换

    4.1 bam文件转化为bigwig
    将bam文件转为bw文件,有很多工具可以实现这个目标,但是我们这里只记录deeptools:

    bamCoverage --bam a.bam -o a.SeqDepthNorm.bw \
        --binSize 10
        --normalizeUsing RPGC
        --effectiveGenomeSize 2150570000
    

    4.2 wig/bw/bedgraph相互转换工具
    bedGraphToBigWig :Convert a bedGraph file to bigWig format. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bedGraphToBigWig

    bigWigToBedGraph :Convert from bigWig to bedGraph format. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigToBedGraph

    bigWigToWig :Convert bigWig to wig. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigToWig

    bigWigSummary :Extract summary information from a bigWig file. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigSummary

    bigWigAverageOverBed :Compute average score of big wig over each bed, which may have introns. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigAverageOverBed

    bigWigInfo :Print out information about bigWig file. http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/bigWigInfo

    4.3bigwig文件转为bed文件

    分两步进行:将bigwig文件转为bdg文件,再将bdg文件转为bed文件

    bigWigToBedGraph in.bigWig out.bedGraph
    grep -v track out.bedGraph | cut -f 1-3 > out.bed
    

    相关文章

      网友评论

        本文标题:wig、bigWig(bw)和bedgraph(bdg)文件详解

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