Bismark是進行甲基化分析過程中常用到的軟件,可以將bisulfite處理后的測序reads比對到參考基因組上,得到參考基因組相應位置的甲基化水平。
我的甲基化數據為WGBS所測得的數據,使用Bismark call methylation分為以下幾步:
1.處理WGBS測序數據,使用trimmomatic去接頭;
2.為參考基因組建立索引;(基因組約450M,這一步用時15min);
bismark_genome_preparation? --bowtie2?yourdir? ##yourdir中存放genome
3.比對甲基化數據;(這步用時較久,每個個體大概花費3h)
nohup bismark --bowtie2 -N 0 -L 20 --quiet --un --ambiguous --bam --parallel 30 -o outdir? refdir -1 file1 -2 file2 &
4.去冗余;(0.5h)
nohup deduplicate_bismark -p -bam alignment_bam &
對3中比對的bam文件進行去冗余
5.提取甲基化信息;(4h)
nohup bismark_methylation_extractor -p --parallel 40 --comprehensive --no_overlap--bedGraph --cytosine_report --CX_context --split_by_chromosome --counts--buffer_size 20G --report --samtools_path yourpath/smrtlink_v9/smrtcmds/bin --genome_folder refdir bam??? -o outdir &
##--split_by_chromosome參數可以將結果按照染色體拆分,便于后續可視化。
結果生成多個文件,主要使用每條染色體的甲基化文件,例:
*_bismark_bt2_pe.deduplicated.CX_report.txt.chrChr14.CX_report.txt
文件格式如下:
各列分別為:
<chromosome> <position> <strand> <count methylated> <count unmethylated> <C-context> <trinucleotide context>
第一列:染色體;
第二列:染色體上具體位點(以1開始);
第三列:正負鏈;
第四列:比對到該位點發生甲基化的reads數;
第五列:比對到該位點未發生甲基化的read數;
第六列:甲基化類型,有三種:CG, CHG, CHH;
第七列:該位點的三核苷酸序列;
6.IGV可視化
為了使用IGV進行可視化,需要構建bedgraph格式文件,bedgraph格式文件可以在IGV中對continuous-valued 數據進行可視化,適用于轉錄組數據或概率得分(The bedGraph format allows display of continuous-valued data in track format. This display type is useful for probability scores and transcriptome data.?),因此也適合展示甲基化率。bedgraph文件格式如下:
chromA??chromStartA??chromEndA??dataValueA chromB??chromStartB??chromEndB??dataValueB
第一列:染色體;
第二列:基因/位點在染色體上的起始位置;
第三列:基因/位點在染色體上的結束位置;
第四列:數值;(本次分析中為甲基化率)
bismark_methylation_extractor會生成一個總的bedgraph文件:
*_P_1_bismark_bt2_pe.deduplicated.bedGraph.gz
但該文件是整個基因組所有甲基化C位點,沒有分CG/CHG/CHH信息,也不利于后續可視化,因此根據5提到的CX_report.txt(已按照染色體拆分)文件拆分CG,CHG,CHH三類甲基化后轉換成bedgraph格式文件。
首先使用bismarkCXmethykit.pl腳本進行轉換,轉換后出現以CG_methykit.txt,CHG_methykit.txt,CHH_methykit.txt為后綴的拆分甲基化類型的文件,文件格式如下:
再使用R腳本轉換成bedgraph文件,只需保留chr列,base列和freqC列,R腳本如下:
Args <- commandArgs(T)
Args[1]
myfile=read.table(Args[1],header=T)
outfile=sub("_P_1_bismark_bt2_pe.deduplicated.CX_report.txt.chrChr19.CX_report.txt", "",Args[1])
file_out=sub("_methykit.txt", ".bedgraph", outfile )? ?###輸出文件
chr<-as.character(myfile$chr)
pos<-as.integer(myfile$base)
pos2<-as.integer(myfile$base)
freq<-as.numeric(myfile$freqC)
outf<-data.frame(chr,pos,pos2,freq, check.names = F)? ?###合并以上四列,check.names = F可以防止將字符串轉化為其他內容。
outf$chr<-factor(outf$chr)
dim(myfile)
dim(outf)? ###檢查一下新文件和原文件行數是否相等
write.table(outf, file=file_out, quote=F,col.names = F, row.names = F)? ##輸出
轉換后生成以CG.bedgraph/CHG.bedgraph/CHH.bedgraph為后綴的文件,文件內容如下:
符合IGV需求的格式,可以用于可視化。
##由于有時候整個基因組的bedgraph文件太大,我們只想看某條染色體的情況,可以先使用linux提取某條染色體以及某類C(CG/CHG/CHH)的信息,然后轉成bedgraph格式。可以大大降低運行時間。
export PATH=/gpfs/home/fffu/anaconda3/envs/R4.2/bin:$PATH
###提取chrA01的CG信息
for file in ./*R_clean_1_bismark_bt2_pe.deduplicated.CX_report.txt
do
sample=${file##*/}
short=${sample%%R_clean_1_bismark_bt2_pe.deduplicated.CX_report.txt}
outall=$short"CG.report"
outchr1=$short"chr1_CG.report"
awk '$6 == "CG"' $file? > $outall
awk '$1 == "chrA01"' $outall? > $outchr1
done
### bismarkCXmethykit.pl計算甲基化率
for file in ./*chr1_CG.report
do
perl bismarkCXmethykit.pl $file
done
### bismarkCXmethykit.pl結果轉為bedgraph結果
for file in ./*CG_methykit.txt
do
Rscript methykit2bedgraph.R? $file
done
###生成的結果可用于IGV可視化。
bismark介紹見官網:https://github.com/FelixKrueger/Bismark/tree/master/Docs
bedgraph介紹:
http://genome.ucsc.edu/goldenPath/help/bedgraph.html
bismarkCXmethykit.pl腳本參考:
http://www.lxweimin.com/p/5c27908ff1e3