Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rightbardata retrieval and used to as leftBrData #1078

Open
wangzunq opened this issue Dec 16, 2024 · 4 comments
Open

Rightbardata retrieval and used to as leftBrData #1078

wangzunq opened this issue Dec 16, 2024 · 4 comments

Comments

@wangzunq
Copy link

Describe the issue
I see the default rightbar is a summary count bar plot for each gene(rowSum). What I want is the same bar plot to be plotted in the left instead. Where and how to retrieve the default rightBarData so that I can used to act as leftBarData to plot left bar instead. In addition, how to access the “% mutation” that besides right bar for each row as well as the gene names as I want to switch the orientation (left is bar plot with % mutation, right is gene names). I see early version of maftools was in this manner, now it is the opposite orientation. Any help is appreciated! Thank you

@PoisonAlien
Copy link
Owner

Hi,

Some of these are hard-coded and can not be changed. This is the closest you can do to switch the bar plots from right to left. Note that you won't be able to color code the data on the left bar.
Hope this helps to a certain extent.

library(maftools)
laml.maf = system.file("extdata", "tcga_laml.maf.gz", package = "maftools") #MAF file
laml.clin = system.file('extdata', 'tcga_laml_annot.tsv', package = 'maftools') #clinical data
laml = read.maf(maf = laml.maf, clinicalData = laml.clin)

genes2plot = c("FLT3", "DNMT3A", "NPM1", "IDH2", "IDH1", "TET2", "RUNX1", 
"TP53", "NRAS", "CEBPA")

n_samples = laml@summary[ID %in% "Samples", summary] |> as.numeric()

mut_freq = maftools::getGeneSummary(laml)[Hugo_Symbol %in% genes2plot, .(Hugo_Symbol, AlteredSamples)]
mut_freq[, pct := (AlteredSamples / n_samples)*100]
data.table::setDF(x = mut_freq, mut_freq$Hugo_Symbol)

> mut_freq
       Hugo_Symbol AlteredSamples       pct
FLT3          FLT3             52 26.943005
DNMT3A      DNMT3A             48 24.870466
NPM1          NPM1             33 17.098446
IDH2          IDH2             20 10.362694
IDH1          IDH1             18  9.326425
TET2          TET2             17  8.808290
RUNX1        RUNX1             16  8.290155
TP53          TP53             15  7.772021
NRAS          NRAS             15  7.772021
CEBPA        CEBPA             13  6.735751


maftools::oncoplot(
  maf = laml,
  genes = genes2plot,
  leftBarData = mut_freq,
  drawRowBar = FALSE,
  leftBarLims = c(0, max(mut_freq$AlteredSamples)),
  gene_mar = 1
)

image

@wangzunq
Copy link
Author

wangzunq commented Dec 17, 2024 via email

@PoisonAlien
Copy link
Owner

Hi,

Yes, it should be fine. Save the plots as vector graphics (pdf, svg) so you can edit them in Illustrator or Affinity Designer.

@wangzunq
Copy link
Author

wangzunq commented Dec 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants