uclahs-cds / package-CancerEvolutionVisualization

Publication Quality Phylogenetic Tree Plots
https://cran.r-project.org/web/packages/CancerEvolutionVisualization/
GNU General Public License v2.0
2 stars 0 forks source link

CCF Heatmap #61

Closed whelena closed 1 year ago

whelena commented 1 year ago

Dataframe Input

Mutation-to-clone Data

Must at least contain the following columns

snv.id CCF clone.id ID
unique snv ID (usually chr:start.pos_ref/alt) SNV clone assignment Tumour sample ID

Heatmap input

SNV 1 SNV 2 ... SNV n
Sample 1 CCF(1, 1) CCF(1, 2) ... CCF(1, n)
Sample 2 CCF(2, 1) CCF(2, 2) ... CCF(2, n)
...
Sample n CCF(n, 1) CCF(n, 2) ... CCF(n, n)

Plot Output

CCF values for clustered data

(rows = sample, columns = SNV) MSK-AB-0005_clustered-hm

hm <- create.heatmap(
        filename = NULL,
        x = heatmap.array,
        force.clustering = TRUE,
        cluster.dimensions = cls.dim,
        clustering.method = cls.method,
        rows.distance.method = dist.method,
        cols.distance.method = dist.method,
        xaxis.lab = xaxis.lab,
        xlab.label = xlab.label,
        xlab.cex = 1,
        xaxis.cex = 0.6,
        xaxis.fontface = 1,
        xaxis.rot = 90,
        yaxis.lab = colnames(hm.array),
        ylab.cex = 1,
        yaxis.cex = 0.6,
        yaxis.fontface = 1,
        colourkey.cex = 0.6,
        colour.scheme = col.scheme,
        left.padding = 1,
        right.padding = 1,
        resolution = 3000,
        width = 9,
        height = 5,
        colourkey.labels.at = col.labels
        );

cov <- create.heatmap(
        x = t(cls.colours[snv.order$clone.id]),
        input.colours = TRUE,
        clustering.method = 'none',
        grid.col = FALSE,
        print.colour.key = FALSE,
        resolution = 5000
        );

legend.clone <- legend.grob(
        list(
            legend = list(
                title = 'Clones',
                labels = names(cls.colours),
                colours = cls.colours,
                border = 'black'
                ),
            legend = list(
                title = 'CCF',
                labels = c(min(arr), max(arr)),
                colours = if (is.null(hm.cols)) { c('white', 'blue') } else { hm.cols },
                border = 'black',
                continuous = TRUE,
                size = 0.6
                )
            ),
        size = 1,
        title.cex = 0.75,
        label.cex = 0.6
        );

create.multiplot(
        filename = file.path(
            save.path,
            generate.filename(
                project.stem = p,
                file.core = fname,
                extension = 'png',
                file.date = FALSE
                )
            ),
        plot.objects = list(cov, hm),
        plot.layout = c(1, 2),
        panel.heights = c(1, 0.05),
        xaxis.lab = if (!is.null(xaxis.col)) { xaxis.label} else { NULL },
        xaxis.cex = 0.6,
        xaxis.rot = 90,
        xaxis.fontface = 1,
        xaxis.tck = 0,
        #plot.labels.to.retrieve = 2,
        yaxis.lab = list(NULL, colnames(arr)),
        yaxis.cex = 0.6,
        yaxis.tck = 0,
        yaxis.fontface = 1,
        y.spacing = 0.5,
        left.padding = 17,
        print.new.legend = TRUE,
        legend = list(right = list(
            fun = legend.clone
        )),
        height = plt.height,
        width = plt.width
        );

Median CCF values with SNV barplots

(rows = sample, columns = clones)

add functionality for stacked barplot for marked (usually driver) SNVs ![MSK-AB-0005_median-ccf-hm](https://user-images.githubusercontent.com/51138179/197296437-2ac1a102-8a5d-4925-92ce-154618523d11.png)