selkamand / ggoncoplot

Easily Create Interactive Oncoplots
https://selkamand.github.io/ggoncoplot/
Other
3 stars 0 forks source link

Percentages of samples with alteration on the y axis of the barplot #79

Closed ConYel closed 2 months ago

ConYel commented 1 year ago

Hello Sam Elkamand, and thank you for this well made package. I would like to ask you if it is possible to add on the gene_barplot a Y axis that shows the percentages of samples that have alterations on that specific gene. Some examples can be found here Thank you for your time!

selkamand commented 1 year ago

Hiya ConYel

Thanks for the suggestion! It is definitely a feature worth adding. I'll look into implementing this!

selkamand commented 2 months ago

Hiya @ConYel. Sorry for the abhorrently long wait time. This feature is now in the ggoncoplot (master branch)

Key features:

1) hover-over tooltips now shows the proportion of samples with the mutation when interactive = TRUE 2) you can add a text label next to each bar of the gene barplot using ggoncoplot_options(show_genebar_labels = TRUE).

There are also a couple of options for customising how the text labels look. Their defaults are shown. See ?ggoncoplot_options for details

genebar_label_padding = 0.3
genebar_only_pad_when_labels_shown = TRUE
genebar_label_nudge = 2
genebar_label_round = 0

Heres an example in the manual with gene barplot labels shown:

Notes on how total number of samples is calculated There are multiole approaches that can be used to calculate the total number of samples. See the documentation of the total_samples argument of ggoncoplot for details. By default we count the total number of samples present in the mutation data.frame you pass to the .data argument of ggoncoplot. If you want to also include samples with only metadata (even if they have no mutations in any genes at all) in your count of 'total samples' set total_samples = 'all'. Alternatively if you prefer to just calculate gene recurrence based ONLY off samples present in the final oncoplot set `total_samples = 'oncoplot'

selkamand commented 2 months ago

Minimal reproducible example:

library(ggoncoplot)

gbm_csv <- system.file(package='ggoncoplot', "testdata/GBM_tcgamutations_mc3_maf.csv.gz")
gbm_df <- read.csv(file = gbm_csv, header=TRUE)

gbm_df |> 
  ggoncoplot(
    col_genes = 'Hugo_Symbol', 
    col_samples = 'Tumor_Sample_Barcode', 
    col_mutation_type = 'Variant_Classification', 
    topn = 10, 
    draw_gene_barplot = TRUE, 
    draw_tmb_barplot = TRUE,
    interactive = FALSE,
    options = ggoncoplot_options(
      show_genebar_labels = TRUE
    )
  )
#> 
#> ── Identify Class ──
#> 
#> ℹ Found 7 unique mutation types in input set
#> ℹ 0/7 mutation types were valid PAVE terms
#> ℹ 0/7 mutation types were valid SO terms
#> ℹ 7/7 mutation types were valid MAF terms
#> ✔ Mutation Types are described using valid MAF terms ... using MAF palete
#> ! TMB plot: Ignoring `col_mutation_type` since `log10_transform = TRUE`.
#> This is because you cannot accurately plot stacked bars on a logarithmic scale

Created on 2024-06-17 with reprex v2.1.0

ConYel commented 2 months ago

This is great! Thank you very much for implementing this!