morinlab / GAMBLR.viz

Collection of functions to make plots for Genomic Analysis of Mature B-cell Lymphomas in R
https://morinlab.github.io/GAMBLR.viz/
MIT License
0 stars 0 forks source link

handling of custom colors for numeric annotations #62

Open Kdreval opened 2 weeks ago

Kdreval commented 2 weeks ago

Any idea why prettyOncoplot can't handle custom colours for continuous annotations? I have a continuous column range(patient_metadata$`T1 % Exclusive`) [1] 0 100 My col_fun is col_fun <- colorRamp2(c(0, 50, 100), c("blue", "white", "red")) My function is this:


        maf_list[[mut_cat]],
        these_samples_metadata = with(
            patient_metadata,
            patient_metadata[order(Tumor_Sample_Barcode), ]
        ),
        metadataColumns = "Treatment Group",
        numericMetadataColumns = c(
            "T1 % Exclusive"
        ),
        keepSampleOrder = TRUE,
        sortByColumns = "T1 % Exclusive",
        highlightHotspots = TRUE,
        genes = plotgenes,
        keepGeneOrder = TRUE,
        splitColumnName = "Treatment Group",
        removeNonMutated = FALSE,
        custom_colours = list(
            "T1 % Exclusive" = col_fun
        ),
        hideTopBarplot = FALSE,
        tally_all_mutations = TRUE,
        legendFontSize = 10,
        fontSizeGene = 10,
        metadataBarFontsize = 12,
        metadataBarHeight = 3
    )```
Error message:
```Error: elements in `col` should be named vectors.```
If I don't provide a custom colour for this continuous annotation track, or if I only provide a custom colour for the categorical annotation track, it works fine. I'm using GAMBLR.viz@d7c6c72

[Slack Message](https://morinlabsfu.slack.com/archives/C0224H120CU/p1718732720065849?thread_ts=1718732720.065849&cid=C0224H120CU)
Kdreval commented 2 weeks ago

rep example:

library(GAMBLR)
library(tidyverse)

meta <- GAMBLR.data::get_gambl_metadata() %>%
    filter(cohort == "BL_Thomas")

meta <- meta %>%
    mutate(
        numeric_column = sample(1:100, nrow(meta), replace = TRUE),
        `Treatmen Group` = sample(c("Treated", "Untreated"), nrow(meta), replace = TRUE)
    )

maf <- GAMBLR.data::get_coding_ssm(
    these_samples_metadata = meta,
    projection = "grch37"
)

maf <- GAMBLR.data::annotate_hotspots(maf)

genes <- c("MYC", "TP53", "DDX3X", "FOXO1", "EZH2", "CREBBP", "BCL2")

col_fun <- circlize::colorRamp2(c(0, 50, 100), c("blue", "white", "red"))

prettyOncoplot(
        maf,
        these_samples_metadata = with(
            meta,
            meta[order(Tumor_Sample_Barcode), ]
        ),
        metadataColumns = "Treatmen Group",
        numericMetadataColumns = c(
            "numeric_column"
        ),
        keepSampleOrder = TRUE,
        sortByColumns = "numeric_column",
        highlightHotspots = TRUE,
        genes = genes,
        keepGeneOrder = TRUE,
        removeNonMutated = FALSE,
        custom_colours = list(
            "Treatment Group" = c("Treated" = "#56af92", "Untreated" = "#35a3da"),
            "numeric_column" = col_fun
        ),
        hideTopBarplot = FALSE,
        tally_all_mutations = TRUE,
        legendFontSize = 10,
        fontSizeGene = 10,
        metadataBarFontsize = 12,
        metadataBarHeight = 3
    )