plot_reconstruction: Plot mutational spectrum reconstructions

Description Usage Arguments Examples

View source: R/sigfit_plotting.R

Description

plot_reconstruction plots reconstructions of the original mutational catalogues obtained using the inferred signatures and/or exposures. If provided with multiple catalogues, it produces one plot per catalogue. Fitting or extraction results can be provided either as a single stanfit object (generated via fit_signatures or extract_signatures), or as separate signatures and exposures matrices (or lists produced via retrieve_pars). Only the former option allows the incorporation of HPD intervals to the reconstructed catalogue.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
plot_reconstruction(
  mcmc_samples = NULL,
  pdf_path = NULL,
  counts = NULL,
  signatures = NULL,
  exposures = NULL,
  opportunities = NULL,
  pdf_width = 24,
  pdf_height = 15,
  legend_pos = "topleft",
  legend_cex = 2,
  sig_color_palette = NULL,
  boxes = TRUE,
  generic = FALSE
)

Arguments

mcmc_samples

List with two elements named `data` and `results`, produced via fit_signatures, extract_signatures, or fit_extract_signatures. This is the preferred option for supplying data and results, but can be replaced by the combination of arguments counts, signatures, exposures and opportunities.

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.

counts

Numeric matrix of observed mutation counts, with one row per sample and one column per mutation type. Only needed if mcmc_samples is not provided.

signatures

Either a numeric matrix of mutational signatures, with one row per signature and one column per mutation type, or a list of matrices generated via retrieve_pars. Only needed if mcmc_samples is not provided.

exposures

Either a numeric matrix of signature exposures, with one row per sample and one column per signature, or a list of matrices generated via retrieve_pars. Only needed if mcmc_samples is not provided.

opportunities

Numeric matrix of mutational opportunities, with one row per signature and one column per mutation type. It also admits character values "human-genome" or "human-exome", in which case the mutational opportunities of the reference human genome/exome will be used. Only needed if mcmc_samples is not provided and opportunities were used during signature extraction or fitting.

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 15). Only used if pdf_path is provided.

legend_pos

Character indicating the position of the legend in the plots. Admits values "top", "bottom", "center", "left", "right", "topleft", "topright", "bottomleft" and "bottomright" (default is "topleft").

legend_cex

Numeric indicating the relative size of the legend (default is 2).

sig_color_palette

Character vector of custom color names or hexadecimal codes to use for each signature in exposure and reconstruction plots. Must have at least as many elements as the number of signatures.

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
19
20
## Not run: 
# Load example mutational catalogues
data("counts_21breast")

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

# Retrieve signatures and exposures
signatures <- retrieve_pars(samples, "signatures")
exposures <- retrieve_pars(samples, "exposures")

# Plot reconstructed catalogues using stanfit object
plot_reconstruction(mcmc_samples = samples, pdf_path = "Reconstructions_1.pdf")

# Plot reconstructed catalogues using retrieved signatures and exposures
plot_reconstruction(counts = counts_21breast, signatures = signatures, exposures = exposures,
                    opportunities = "human-genome", pdf_path = "Reconstructions_2.pdf")

## End(Not run)

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