Package 'CancerEvolutionVisualization'

Title: Publication Quality Phylogenetic Tree Plots
Description: Generates tree plots with precise branch lengths, gene annotations, and cellular prevalence. The package handles complex tree structures (angles, lengths, etc.) and can be further refined as needed by the user.
Authors: Paul Boutros [cre], Adriana Salcedo [aut], Dan Knight [aut], Helena Winata [aut], Selina Wu [ctb]
Maintainer: Paul Boutros <[email protected]>
License: GPL-2
Version: 3.0.0
Built: 2024-11-20 19:24:23 UTC
Source: https://github.com/uclahs-cds/package-cancerevolutionvisualization

Help Index


Colour scheme vector

Description

Default colours used by CP polygons, etc.

Format

Character vector


CCF Distribution Heatmap

Description

Creates a heatmap of cancer cell fraction (CCF) distribution across tumour samples. The function is a wrapper around BoutrosLab.plotting.general::create.heatmap() with some changes in the default parameters. All parameter description are the same as in BoutrosLab.plotting.general::create.heatmap() except for ccf.thres.

Usage

create.ccf.heatmap(
    x,
    cluster.dimensions = 'both',
    clustering.method = 'complete',
    distance.method = 'euclidean',
    xaxis.lab = '',
    xlab.label = 'SNVs',
    print.colour.key = FALSE,
    colour.scheme = c('white', 'blue'),
    ...
    )

Arguments

x

Either a data-frame or a matrix from which the heatmap is to created

cluster.dimensions

Defaults to “both”.

clustering.method

Defaults to “complete”.

distance.method

Defaults to “euclidean”.

xaxis.lab

Defaults to an empty string.

xlab.label

Defaults to “SNVs”.

print.colour.key

Defaults to FALSE.

colour.scheme

Defaults to c('white', 'blue').

...

Pass through argument. See BoutrosLab.plotting.general::create.heatmap() for further details.

Value

A 'grob' object of the heatmap.

Author(s)

Helena Winata

See Also

create.heatmap


CCF Summary Heatmap

Description

Creates a heatmap of cancer cell fraction (CCF) distribution across tumour samples with clone IDs as a covariate beneath the heatmap. Subplot parameters controls the appearance of the heatmap and barplots. See BoutrosLab.plotting.general::create.barplot() or BoutrosLab.plotting.general::create.heatmap() for parameter description. Legend parameters are passed to BoutrosLab.plotting.general::legend.grob().

Usage

create.ccf.summary.heatmap(
    DF,
    ccf.limits = NULL,
    median.col = 'median.ccf.per.sample',
    clone.order = NULL,
    sample.order = NULL,
    hm.col.scheme = c('white', 'blue'),
    clone.colours = NULL,
    subplot.xlab.cex = 1.2,
    subplot.xaxis.cex = 1,
    subplot.xaxis.fontface = 'bold',
    subplot.xaxis.rot = 90,
    subplot.ylab.cex = 1.2,
    subplot.yaxis.cex = 1,
    subplot.yaxis.fontface = 'bold',
    hm.xaxis.rot = 90,
    legend.size = 3,
    legend.title.cex = 1.2,
    legend.label.cex = 1,
    legend.x = 0.9,
    legend.y = 0.8,
    plot.objects.heights = c(0.3, 1),
    add.median.text = FALSE,
    ...
    );

Arguments

DF

A data-frame with the following column names: 'ID', 'SNV.id', 'clone.id', 'CCF'.

ccf.limits

CCF limits to be applied to the heatmap. Must be a vector of length 2 for min and max thresholds. Defaults to NULL

median.col

Defaults to “median.ccf.per.sample”

clone.order

Defaults to NULL

sample.order

Defaults to NULL

hm.col.scheme

Heatmap colour scheme. Defaults to c('white', 'blue')

clone.colours

A named vector specifying the color to use for each clone to generate a covariate heatmap. If NULL, no covariates will be added.

subplot.xlab.cex

Subplot parameter. Defaults to 1.2

subplot.xaxis.cex

Subplot parameter. Defaults to 1

subplot.xaxis.fontface

Subplot parameter. Defaults to “bold”

subplot.xaxis.rot

Subplot parameter. Defaults to 90

