plot_spectrum: Plot mutational spectra

Description Usage Arguments Examples

View source: R/sigfit_plotting.R

Description

plot_spectrum generates plots of one or more mutational spectra, which can be either mutational catalogues or mutational signatures. If provided with multiple spectra, it produces one plot per spectrum. If the spectra contain values greater than 1, the values will be interpreted as mutation counts (as in a catalogue); otherwise, they will be interpreted as mutation probabilities (as in a signature).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
plot_spectrum(
  spectra,
  pdf_path = NULL,
  pdf_width = 24,
  pdf_height = 8,
  name = NULL,
  max_y = NULL,
  colors = NULL,
  boxes = TRUE,
  generic = FALSE
)

Arguments

spectra

This can be a numeric vector with one element per mutation type, a numeric matrix with one row per signature/catalogue and one column per mutation type, or a list of signature matrices as produced by retrieve_pars. In the latter case, HPD intervals will be included in the plots. Row names will be used as the catalogue/signature names.

pdf_path

Character indicating the path to an optional output PDF file for the plots. The PDF dimensions and graphical parameters are automatically set to appropriate values, but custom dimensions can be specified via the arguments pdf_width and pdf_height.

pdf_width

Numeric indicating the width of the output PDF, in inches (default is 24). Only used if pdf_path is provided.

pdf_height

Numeric indicating the height of the output PDF, in inches (default is 8). Only used if pdf_path is provided.

name

Character indicating a name to include in the plot title; useful when plotting a single spectrum.

max_y

Numeric indicating an optional upper limit for the vertical axis.

colors

Character vector of custom color names or hexadecimal codes to use for the spectrum bars. Must contain either a single value, or as many values as the number of mutation types in the spectrum. This argument is ignored when plotting transcriptional strand-wise spectra.

boxes

Logical indicating whether boxes should be drawn around the plots (default is TRUE).

generic

Logical indicating whether a "generic" spectrum should be plotted (default is FALSE). A generic spectrum is always plotted if the number of mutation types in spectra does not match any of the available spectrum types.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# Load example mutational catalogues
data("counts_21breast")

# Plot catalogues
plot_spectrum(counts_21breast, pdf_path = "Catalogues.pdf")

# Extract signatures using the Poisson model
samples <- extract_signatures(counts_21breast, nsignatures = 2, model = "poisson",
                              opportunities = "human-genome", iter = 800)

# Retrieve extracted signatures
sigs <- retrieve_pars(samples, "signatures")

# Plot signatures
plot_spectrum(sigs, pdf_path = "Signatures.pdf")

## End(Not run)

kgori/sigfit documentation built on Feb. 3, 2022, 12:04 p.m.