2020-06-01 学习maftools : 可视化分析SNV(三)

Customizing oncoplots

clp

6/1/2020

加载包

library(maftools)

读入数据

#path to TCGA LAML MAF file
laml.maf = system.file('extdata', 'tcga_laml.maf.gz', package = 'maftools')
#clinical information containing survival information and histology. This is optional
laml.clin = system.file('extdata', 'tcga_laml_annot.tsv', package = 'maftools')

laml = read.maf(maf = laml.maf,
                clinicalData = laml.clin,
                verbose = FALSE)

0.1 Including Transition/Transversions into oncoplot

可视化前20个突变基因瀑布图

#By default the function plots top20 mutated genes
oncoplot(maf = laml, draw_titv = TRUE)
image.png

0.2 Changing colors for variant classifications

美化图表

#One can use any colors, here in this example color palette from RColorBrewer package is used
vc_cols = RColorBrewer::brewer.pal(n = 8, name = 'Paired')
names(vc_cols) = c(
  'Frame_Shift_Del',
  'Missense_Mutation',
  'Nonsense_Mutation',
  'Multi_Hit',
  'Frame_Shift_Ins',
  'In_Frame_Ins',
  'Splice_Site',
  'In_Frame_Del'
)
print(vc_cols)
#>   Frame_Shift_Del Missense_Mutation Nonsense_Mutation         Multi_Hit 
#>         "#A6CEE3"         "#1F78B4"         "#B2DF8A"         "#33A02C" 
#>   Frame_Shift_Ins      In_Frame_Ins       Splice_Site      In_Frame_Del 
#>         "#FB9A99"         "#E31A1C"         "#FDBF6F"         "#FF7F00"

oncoplot(maf = laml, colors = vc_cols, top = 10)
image.png

0.3 Including copy number data into oncoplots.

There are two ways one include CN status into MAF. 1. GISTIC results 2. Custom copy number table

0.3.1 GISTIC results

Most widely used tool for copy number analysis from large scale studies is GISTIC and we can simultaneously read gistic results along with MAF. GISTIC generates numerous files but we need mainly four files all_lesions.conf_XX.txt, amp_genes.conf_XX.txt, del_genes.conf_XX.txt, scores.gistic where XX is confidence level. These files contain significantly altered genomic regions along with amplified and deleted genes respectively.

#GISTIC results LAML
all.lesions =
  system.file("extdata", "all_lesions.conf_99.txt", package = "maftools")
amp.genes =
  system.file("extdata", "amp_genes.conf_99.txt", package = "maftools")
del.genes =
  system.file("extdata", "del_genes.conf_99.txt", package = "maftools")
scores.gis =
  system.file("extdata", "scores.gistic", package = "maftools")
#Read GISTIC results along with MAF
laml.plus.gistic = read.maf(
  maf = laml.maf,
  gisticAllLesionsFile = all.lesions,
  gisticAmpGenesFile = amp.genes,
  gisticDelGenesFile = del.genes,
  gisticScoresFile = scores.gis,
  isTCGA = TRUE,
  verbose = FALSE, 
  clinicalData = laml.clin
)
oncoplot(maf = laml.plus.gistic, top = 10)
image.png

This plot shows frequent deletions in TP53 gene which is located on one of the significantly deleted locus 17p13.2.

0.3.2 Custom copy-number table

In case there is no GISTIC results available, one can generate a table containing CN status for known genes in known samples. This can be easily created and read along with MAF file.

For example lets create a dummy CN alterations for DNMT3A in random 20 samples.

set.seed(seed = 1024)
barcodes = as.character(getSampleSummary(x = laml)[,Tumor_Sample_Barcode])
#Random 20 samples
dummy.samples = sample(x = barcodes,
                       size = 20,
                       replace = FALSE)

#Genarate random CN status for above samples
cn.status = sample(
  x = c('Amp', 'Del'),
  size = length(dummy.samples),
  replace = TRUE
)

custom.cn.data = data.frame(
  Gene = "DNMT3A",
  Sample_name = dummy.samples,
  CN = cn.status,
  stringsAsFactors = FALSE
)

head(custom.cn.data)
#>     Gene  Sample_name  CN
#> 1 DNMT3A TCGA-AB-2898 Amp
#> 2 DNMT3A TCGA-AB-2879 Amp
#> 3 DNMT3A TCGA-AB-2920 Del
#> 4 DNMT3A TCGA-AB-2866 Amp
#> 5 DNMT3A TCGA-AB-2892 Amp
#> 6 DNMT3A TCGA-AB-2863 Amp

laml.plus.cn = read.maf(maf = laml.maf,
                        cnTable = custom.cn.data,
                        verbose = FALSE)