subplot.ylab.cex

Subplot parameter. Defaults to 1.2

subplot.yaxis.cex

Subplot parameter. Defaults to 1

subplot.yaxis.fontface

Subplot parameter. Defaults to “bold”

hm.xaxis.rot

Subplot parameter. Defaults to 90

legend.size

Legend parameter. Defaults to 3

legend.title.cex

Legend parameter. Defaults to 1.2

legend.label.cex

Legend parameter. Defaults to 1

legend.x

Legend parameter. Defaults to 0.9

legend.y

Legend parameter. Defaults to 0.8

plot.objects.heights

If clone.colours is specified, this must be an array of length 3. Defaults to c(0.3, 1). See BoutrosLab.plotting.general::create.multipanelplot()

add.median.text

If TRUE, median CCF values will be added to the heatmap. Defaults to FALSE

...

Pass through argument. See BoutrosLab.plotting.general::create.multipanelplot() for further details.

Value

A 'grob' object of the summary plot.

Author(s)

Helena Winata

See Also

legend.grob, create.multipanelplot, create.heatmap


Create Clone Genome Distribution Plot

Description

This function creates a plot showing the distribution of clones across the genome. It generates a scatter plot of the SNVs colored by clone ID and a density plot showing the density of each clone across the genome. The function can handle both single and multi-sample inputs.

Usage

create.clone.genome.distribution.plot(
    snv.df,
    genome.build = 'GRCh37',
    clone.order = NULL,
    clone.colours = NULL,
    filename = NULL,
    multi.sample = FALSE,
    alpha = 0.25,
    legend.x = 0.1,
    legend.y = 0.55,
    ...
    )

Arguments

snv.df

A data frame containing the SNV data. It must have columns 'chr', 'pos', and 'clone.id'. If multi.sample = TRUE, it must also have a column 'ID' specifying the sample ID for each SNV.

genome.build

The genome build to use. Defaults to “GRCh37”.

clone.order

The order in which to plot the clones. If NULL, clones will be sorted alphabetically.

clone.colours

A named vector specifying the color to use for each clone. If NULL, colors will be automatically assigned.

filename

Directory or filepath to save the plot in. If multi.sample = TRUE, this must be a directory. if multi.sample = FALSE, this must be a filepath. If NULL, the plot will not be saved.

multi.sample

Logical indicating whether the input data contains multiple samples. Defaults to FALSE.

alpha

Transparency level of the points in the scatter plot. Defaults to 0.25.

legend.x

Legend parameter. Defaults to 0.1

legend.y

Legend parameter. Defaults to 0.55

...

Additional arguments to be passed to BoutrosLab.plotting.general::create.multipanelplot().

Details

This function preprocesses the input data frame, extracts chromosome information, and iterates over each sample to create a clone genome distribution plot. For each sample, it calculates the density of each clone across the genome and creates a scatter plot of the SNVs colored by clone ID and a density plot showing the density of each clone.

Value

A 'grob' object.

Author(s)

Helena Winata, Selina Wu

See Also

legend.grob, create.multipanelplot, create.scatterplot, create.densityplot


Cluster Heatmap

Description

Creates a heatmap of cancer cell fraction (CCF) distribution across tumour samples with clone IDs as a covariate beneath the heatmap.

Usage

create.cluster.heatmap(
    DF,
    ccf.limits = NULL,
    clone.colours = NULL,
    height = 6,
    width = 11,
    xaxis.col = NULL,
    legend.size = 3,
    legend.title.cex = 1.2,
    legend.label.cex = 1,
    filename = NULL,
    xlab.label = 'SNVs',
    xlab.cex = 1.2,
    xaxis.cex = 1,
    xaxis.fontface = 'bold',
    y.spacing = 1,
    colour.scheme = c('white', 'blue'),
    ...
    );

Arguments

DF

A data-frame with the following column names: 'ID', 'SNV.id', 'clone.id', 'CCF'.

ccf.limits

CCF limits to be applied to the heatmap. Must be a vector of length 2 for min and max thresholds. Defaults to NULL

clone.colours

Named list to provide a colour scheme for the clone ID covariate bar. If NULL, colours will be randomly generated. Defaults to NULL.

