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


目录

介绍

准备

格式转换

总体分析框架

maftools安装

正式处理

#读入annovar文件转换为maf——annovarToMaf

Description

Usage

Arguments

#读入maf文件——read.maf

Description

Usage

Arguments

绘制maf文件的摘要——plotmafSummary

Description

Usage

Arguments

#绘制瀑布图——oncoplots

Description

Usage

Arguments

#绘制箱线图—— titv

Description

Usage

Arguments

#绘制棒棒图——lollipopPlot


介绍

With advances in Cancer Genomics, Mutation Annotation Format (MAF) is being widely accepted and used to store somatic variants detected. The Cancer Genome Atlas Project has sequenced over 30 different cancers with sample size of each cancer type being over 200. Resulting data consisting of somatic variants are stored in the form of Mutation Annotation Format. This package attempts to summarize, analyze, annotate and visualize MAF files in an efficient manner from either TCGA sources or any in-house studies as long as the data is in MAF format.

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


准备

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

maf文件包含的内容:

  • Mandatory fields: Hugo_Symbol, Chromosome, Start_Position, End_Position, Reference_Allele, Tumor_Seq_Allele2, Variant_Classification, Variant_Type and Tumor_Sample_Barcode.

  • Recommended optional fields: non MAF specific fields containing VAF (Variant Allele Frequecy) and amino acid change information.

格式转换

#将突变结果进行注释,得到txt文件
for i in *.somatic.anno;do perl ~/software/Desktop/annovar/table_annovar.pl $sra_file /home/yang.zou/database/humandb_new/ -buildver hg19 -out variants --otherinfo -remove -protocol ensGene -operation g -nastring NA -outfile;done#然后将所有.hg19_multianno.txt文件添加一列填入文件名前缀并将所有txt文件拼接成一个文件,提取出含有外显子的信息
for i in *.hg19_multianno.txt;do sed '1d' $i | sed "s/$/${i%%.*}/" >> all_annovar;done
grep -P "\texonic\t" all_annovar > all_annovar2#格式转换
perl to-maftools.pl all_annovar2         #将文件转换为maf格式
#to-maftools.pl
use strict;
use warnings;open (FA,"all_annovar2");
open (FB,">all_annovar3");print FB "Chr\tStart\tEnd\tRef\tAlt\tFunc.ensGene\tGene.ensGene\tGeneDetail.ensGene\tExonicFunc.ensGene\tAAChange.ensGene\tTumor_Sample_Barcode\n";
while (<FA>){chomp;my @l=split /\t/,$_;print FB $l[0],"\t",$l[1],"\t",$l[2],"\t",$l[3],"\t",$l[4],"\t",$l[5],"\t",$l[6],"\t",$l[7],"\t",$l[8],"\t",$l[9],"\t",$l[10],"\n";
}

总体分析框架


maftools安装

source("http://bioconductor.org/biocLite.R")
biocLite("maftools")library(maftools)

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

version.string R version 3.4.1 (2017-06-30)

正式处理

#读入annovar文件转换为maf——annovarToMaf

#read maf
var.annovar.maf = annovarToMaf(annovar = "all_annovar3", Center = 'NA', refBuild = 'hg19', tsbCol = 'Tumor_Sample_Barcode', table = 'ensGene',sep = "\t")
write.table(x=var.annovar.maf,file="var_annovar_maf",quote= F,sep="\t",row.names=F)

annovarToMaf函数说明

Description

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

Usage

annovarToMaf(annovar, Center = NULL, refBuild = "hg19", tsbCol = NULL,table = "refGene", basename = NULL, sep = "\t", MAFobj = FALSE,sampleAnno = NULL)

Arguments

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 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处理掉那些无义突变,也可以在后续设置参数去掉无义突变

sed 's/^NA/unknown/' var_annovar_maf > var_annovar_maf2
grep -v "^NA" var_annovar_maf | grep -v -P "\tUNKNOWN\t"> var_annovar_maf2

#读入maf文件——read.maf

var_maf = read.maf(maf ="var_annovar_maf2")
plotmafSummary(maf = var_maf, rmOutlier = TRUE, addStat = 'median')
oncoplot(maf = var_maf, top = 400, writeMatrix=T,removeNonMutated = F,showTumorSampleBarcodes=T)