oncoplot(maf = laml.plus.cn, top = 5)
image.png

0.4 Bar plots

leftBarData, rightBarData and topBarData arguments can be used to display additional values as barplots. Below example demonstrates adding gene expression values and mutsig q-values as left and right side bars respectivelly.

#Selected AML driver genes
aml_genes = c("TP53", "WT1", "PHF6", "DNMT3A", "DNMT3B", "TET1", "TET2", "IDH1", "IDH2", "FLT3", "KIT", "KRAS", "NRAS", "RUNX1", "CEBPA", "ASXL1", "EZH2", "KDM6A")

#Variant allele frequcnies (Right bar plot)
aml_genes_vaf = subsetMaf(maf = laml, genes = aml_genes, fields = "i_TumorVAF_WU", mafObj = FALSE)[,mean(i_TumorVAF_WU, na.rm = TRUE), Hugo_Symbol]
colnames(aml_genes_vaf)[2] = "VAF"
head(aml_genes_vaf)
#>    Hugo_Symbol      VAF
#> 1:       ASXL1 37.11250
#> 2:       CEBPA 22.00235
#> 3:      DNMT3A 43.51556
#> 4:      DNMT3B 37.14000
#> 5:        EZH2 68.88500
#> 6:        FLT3 34.60294

#MutSig results (Right bar plot)
laml.mutsig = system.file("extdata", "LAML_sig_genes.txt.gz", package = "maftools")
laml.mutsig = data.table::fread(input = laml.mutsig)[,.(gene, q)]
laml.mutsig[,q := -log10(q)] #transoform to log10
head(laml.mutsig)
#>      gene        q
#> 1:   FLT3 12.64176
#> 2: DNMT3A 12.64176
#> 3:   NPM1 12.64176
#> 4:   IDH2 12.64176
#> 5:   IDH1 12.64176
#> 6:   TET2 12.64176

# oncoplot(
#   maf = laml,
#   genes = aml_genes,
#   leftBarData = aml_genes_vaf,
#   leftBarLims = c(0, 100),
#   rightBarData = laml.mutsig,
#   rightBarLims = c(0, 20)
# )

由于频繁出现报错不存在参数leftBarData,查看了帮助文档,确实没有这个参数,比较符合的应该是mutsig = NULL ,还未探索到正确的展示方法。先注释出图函数,需要进一步研究。理论上出图效果为:

image.png

0.5 Including annotations

Annotations are stored in clinical.data slot of MAF.

getClinicalData(x = laml)
#>      Tumor_Sample_Barcode FAB_classification days_to_last_followup
#>   1:         TCGA-AB-2802                 M4                   365
#>   2:         TCGA-AB-2803                 M3                   792
#>   3:         TCGA-AB-2804                 M3                  2557
#>   4:         TCGA-AB-2805                 M0                   577
#>   5:         TCGA-AB-2806                 M1                   945
#>  ---                                                              
#> 189:         TCGA-AB-3007                 M3                  1581
#> 190:         TCGA-AB-3008                 M1                   822
#> 191:         TCGA-AB-3009                 M4                   577
#> 192:         TCGA-AB-3011                 M1                  1885
#> 193:         TCGA-AB-3012                 M3                  1887
#>      Overall_Survival_Status
#>   1:                       1
#>   2:                       1
#>   3:                       0
#>   4:                       1
#>   5:                       1
#>  ---                        
#> 189:                       0
#> 190:                       1
#> 191:                       1
#> 192:                       0
#> 193:                       0

Include FAB_classification from clinical data as one of the sample annotations.

oncoplot(maf = laml, genes = aml_genes, clinicalFeatures = 'FAB_classification')
image.png

More than one annotations can be included by passing them to the argument clinicalFeatures. Above plot can be further enhanced by sorting according to annotations. Custom colors can be specified as a list of named vectors for each levels.

#Color coding for FAB classification
fabcolors = RColorBrewer::brewer.pal(n = 8,name = 'Spectral')
names(fabcolors) = c("M0", "M1", "M2", "M3", "M4", "M5", "M6", "M7")
fabcolors = list(FAB_classification = fabcolors)

print(fabcolors)
#> $FAB_classification
#>        M0        M1        M2        M3        M4        M5        M6 
#> "#D53E4F" "#F46D43" "#FDAE61" "#FEE08B" "#E6F598" "#ABDDA4" "#66C2A5" 
#>        M7 
#> "#3288BD"

oncoplot(
  maf = laml, genes = aml_genes,
  clinicalFeatures = 'FAB_classification',
  sortByAnnotation = TRUE,
  annotationColor = fabcolors
)
image.png

0.6 Highlighting samples

If you prefer to highlight mutations by a specific attribute, you can use additionalFeature argument.