height

Defaults to 6

width

Defaults to 11

xaxis.col

Column in DF to extract x-axis labels from. Defaults to NULL.

legend.size

Width of the legend boxes in 'character' units. Defaults to 3

legend.title.cex

Size of titles in the legends. Defaults to 1.2

legend.label.cex

Size of text labels in the legends. Defaults to 1

filename

Filename for tiff output, or if NULL returns the trellis object itself. Defaults to NULL.

xlab.label

Defaults to “SNVs”.

xlab.cex

Defaults to 1.2

xaxis.cex

Defaults to 1

xaxis.fontface

Defaults to “bold”.

y.spacing

Spacing between heatmap and clone covariate bar. Defaults to 1

colour.scheme

Colour scheme for the heatmap. Defaults to c('white', 'blue').

...

Pass through argument. See BoutrosLab.plotting.general::create.heatmap() for further details.

Value

A 'grob' object of the heatmap.

Author(s)

Helena Winata

See Also

create.ccf.heatmap, create.heatmap


Phylogenetic Tree Plot

Description

Create a phylogenetic tree plot using 'SRCGrob'. The 'width', 'heigth', 'units', 'res', and 'bg' arguments are passed to the 'grDevices' function to save the plot to file.

Usage

create.phylogenetic.tree(
    tree,
    filename = NULL,
    width = 5,
    height = 5,
    units = 'in',
    res = 500,
    bg = 'white',
    ...
    )

Arguments

tree

Tree structure data.frame

filename

Filename for plot output, or if NULL displays the tree using grid.draw. Defaults to NULL.

width

Width of the plot. Defaults to 5.

height

Height of the plot. Defaults to 5.

units

Units of the plot. Defaults to “in”.

res

Resolution of the plot. Defaults to 500.

bg

Background colour of the plot. Defaults to “white”.

...

Pass through argument. See SRCGrob() for further details.

Value

A 'grob' of class "SRCGrob".

Author(s)

Helena Winata

See Also

SRCGrob, pdf, png, tiff, svg

Examples

# Simple Tree Plot
simple.tree <- data.frame(
    parent = c(NA, 1, 1)
    );
create.phylogenetic.tree(simple.tree);

# Non-numeric node.id
phy.dt <- data.frame(
    node.id = c('MRCA', 'C01', 'C02', 'C03', 5:7),
    parent = c(NA, 'MRCA', 'MRCA', 'MRCA', 'C02', 'C03', 'C03')
    );
create.phylogenetic.tree(phy.dt);

# Numeric disordered node.id with labels
phy.dt <- data.frame(
    node.id = c(1, 2, 5, 6, 4, 9, 10),
    parent = c(NA, 1, 1, 1, 5, 6, 6),
    label = c('MRCA', 'C01', 'C02', 'C03', 5:7)
    );
create.phylogenetic.tree(phy.dt);

GRCh37 Chromosom Information

Description

Chromosome information for the GRCh37 genome build. Used for plotting.

Format

data.frame


GRCh38 Chromosom Information

Description

Chromosome information for the GRCh38 genome build. Used for plotting.

Format

data.frame


Subclone Tree Plot

Description

Creates a phylogenetic tree using subclonal reconstruction data. An optional node text data.frame can be used to annotate notable genes alonside branches.

Usage

SRCGrob(
    tree,
    node.text = NULL,
    main = NULL,
    horizontal.padding = 0.1,
    scale1 = 1,
    scale2 = 1,
    yat = NULL,
    yaxis1.label = NULL,
    yaxis2.label = NULL,
    xlab.cex = 1.55,
    ylab.cex = 1.55,
    xaxis.cex = 1.45,
    yaxis.cex = 1.45,
    xaxis.label = 'CP',
    label.cex = NA,
    node.text.cex = 0.85,
    main.y = NULL,
    main.cex = 1.7,
    node.text.line.dist = 0.1,
    colour.scheme = 'grey',
    add.normal = FALSE,
    use.radians = FALSE,
    normal.cex = 1,
    label.nodes = TRUE,
    disable.polygons = FALSE,
    polygon.shape = 3,
    polygon.width = 1.2,
    length.from.node.edge = TRUE,
    size.units = 'npc',
    scale.bar = FALSE,
    scale.bar.coords = c(0.5, 1),
    scale.size.1 = NA,
    scale.size.2 = NA,
    scale.padding = 1

    );

