This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Making a legoplot of mutational signatures

Hi

Here doing 3D plot

https://cran.r-project.org/web/packages/barplot3d/vignettes/barplot3d.html

But I don't know from where I can provide the input as every deconvolution tools to get 3 nucleotides context returns some thing different than the example input here

enter image description here

I want to plot something like this

r

What data are you trying to make this from? You should try to include some of that data in the post.

A 96 base substitution 3D bar plot

1 answer

## Prepare your own data
library(maftools)
laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
laml <- read.maf(maf = laml.maf)
laml.tnm <- trinucleotideMatrix(maf = laml, ref_genome = 'BSgenome.Hsapiens.UCSC.hg19',
                                prefix = 'chr', add = TRUE, useSyn = TRUE)

## Check the example data
library(barplot3d)
x=system.file("extdata", "signature_probabilities.txt", package = "barplot3d")
sigdata=read.table(x,header=TRUE,stringsAsFactors = FALSE)

## Make the order correct
ods = paste0(sigdata$Preceeding_base, "[",
             substr(sigdata$Substitution_type, 1, 3),
             "]", sigdata$Succeeding_base)

all(colnames(laml.tnm$nmf_matrix) %in% ods)

## Visualization
# For all samples
all_counts = rowSums(t(laml.tnm$nmf_matrix)[ods, ])
legoplot3d(contextdata=all_counts/sum(all_counts),
           labels=TRUE,scalexy=20,sixcolors="sanger",
           alpha=0.4,zsub="Probability")

Log in to answer this question.