This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to convert maf file format to oncoPrint matrix (ComplexHeatmap package)?

I have maf files and I'd like to create a oncoPrint matrix with my own data according to https://jokergoo.github.io/ComplexHeatmap-reference/book/oncoprint.html. However, the input format for oncoPrint is:

##    s1          s2          s3         
## g1 "snv;indel" "snv"       "indel"    
## g2 ""          "snv;indel" "snv"      
## g3 "snv"       ""          "indel;snv"

The maf file format is:

##Hugo_Symbol   Variant_Classification  Tumor_Sample_Barcode
##g1    Missense_Mutation   s1
##g1    Splice_Site s1
##g2    Missense_Mutation   s1
##g2    Missense_Mutation   s2
##g2    Frame_Shift_Ins s2
##g3    Missense_Mutation   s3

Is there a tool to convert maf to the oncoPrint format?

Many thanks!

r oncoprint complexheatmap

Thanks for this - I actually did it - it worked nicely in maftools. However, MAFTOOLS is not able to show genes with more than one variant type (multihit) as half (or proportion) of each variant in the cell (see https://github.com/PoisonAlien/maftools/issues/246). I need a more detailed plot using ComplexHeatmap or other package to show different variants in the same cell. Any recommentation?

Hi there,

Actually I used the [maftools] package. I loaded my maf file using 'read.maf' function and then used the 'oncoplot' function to plot - you can create a OncoPrint matrix by including the 'writeMatrix = TRUE' argument.

Hope it helps!

Thanks for sharing. However, I already did that. Following is the outline of the code

colnames(data2) <- c("Samples","Gene","Impact")
### remove duplicate rows
data <-data[!duplicated(data[,]),]
for(i in 1:nrow(data)) {

  for(j in 1:nrow(data)) {

      if(identical(data[i,1], data[j,1]) && identical(data[i,2], data[j,2]) && data[i,3] != data[j,3]){

    data[i,3] <- paste0(data[i,3],";",data[j,3])
    data<- data[-j,]

  }}}

Hi Dear,

Were you able to do that? I wanted to convert my MAF file in Matrix format for Oncoprint as well.

Thanks Najeeb

1 answer

Have you tried using maftools?

It is a very handy package if you are working with MAF files. It summarizes, analyzes, annotates and visualizes MAF files in a quite nice way. Among many functions, you can plot your oncoprint there as well.

I hope it helps. Good luck!

Log in to answer this question.