Arguments

tree

Tree structure data.frame

node.text

Dataframe for text labels to be displayed next to nodes

main

Main plot title

horizontal.padding

Increase/reduce the plot's horizontal padding proportionally. A positive value will expand the padding, and a negative value will reduce it.

scale1

Proportionally scale the values of the first branch length column in the tree input.

scale2

Proportionally scale the values of the second branch length column in the tree input.

yat

Specific values to be used for the y-axis ticks. A list is required, with each element corresponding to an axis.

yaxis1.label

Text label for the first, leftmost y-axis

yaxis2.label

Text label for the second, rightmost y-axis

xlab.cex

Font size for the x-axis label

ylab.cex

Font size for the y-axis labels

xaxis.cex

Font size for the x-axis tick labels

yaxis.cex

Font size for the y-axis tick labels

xaxis.label

Text label for the x-axis

label.cex

Font size for the node labels

node.text.cex

Font size for the node text

main.y

Move the main plot title position up or down

main.cex

Font size for the main plot title

node.text.line.dist

Distance between node text and tree branches (as a value between 0 and 1)

colour.scheme

Vector of colour values to be used for CP polygons

add.normal

Adds a normal

use.radians

Unit to be used for 'angle' column (degrees or radians)

normal.cex

Font size within the normal 'box'

label.nodes

Enable/disable node labels

disable.polygons

Disables CP polygon drawing (even when CP values are provided)

polygon.shape

Changes the shape of the CP shading. Lower values are smoother.

polygon.width

Width of the CP shading

length.from.node.edge

Sets the branch length to be calculated from the edge of the node instead of the centre

size.units

Grid units to be used for all specific size/length parameters

scale.bar

Set to TRUE to add a scale bar instead of y-axis

scale.bar.coords

Coordinates for the scale bar placement c(x.pos, y.pos)

scale.size.1

Overide size of the first scale bar

scale.size.2

Overide size of the second scale bar

scale.padding

Padding between scale bars if more than 1 is present

Value

A ‘grob' of class ’SRCGrob'

Author(s)

Dan Knight

Examples

# Simple Tree Plot
simple.tree <- data.frame(
    parent = c(NA, 1, 1)
    );

SRCGrob(simple.tree);


# Specify Branch Lengths
branch.lengths.tree <- data.frame(
    simple.tree,
    length1 = c(10, 20, 15)
    );

SRCGrob(branch.lengths.tree);


# Cellular Prevalence
CP.tree <- data.frame(
    branch.lengths.tree,
    CP = c(1, 0.3, 0.5)
    );

SRCGrob(CP.tree);


# Scaled Branch Lengths
SRCGrob(
    branch.lengths.tree,
    scale1 = 0.8
    );


# Override Branch Angles in Degrees
degrees.tree <- data.frame(
    parent = c(NA, 1, 2),
    angle = c(NA, NA, 90)
    );

SRCGrob(degrees.tree);


# Override Branch Angles in Radians
radians.tree <- data.frame(
    parent = c(NA, 1, 2),
    angle = c(NA, NA, pi / 2)
    );

SRCGrob(
    radians.tree,
    use.radians = TRUE
    );


# Plot Title
SRCGrob(
    simple.tree,
    main = 'Example Plot'
    );


# Y-Axis Label
SRCGrob(
    branch.lengths.tree,
    yaxis1.label = 'SNVs'
    );


# Y-Axis Ticks
yaxis1.ticks <- seq(0, 10, 2);

SRCGrob(
    branch.lengths.tree,
    yat = list(yaxis1.ticks)
    );


# Scale Bar
SRCGrob(
    branch.lengths.tree,
    yaxis1.label = 'SNVs',
    scale.bar = TRUE
    );


# Normal
SRCGrob(
    simple.tree,
    add.normal = TRUE
    );


# Nodeless Mode
nodeless.tree <- data.frame(
    parent = c(NA, 1, 2, 2),
    draw.node = c(TRUE, FALSE, TRUE, TRUE)
    );

SRCGrob(nodeless.tree);