plot_clonealign: Plot gene expression and copy number

Description Usage Arguments Details Value Examples

View source: R/plotting.R

Description

Plot gene expression and copy number as a function of genomic coordinate.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
plot_clonealign(
  sce,
  clones,
  cnv_data,
  chromosome = "1",
  chr_str = "chr",
  start_str = "start_position",
  end_str = "end_position",
  jitter_cnv = TRUE,
  ggplot_palette = "Set1",
  expression_ylim = c(-0.15, 0.15),
  cnv_dodge_sd = 0.1
)

Arguments

sce

A SingleCellExperiment. Note this must have the fields chr_str, start_str, and end_str in rowData. See details.

clones

The clone assignments of each cell - must be of the same set as the colnames of L

cnv_data

The gene by clone copy number matrix used as input to clonealign_fit. The genes (rows) of this must match to the genes in sce

chromosome

The chromosome to plot

chr_str

The column of rowData(sce) that refers to the chromosome of each feature

start_str

The column of rowData(sce) that refers to the start position of each feature

end_str

The column of rowData(sce) that refers to the end position of each feature

jitter_cnv

Logical - if true random noise is added to the copy number profiles to help display all clones in case two lie on top of each other

ggplot_palette

The palette to be passed to scale_colour_brewer

expression_ylim

The y axis limits on the smoothed expression plot

cnv_dodge_sd

The standard deviation of the (0 mean) noise to add to the CNV plot

Details

This function requires the chromosome, start, and end positions of each features to plot. These are encoded as the chr_str, start_str, and end_str features in rowData(sce) respectively. If we have ensembl ids or similar we can get add the required fields using the getBMFeatureAnnos function in the scater package -
sce <- getBMFeatureAnnos(sce, filters = "ensembl_gene_id", attributes = c("chromosome_name", "start_position", "end_position"), feature_symbol = "hgnc_symbol", feature_id = "ensembl_gene_id", dataset = "hsapiens_gene_ensembl")
Then we would call plot_clonealign using chr_str == "chromosome_name", start_str == "start_position", and end_str == "end_position".

Value

A ggplot2 object displaying a CNV and gene expression track for each (inferred) clone

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(SingleCellExperiment)
library(scater)
library(dplyr)
data(example_clonealign_fit)
cnv_data <- rowData(example_sce)[,c("A", "B", "C")]
gene_position <- as_data_frame(cnv_data) %>%
mutate(gene = seq_len(nrow(cnv_data))) %>%
  arrange(A, B, C) %>%
 mutate(position = seq_len(nrow(cnv_data))) %>%
  arrange(gene) %>%
  .$position

rowData(example_sce)$chromosome <- "1"
rowData(example_sce)$start_pos <- gene_position
rowData(example_sce)$end_pos <- gene_position
example_sce <- normalize(example_sce)
plot_clonealign(example_sce, example_clonealign_fit$clone, cnv_data,
chromosome = "1",
chr_str = "chromosome",
start_str = "start_pos",
end_str = "end_pos")

kieranrcampbell/clonealign documentation built on Dec. 18, 2020, 3:49 a.m.