作者:Jenny
審稿:童蒙
排版:amethyst
引言
在表觀多組學(xué)聯(lián)合分析中,我們經(jīng)常會(huì)遇到想對(duì)某個(gè)區(qū)域可視化,每當(dāng)看到高分文章里漂亮的tracks圖,就羨慕不已。今天小編就給大家介紹一款非常好用的python包—pyGenomeTracks,它能夠滿足Hi-C、ChIP-seq/ATAC-seq、RNA-seq和BS-seq等多種組學(xué)數(shù)據(jù)類型。接下來,就讓我們一步步了解下如何實(shí)現(xiàn)的吧!
pyGenomeTracks的使用方法很簡單易懂,首先需要生成相應(yīng)的配置文件hic_track.ini(可以自己編輯也可以用make_tracks_file命令自動(dòng)生成),然后用pyGenomeTracks命令對(duì)特定區(qū)域生成相應(yīng)的hic_track.pdf便可。
命令如下所示:
#step1
make_tracks_file --trackFiles hic_data.h5 bigwig.bw -o hic_track.ini
#step2
pyGenomeTracks --tracks hic_track.ini --region chrX:2500000-3500000 --outFileName hic_track.pdf
有小伙伴馬上發(fā)現(xiàn),畫出來的結(jié)果跟最上面展示的有些差異。這是因?yàn)楹芏鄷r(shí)候我們需要對(duì)配置文件track.ini進(jìn)行修改。另一方面,我們需要設(shè)計(jì)自己個(gè)性化的track,比如基因注釋文件,甲基化CpGs位點(diǎn)還有Loops、AB compartments等等,有時(shí)候因?yàn)閿?shù)據(jù)的特殊性我們還得稍微調(diào)整下參數(shù)。因此為了畫出能夠直接用于文章發(fā)表的精美tracks,還是很有必要對(duì)一些基本概念了解清楚的。
01 軟件安裝
pyGenomeTracks需要python >=3.6,這里小編建議用Anaconda3安裝。
前幾期我們有介紹如何安裝Anaconda3,有需求的小伙伴可以點(diǎn)后面鏈接看看,大家按照步驟安裝就可以了,Anaconda3會(huì)自動(dòng)安裝python3.6的。(大火的單細(xì)胞分析軟件Seurat,不能正常安裝,怎么辦?)
#安裝命令
conda install -c bioconda -c conda-forge pygenometracks
02 文件格式
- bigwig
- bed3(TAD domain),bed4(可視化peaks區(qū)域),bed6(最簡單的基因格式),bed12(UCSC gene format)
- arcs(Loops)
- Hi-C matrices
- bedgraph
- epilogos
- narrow peaks
按照軟件說明, pyGenomeTracks可以對(duì)以上文件格式進(jìn)行可視化,接下來小編對(duì)主要的幾種格式進(jìn)行介紹。
2.1 bigwig
bigwig是一種十分常用的二進(jìn)制可視化格式,可以直接由bam文件生成。
小編這里對(duì)bedgraph格式?jīng)]有嘗試成功,大家如果也不行的話,可以轉(zhuǎn)成bigwig格式再用 pyGenomeTracks畫。
#bam轉(zhuǎn)bigwig
bamCoverage -b in.bam --outFileName in.bw --binSize 50 --normalizeUsing RPKM --smoothLength 300 --outFileFormat bigwig
#bedgraph轉(zhuǎn)bigwig
bedGraphToBigWig in.bedGraph chrom.sizes out.bw
目前,ChIP-seq、ATAC-seq和RNA-seq的信號(hào)強(qiáng)度都可以用bigwig文件可視化的。另外BS-seq的CpGs甲基化位點(diǎn)和Hi-C組學(xué)的AB compartments(PC1值)也可以生成bedgraph格式再轉(zhuǎn)bigwig。
2.2 bed
bed格式的種類非常多,包括bed3、bed4、bed6、bed12等,它們的共同點(diǎn)是前3列都是chr、start、end。
第4列是名稱,如果是基因我們通常用symbol名,第5列的信息一般不重要(可以都用0),第6列是基因的+-鏈信息。
這里我們主要介紹下bed12格式,專門用于USCS gene format可視化的。
其中translation_start,translation_end需要在TSS、TES范圍內(nèi),用TSS、TES也是可以。
其實(shí)我們可以用gtf生成genePredName.txt文件,然后按照上面格式要求自己寫腳本生成bed12便可。
- bed是0-based格式,也就是從0開始,左閉右開[ )區(qū)間,如果出現(xiàn)start=end的情況(如對(duì)SNP位點(diǎn)用bed格式可視化時(shí)),pyGenomeTracks會(huì)報(bào)錯(cuò)。另外我們還必須對(duì)bed文件進(jìn)行sort才行。
gtfToGenePred -genePredExt -geneNameAsName2 genes.gtf genePredName.txt
sort -k 1,1 -k 2,2n test.bed > out.bed
2.3 Hi-C文件格式
Hi-C組學(xué)除了前面我們提到的TAD_domain.bed格式和AB compartment用bedGraph表示外,我們還有利用matrix文件畫熱圖以及利用interaction信息畫Loops。
1)loops.arcs
Loops必須采用arcs格式,如下圖所示。
2)matrix.h5
matrix必須用h5格式,如果我們利用HiCPro軟件得到的matrix需要轉(zhuǎn)成h5格式。我們可以利用HiCExplorer軟件來完成,它可以對(duì)h5、cool、hic、homer、hicpro這些格式相互轉(zhuǎn)換。
hicConvertFormat -m 40000_iced.matrix --bedFileHicpro 40000_abs.bed --inputFormat hicpro --outputFormat h5 -o 40000_iced.h5
03 軟件實(shí)操
3.1數(shù)據(jù)準(zhǔn)備
參考2部分準(zhǔn)備以下文件:
file = hic_data.h5
file = domains.bed
file = bigwig.bw
file = test.arcs
file = genes_bed12.bed
生成以下配置文件test.ini
可以用make_tracks_file自動(dòng)生成,之后參考以下內(nèi)容修改,需要注意的是:
depth作為熱圖的高度可以調(diào)整,顏色colormap也可以為Reds。另外min_value、max_value 、transform也可以根據(jù)實(shí)際情況調(diào)整。
[x-axis]
where = top
[hic matrix]
file = hic_data.h5
title = Hi-C data
colormap = RdYlBu_r
#colormap = Reds
# depth is the maximum distance plotted in bp. In Hi-C tracks
# the height of the track is calculated based on the depth such
# that the matrix does not look deformed
depth = 200000
transform = log1p
file_type = hic_matrix
[tads]
file = domains.bed
file_type = domains
border color = black
color = none
line_width=1.5
# the tads are overlay over the hic-matrix
# the share-y options sets the y-axis to be shared
# between the Hi-C matrix and the TADs.
overlay previous = share-y
[spacer]
[bigwig file test]
file = bigwig.bw
# height of the track in cm (optional value)
height = 4
title = ChIP-seq
min_value = 0
max_value = 30
transform = log1p
[spacer]
[test arcs]
file = test.arcs
line_width = 3
color=purple
#color = RdYlGn
title = Loops
height = 3
[test gene rows]
file = genes_bed12.bed
height = 3
title = UCSC bed12 genes
fontsize = 8
style = UCSC
gene_rows = 3
color=black
border color = black
3.2生成track圖
pyGenomeTracks --tracks test.ini --region chrX:2800000-3300000 --outFileName test_track.pdf
以上,就是本次分享的全部內(nèi)容了,是不是很容易就能實(shí)現(xiàn)呢!其實(shí)小編這里主要還是起著拋磚引玉的作用,更多精美漂亮的圖還等著各位小伙伴去一一嘗試哦!另外該包的作者在github網(wǎng)址有很詳細(xì)的examples。大家有興趣的話可以去https://github.com/deeptools/pyGenomeTracks/tree/master/pygenometracks/tests/test_data下載鉆研。
參考文獻(xiàn)
https://github.com/deeptools/pyGenomeTracks
https://hicexplorer.readthedocs.io/en/latest/content/installation.html
Fidel Ramírez, Vivek Bhardwaj, Laura Arrigoni, Kin Chung Lam, Bj?rn A. Grüning, José Villaveces, Bianca Habermann, Asifa Akhtar & Thomas Manke. High-resolution TADs reveal DNA sequences underlying genome organization in flies. Nature Communications (2018) doi:10.1038/s41467-017-02525-w