R包——maftools 可视化神器

Python012

R包——maftools 可视化神器,第1张

随着癌症基因组学的进步,突变注释格式(MAF)被广泛接受并用于存储检测到的体细胞变体。 癌症基因组图谱项目对30多种不同的癌症进行了测序,每种癌症类型的样本量超过200种。由体细胞变体组成的结果数据以MAF格式形式存储。 只要数据采用MAF格式,该软件包就会尝试从TCGA源或任何内部研究中有效地汇总,分析,注释和可视化MAF文件.

使用前要先将文件转换为maf格式,对于VCF格式文件,可以使用 vcf2maf 进行格式转换.

maf文件包含的内容:

注: 安装过程特别麻烦,按了好几天,R版本要求3.3以上,也不要使用最新版本,可能有的包新版本还没同步 。我使用的是:

annovarToMaf函数说明

Converts variant annotations from Annovar into a basic MAF.将annovar格式转换为maf格式

| 参数 |详细解释 |

| annovar | input annovar annotation file.|

| Center | Center field in MAF file will be filled with this value. Default NA.(MAF文件中的中心字段将填充此值。 默认NA)|

| refBuild | NCBI_Build field in MAF file will be filled with this value. Default hg19.(MAF文件中的NCBI_Build字段将填充此值。 默认hg19)|

| tsbCol | column name containing Tumor_Sample_Barcode or sample names in input file.(列名包含Tumor_Sample_Barcode或输入文件中的示例名称) |

| table | reference table used for gene-based annotations. Can be 'ensGene' or 'refGene'. Default 'refGene'(用于基于基因的注释的参考表。 可以是'ensGene'或'refGene'。 默认'refGene)|

| basename | If provided writes resulting MAF file to an output file. (将结果MAF文件写入输出文件)|

| sep | field seperator for input file. Default tab seperated.|

| MAFobj | If TRUE, returns results as an [MAF](http://127.0.0.1:37698/help/library/maftools/help/MAF object.|

| sampleAnno | annotations associated with each sample/Tumor_Sample_Barcode in input annovar file. If provided it will be included in MAF object. Could be a text file or a data.frame. Ideally annotation would contain clinical data, survival information and other necessary features associated with samples. Default NULL.(与输入annovar文件中的每个样本/ Tumor_Sample_Barcode相关联的注释。 如果提供,它将包含在MAF对象中。 可以是文本文件或data.frame。 理想情况下,注释将包含临床数据,生存信息和与样本相关的其他必要特征。 默认为NULL)|

然后用linux处理掉那些无义突变,也可以在后续设置参数去掉无义突变

Takes tab delimited MAF (can be plain text or gz compressed) file as an input and summarizes it in various ways. Also creates oncomatrix - helpful for visualization.

该文件将每个样本中的变体数显示为堆积条形图,将变体类型显示为Variant_Classification汇总的箱形图。 我们可以在堆积的条形图中添加平均线或中线,以显示整个群组中变体的平均值/中值数

Plots maf summary.

Oncoplot函数使用“ComplexHeatmap”来绘制oncoplots2。 具体来说,oncoplot是ComplexHeatmap的OncoPrint功能的包装器,几乎没有任何修改和自动化,使绘图更容易。 侧面条形图和顶部条形图可分别由drawRowBar和drawColBar参数控制。

top的值需要视情况而定

takes output generated by read.maf and draws an oncoplot

通过包括与样本相关的注释(临床特征),改变变体分类的颜色并包括显着性的q值(从MutSig或类似程序生成),可以进一步改善Oncoplots。

[图片上传失败...(image-fc6334-1536734778754)]

使用oncostrip函数可视化任何一组基因,它们在每个样本中绘制类似于cBioPortal上的OncoPrinter工具的突变。 oncostrip可用于使用top或gene参数绘制任意数量的基因

titv函数将SNP分类为 Transitions_vs_Transversions ,并以各种方式返回汇总表的列表。 汇总数据也可以显示为一个箱线图,显示六种不同转换的总体分布,并作为堆积条形图显示每个样本中的转换比例。

takes output generated by read.maf and classifies Single Nucleotide Variants into Transitions and Transversions.

棒棒糖图是简单且最有效的方式,显示蛋白质结构上的突变点。许多致癌基因具有比任何其他基因座更频繁突变的优先位点。这些斑点被认为是突变热点,棒棒糖图可以用于显示它们以及其他突变。我们可以使用函数lollipopPlot绘制这样的图。这个功能要求我们在maf文件中有氨基酸改变信息。然而,MAF文件没有关于命名氨基酸变化字段的明确指南,不同的研究具有不同的氨基酸变化的字段(或列)名称。默认情况下,lollipopPlot查找列AAChange,如果在MAF文件中找不到它,则会打印所有可用字段并显示警告消息。对于以下示例,MAF文件包含字段/列名称“Protein_Change”下的氨基酸变化。我们将使用参数AACol手动指定它。此函数还将绘图作为ggplot对象返回,如果需要,用户稍后可以修改该对象。

maftools还可以制作很多图,比如

还可以用函数geneCloud绘制突变基因的词云图。 每个基因的大小与其突变/改变的样品总数成比例。

癌症中的许多引起疾病的基因共同发生或在其突变模式中显示出强烈的排他性。 可以使用somaticInteractions函数检测这种相互排斥或共同发生的基因组,其执行成对的Fisher's Exact检验以检测这种显着的基因对。 somaticInteractions函数还使用cometExactTest来识别涉及>2个基因的潜在改变的基因集

maftools包 功能很强大,具体可参考:

http://bioconductor.org/packages/release/bioc/vignettes/maftools/inst/doc/maftools.html

#####删除文件的前N行####

tail -n +N Het-158-rawGATK-indel-filter.vcf | head

#####合并所有VCF文件####(合并之后记得加上第一行)

for i in *.vcf do sed -i '1d' $i done

for i in *.vcf do cat $i >> 11.vcf done

#####利用annovar转换格式#####

for i in *.vcf do perl /media/pc/disk2/annovar/convert2annovar.pl -format vcf4 $i >$i.avinput

#####添加样本名称#####(先把snp和indel文件合并会省事一点)

awk 'BEGIN{OFS="\t"}{print "chr"$1,$2,$3,$4,$5,"Het-158"}' Het-158-indel.vcf.avinput > Het-158-indel.tsv

#####合并所有tsv#####

for i in *.tsv do cat $i >> all.tsv done

#####利用annovar注释####

perl /media/pc/disk2/annovar/table_annovar.pl all.tsv /media/pc/disk2/annovar/mousedb/ -buildver mm10 -out variants --otherinfo -remove -protocol refGene -operation g -nastring NA

####可选步骤:提取exonic上的信息#####

grep "exonic" variants.mm10_multianno.txt > exonic.mm10_multianno.txt

####Rstudio:导入到maftools###

>library(maftools)

>var.annovar.maf = annovarToMaf(annovar = "variants.mm10_multianno.txt",Center = 'CSI-NUS', refBuild = 'mm10',tsbCol = 'Tumor_Sample_Barcode', table = 'refGene')

>write.table(x=var.annovar.maf,file="var_annovar_maf",quote= F,sep="\t",row.names=F)

>var_maf = read.maf(maf ="var_annovar_maf")

>plotmafSummary(maf = var_maf, rmOutlier = TRUE, addStat = 'median',showBarcodes = T)

>oncoplot(maf = var_maf, top = 10, fontSize = 12)