Description

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.

Usage

read.maf(maf, clinicalData = NULL, removeDuplicatedVariants = TRUE,useAll = TRUE, gisticAllLesionsFile = NULL, gisticAmpGenesFile = NULL,gisticDelGenesFile = NULL, gisticScoresFile = NULL, cnLevel = "all",cnTable = NULL, isTCGA = FALSE, vc_nonSyn = NULL, verbose = TRUE)

Arguments

maf

tab delimited MAF file. File can also be gz compressed. Required. Alternatively, you can also provide already read MAF file as a dataframe.(制表符分隔的MAF文件。 文件也可以是gz压缩的。 也可以将已读取的MAF文件作为数据框提供

clinicalData

Clinical data associated with each sample/Tumor_Sample_Barcode in MAF. Could be a text file or a data.frame. Default NULL.(与MAF中每个样本/ Tumor_Sample_Barcode相关的临床数据。 可以是文本文件或data.frame。 默认为NULL)

removeDuplicatedVariants

removes repeated variants in a particuar sample, mapped to multiple transcripts of same Gene. See Description. Default TRUE.(去除特定样本中的重复变体,映射到同一基因的多个转录本。 见说明。 默认值为TRUE)

useAll

logical. Whether to use all variants irrespective of values in Mutation_Status. Defaults to TRUE. If FALSE, only uses with values Somatic.(逻辑。 是否使用所有变体而不管Mutation_Status中的值。 默认为TRUE。 如果为FALSE,则仅使用值Somatic)

gisticAllLesionsFile

All Lesions file generated by gistic. e.g; all_lesions.conf_XX.txt, where XX is the confidence level. Default NULL.

gisticAmpGenesFile

Amplification Genes file generated by gistic. e.g; amp_genes.conf_XX.txt, where XX is the confidence level. Default NULL.(扩增由gistic生成的基因文件。 例如; amp_genes.conf_XX.txt)

gisticDelGenesFile

Deletion Genes file generated by gistic. e.g; del_genes.conf_XX.txt, where XX is the confidence level. Default NULL.(删除由gistic生成的Genes文件。 例如; del_genes.conf_XX.txt)

gisticScoresFile

scores.gistic file generated by gistic. Default NULL(由gistic生成的scores.gistic文件)

cnLevel

level of CN changes to use. Can be 'all', 'deep' or 'shallow'. Default uses all i.e, genes with both 'shallow' or 'deep' CN changes(CN级别改变使用。 可以是“全部”,“深层”或“浅层”。 默认使用所有,即具有“浅”或“深”CN变化的基因)

cnTable

Custom copynumber data if gistic results are not available. Input file or a data.frame should contain three columns with gene name, Sample name and copy number status (either 'Amp' or 'Del'). Default NULL.(如果gistic结果不可用,则自定义copynumber数据。 输入文件或data.frame应包含三列,其中包含基因名称,样品名称和拷贝编号状态('Amp'或'Del')。 默认为NULL)

isTCGA

Is input MAF file from TCGA source. If TRUE uses only first 12 characters from Tumor_Sample_Barcode.(是来自TCGA源的输入MAF文件。 如果TRUE仅使用Tumor_Sample_Barcode中的前12个字符。)

vc_nonSyn

NULL. Provide manual list of variant classifications to be considered as non-synonymous. Rest will be considered as silent variants. Default uses Variant Classifications with High/Moderate variant consequences. http://asia.ensembl.org/Help/Glossary?id=535: "Frame_Shift_Del", "Frame_Shift_Ins", "Splice_Site", "Translation_Start_Site","Nonsense_Mutation", "Nonstop_Mutation", "In_Frame_Del","In_Frame_Ins", "Missense_Mutation"

verbose

TRUE logical. Default to be talkative and prints summary.


绘制maf文件的摘要——plotmafSummary

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

plotmafSummary(maf = laml, rmOutlier = TRUE, addStat = 'median', dashboard = TRUE, titvRaw = FALSE)

Description

Plots maf summary.

Usage

plotmafSummary(maf, file = NULL, rmOutlier = TRUE, dashboard = TRUE,titvRaw = TRUE, width = 10, height = 7, addStat = NULL,showBarcodes = FALSE, fs = 10, textSize = 2, color = NULL,statFontSize = 3, titleSize = c(10, 8), titvColor = NULL, top = 10)

Arguments

maf

an MAF object generated by read.maf

file

If given pdf file will be generated.

rmOutlier

If TRUE removes outlier from boxplot.

dashboard

If FALSE plots simple summary instead of dashboard style.

titvRaw

TRUE. If false instead of raw counts, plots fraction.

width

plot parameter for output file.

height

plot parameter for output file.

addStat

Can be either mean or median. Default NULL.

showBarcodes

include sample names in the top bar plot.

fs

base size for text. Default 10.

textSize

font size if showBarcodes is TRUE. Default 2.

color

named vector of colors for each Variant_Classification.

statFontSize

font size if addStat is used. Default 3.

titleSize

font size for title and subtitle. Default c(10, 8)

titvColor

colors for SNV classifications.

top

include top n genes dashboard plot. Default 10.


#绘制瀑布图——oncoplots

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

top的值需要视情况而定

oncoplot(maf = var_maf, top = 400, writeMatrix=T,removeNonMutated = F,showTumorSampleBarcodes=T)

Description

takes output generated by read.maf and draws an oncoplot

Usage

oncoplot(maf, top = 20, genes = NULL, mutsig = NULL, mutsigQval = 0.1,drawRowBar = TRUE, drawColBar = TRUE, clinicalFeatures = NULL,annotationDat = NULL, annotationColor = NULL, genesToIgnore = NULL,showTumorSampleBarcodes = FALSE, removeNonMutated = TRUE, colors = NULL,sortByMutation = FALSE, sortByAnnotation = FALSE,annotationOrder = NULL, keepGeneOrder = FALSE, GeneOrderSort = TRUE,sampleOrder = NULL, writeMatrix = FALSE, fontSize = 10,SampleNamefontSize = 10, titleFontSize = 15, legendFontSize = 12,annotationFontSize = 12, annotationTitleFontSize = 12)

Arguments

maf

an MAF object generated by read.maf

top

how many top genes to be drawn. defaults to 20.(显示多少基因)

genes

Just draw oncoplot for these genes. Default NULL.(显示特定基因)

mutsig

Mutsig resuts if availbale. Usually file named sig_genes.txt If provided plots significant genes and correpsonding Q-values as side row-bar. Default NULL.(如果可以的话,Mutsig会重新开始。 通常名为sig_genes.txt的文件如果提供,则绘制重要基因并将Q值作为侧行条对应。 默认为NULL)

mutsigQval

Q-value to choose significant genes from mutsig results. Default 0.1(从mutsig结果中选择重要基因的Q值。 默认值为0.1)

drawRowBar

logical plots barplot for each gene. Default TRUE.(每个基因的逻辑图条形图。 默认值为TRUE。)

drawColBar

logical plots barplot for each sample. Default TRUE.

clinicalFeatures

columns names from 'clinical.data' slot of MAF to be drawn in the plot. Dafault NULL.(MAF的'clinical.data'槽中的列名称将在图中绘制。 默认为NULL)

annotationDat

If MAF file was read without clinical data, provide a custom data.framewith a column containing Tumor_Sample_Barcodes along with rest of columns with annotations. You can specify which columns to be drawn using 'clinicalFeatures' argument.(如果在没有临床数据的情况下读取MAF文件,请提供自定义data.frame,其中包含一个包含Tumor_Sample_Barcodes的列以及带有注释的其余列。 您可以使用'clinicalFeatures'参数指定要绘制的列)

annotationColor

list of colors to use for 'clinicalFeatures'. Must be a named list. Default NULL.

genesToIgnore

do not show these genes in Oncoplot. Default NULL.

showTumorSampleBarcodes

logical to include sample names.(逻辑包含样本名称)

removeNonMutated

Logical. If TRUE removes samples with no mutations in the oncoplot for better visualization. Default TRUE.(消除无义突变)

colors

named vector of colors for each Variant_Classification.

sortByMutation

Force sort matrix according mutations. Helpful in case of MAF was read along with copy number data. Default FALSE.(根据突变强制排序矩阵。 在阅读MAF的情况下有用以及拷贝数数据。 默认为FALSE)

sortByAnnotation

logical sort oncomatrix (samples) by provided 'clinicalFeatures'. Sorts based on first 'clinicalFeatures'. Defaults to FALSE. column-sort

annotationOrder

Manually specify order for annotations. Works only for first 'clinicalFeatures'. Default NULL.

keepGeneOrder

logical whether to keep order of given genes. Default FALSE, order according to mutation frequency

GeneOrderSort

logical this is applicable when 'keepGeneOrder' is TRUE. Default TRUE

sampleOrder

Manually speify sample names for oncolplot ordering. Default NULL.

writeMatrix

writes character coded matrix used to generate the plot to an output file. This can be used as an input for ComplexHeatmap oncoPrint function if you wish to customize the plot.(将用于生成绘图的字符编码矩阵写入输出文件。 如果您想自定义绘图,则可以将其用作ComplexHeatmap oncoPrint函数的输入)

fontSize

font size for gene names. Default 10.

SampleNamefontSize

font size for sample names. Default 10

titleFontSize

font size for title. Default 15

legendFontSize

font size for legend. Default 12

annotationFontSize

font size for annotations. Default 12

annotationTitleFontSize

font size for annotation title. Default 12

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

col = RColorBrewer::brewer.pal(n = 8, name = 'Paired')
names(col) = c('Frame_Shift_Del','Missense_Mutation', 'Nonsense_Mutation', 'Multi_Hit', 'Frame_Shift_Ins','In_Frame_Ins', 'Splice_Site', 'In_Frame_Del')#Color coding for FAB classification; try getAnnotations(x = laml) to see available annotations.
fabcolors = RColorBrewer::brewer.pal(n = 8,name = 'Spectral')
names(fabcolors) = c("M0", "M1", "M2", "M3", "M4", "M5", "M6", "M7")
fabcolors = list(FAB_classification = fabcolors)#MutSig reusults
laml.mutsig <- system.file("extdata", "LAML_sig_genes.txt.gz", package = "maftools")oncoplot(maf = laml, colors = col, mutsig = laml.mutsig, mutsigQval = 0.01, clinicalFeatures = 'FAB_classification', sortByAnnotation = TRUE, annotationColor = fabcolors)

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

#显示特定基因
oncostrip(maf = laml, genes = c('DNMT3A','NPM1', 'RUNX1'))


#绘制箱线图—— titv

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

我做的样本比较少效果没有网页介绍的好

Description

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

Usage

titv(maf, useSyn = FALSE, plot = TRUE, file = NULL)

Arguments

maf

an MAF object generated by read.maf

useSyn

Logical. Whether to include synonymous variants in analysis. Defaults to FALSE.

plot

plots a titv fractions. default TRUE.

file

basename for output file name. If given writes summaries to output file. Default NULL.


#绘制棒棒图——lollipopPlot

棒棒糖图是简单且最有效的方式,显示蛋白质结构上的突变点。许多致癌基因具有比任何其他基因座更频繁突变的优先位点。这些斑点被认为是突变热点,棒棒糖图可以用于显示它们以及其他突变。我们可以使用函数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

R包——maftools可视化神器相关推荐

  1. r包调用legend函数_R语言实现基于朴素贝叶斯构造分类模型数据可视化

    本文内容原创,未经作者许可禁止转载! 目录 一.前言 二.摘要 三.关键词 四.算法原理 五.经典应用 六.R建模 1.载入相关包(内含彩蛋): 1.1 library包载入 1.2 pacman包载 ...

  2. maftools: 可视化maf文件的神器

    欢迎关注"生信修炼手册"! maftools是一个R包,发布在bioconductor上,专门用于MAF文件中信息的可视化,链接如下 https://bioconductor.or ...

  3. R 包 pathview 代谢通路可视化

    pathview R 包是一个集成 pathway 通路数据与可视化的工具集.它用于把用户的数据映射并渲染到相关的 pathway 通路图上,用户只需要提供基因或者化合物数据(gene or comp ...

  4. Microbiome:animalcules-交互式微生物组分析和可视化的R包

    animalcules-交互式微生物组分析和可视化的R包 animalcules: interactive microbiome analytics and visualization in R Mi ...

  5. R语言ggplot2可视化:使用ggfortyify包中的autoplot函数自动可视化时间序列数据(Time Series Plot From a Time Series Object (ts))

    R语言ggplot2可视化:使用ggfortyify包中的autoplot函数自动可视化时间序列数据(Time Series Plot From a Time Series Object (ts)) ...

  6. R语言ggplot2可视化:使用dplyr包计算每个分组个数的比例(对计算获得的百分比进行近似,值保留整数部分)、使用ggplot2可视化条形图(bar plot)、并在条形图上添加百分比标签

    R语言ggplot2可视化:使用dplyr包计算每个分组个数的比例(对计算获得的百分比进行近似,值保留整数部分).使用ggplot2可视化条形图(bar plot).并在条形图上添加百分比标签 目录

  7. R语言ggplot2可视化绘制线图(line plot)、使用gghighlight包突出高亮满足条件的线图、并保留其它线图的色彩(而不是灰色)自定义非高亮线图的透明度

    R语言ggplot2可视化绘制线图(line plot).使用gghighlight包突出高亮满足条件的线图.并保留其它线图的色彩(而不是灰色)自定义非高亮线图的透明度 目录

  8. R语言ggplot2可视化分面直方图(faceting histogram)、使用gghighlight包突出高亮突出每个分面中的一个分组的直方图

    R语言ggplot2可视化分面直方图(faceting histogram).使用gghighlight包突出高亮突出每个分面中的一个分组的直方图(highlight histogram in fac ...

  9. R语言ggplot2可视化绘制多条基本线图(Basic line plot)、使用gghighlight包突出高亮其中的某一条线图(highlight line plot)

    R语言ggplot2可视化绘制多条基本线图(Basic line plot).使用gghighlight包突出高亮其中的某一条线图(highlight line plot) 目录

最新文章

  1. html excel零不显,Excel数值为0不显示的三种解决方法
  2. mysql自动增长id 溢出_MySQL表自增id溢出的故障复盘怎么解决 MySQL表自增id溢出的故障复盘解决方法...
  3. Asp.net動態添加控件(转)
  4. 【转】jmeter响应结果乱码问题
  5. 一个亿的融资在一家芯片初创公司可以烧多久?
  6. JDK8 集合排序 xxxList.stream.sorted(...)
  7. 德国大学:如何改变一个民族和整个世界的命运
  8. ggplot2箱式图两两比较_作图技巧024篇ggplot2在循环中的坑
  9. 序列中最大的数(51Nod-1062)
  10. 7-6 求整数段和 (10 分)
  11. 安全是什么意思_进衡水火车站要转着圈找门!这是什么意思……清扫车路边倒水 既浪费又不安全...
  12. FlowNet到FlowNet2.0:基于卷积神经网络的光流预测算法
  13. Redis主从复制(Master/Slaver)初级
  14. java:comp/env 解释
  15. 百度地图api如何查询周边大学、商场等的个数?可实现翻页
  16. could not delete: [org.jbpm.pvm.internal.model.ExecutionImpl#20007] 使用jbpm流程结束时出现异常
  17. 【Unity人物属性】人物属性大量设置用set,get方法还是public成员
  18. JS 内存泄漏与垃圾回收机制
  19. 倒水问题题解(勿喷)
  20. C#Winform中DataGridView控件根据鼠标左右键获取单元格值或者行列

热门文章

  1. 基于深度学习的视觉应用,我们也可以开发哦!
  2. android出现应用程序未安装的解决办法
  3. Vue项目报错npm ERR code 1
  4. 衡水学院计算机实习,衡水学院教育实习系列报道之三
  5. linux debian iso下载,Debian GNU/Linux 9.8 “Stretch” live和DVD ISO现在可供下载
  6. 数据结构--表达式括号匹配和运算
  7. 去中心化的滴滴打车派单模拟系统前端历程
  8. wps 甘特图_项目进度管理的好方法:甘特图
  9. 圣斗士里隐瞒了非常恐怖的剧情
  10. set,setenv和export