Example: Highlight all mutations where alt allele is C.

oncoplot(maf = laml, genes = aml_genes,
         additionalFeature = c("Tumor_Seq_Allele2", "C"))
image.png

Note that first argument (Tumor_Seq_Allele2) must a be column in MAF file, and second argument (C) is a value in that column. If you want to know what columns are present in the MAF file, use getFields.

getFields(x = laml)
#>  [1] "Hugo_Symbol"            "Entrez_Gene_Id"        
#>  [3] "Center"                 "NCBI_Build"            
#>  [5] "Chromosome"             "Start_Position"        
#>  [7] "End_Position"           "Strand"                
#>  [9] "Variant_Classification" "Variant_Type"          
#> [11] "Reference_Allele"       "Tumor_Seq_Allele1"     
#> [13] "Tumor_Seq_Allele2"      "Tumor_Sample_Barcode"  
#> [15] "Protein_Change"         "i_TumorVAF_WU"         
#> [17] "i_transcript_name"

0.7 Group by Pathways

Genes can be auto grouped based on their Biological processess by setting pathways = 'auto'or by providing custom pathway list in the form of a two column tsv file or a data.frame containing gene names and their corresponding pathway.

0.7.1 Auto

setting pathways = 'auto' draws top 3 most affected pathways

# oncoplot(maf = laml, pathways = "auto", gene_mar = 8, fontSize = 0.6)

原教程中这个pathways = "auto"出现报错,不存在该参数。只找到参数colbar_pathway = FALSE

0.7.2 Custom pathways

oncoplot(maf = laml, gene_mar = 8, fontSize = 0.6)
image.png
pathways = data.frame(
  Genes = c(
    "TP53",
    "WT1",
    "PHF6",
    "DNMT3A",
    "DNMT3B",
    "TET1",
    "TET2",
    "IDH1",
    "IDH2",
    "FLT3",
    "KIT",
    "KRAS",
    "NRAS",
    "RUNX1",
    "CEBPA",
    "ASXL1",
    "EZH2",
    "KDM6A"
  ),
  Pathway = rep(c(
    "TSG", "DNAm", "Signalling", "TFs", "ChromMod"
  ), c(3, 6, 4, 2, 3)),
  stringsAsFactors = FALSE
)

head(pathways)
#>    Genes Pathway
#> 1   TP53     TSG
#> 2    WT1     TSG
#> 3   PHF6     TSG
#> 4 DNMT3A    DNAm
#> 5 DNMT3B    DNAm
#> 6   TET1    DNAm

oncoplot(maf = laml, colbar_pathway = T, gene_mar = 8, fontSize = 0.6)
image.png

然而更改参数colbar_pathway = T并未能达到原来的效果,需要进一步学习。

0.8 Combining everything

# oncoplot(
#   maf = laml.plus.gistic,
#   draw_titv = TRUE,
#   pathways = pathways,
#   clinicalFeatures = c('FAB_classification', 'Overall_Survival_Status'),
#   sortByAnnotation = TRUE,
#   additionalFeature = c("Tumor_Seq_Allele2", "C"),
#   leftBarData = aml_genes_vaf,
#   leftBarLims = c(0, 100),
#   rightBarData = laml.mutsig[,.(gene, q)],
# )

汇总所有注释信息绘图结果应该如下图所示,但是由于leftBarDatarightBarData,pathways三个参数可能被更新了,暂时还没能解决。

image.png

0.9 SessionInfo

sessionInfo()
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-apple-darwin15.6.0 (64-bit)
#> Running under: macOS High Sierra 10.13.6
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] maftools_2.2.10
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_1.0.3         lattice_0.20-38    digest_0.6.23     
#>  [4] R.methodsS3_1.7.1  grid_3.6.1         magrittr_1.5      
#>  [7] evaluate_0.14      rlang_0.4.5        stringi_1.4.3     
#> [10] data.table_1.12.6  R.oo_1.23.0        R.utils_2.9.0     
#> [13] Matrix_1.2-17      wordcloud_2.6      rmarkdown_2.1     
#> [16] splines_3.6.1      RColorBrewer_1.1-2 tools_3.6.1       
#> [19] stringr_1.4.0      xfun_0.10          yaml_2.2.0        
#> [22] survival_2.44-1.1  compiler_3.6.1     htmltools_0.4.0   
#> [25] knitr_1.25

参考学习资料:http://www.bioconductor.org/packages/release/bioc/vignettes/maftools/inst/doc/oncoplots.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,711评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,932评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,770评论 0 330
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,799评论 1 271
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,697评论 5 359
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,069评论 1 276
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,535评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,200评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,353评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,290评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,331评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,020评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,610评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,694评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,927评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,330评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,904评论 2 341