plot_all: Plot all results from signature fitting or extraction

Description Usage Arguments Examples

View source: R/sigfit_plotting.R

Description

For a given set of signature fitting or extraction results, plot_all plots, in PDF format:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
plot_all(
  mcmc_samples = NULL,
  out_path,
  prefix = NULL,
  counts = NULL,
  signatures = NULL,
  exposures = NULL,
  opportunities = NULL,
  thresh = 0.01,
  hpd_prob = 0.95,
  signature_names = NULL,
  exp_margin_bottom = 10.5,
  exp_legend_pos = "topleft",
  exp_legend_cex = 2,
  exp_cex_names = 1.9,
  rec_legend_pos = "topleft",
  rec_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.

out_path

Character indicating the path to the directory where the output PDF files will be stored. The directory will be created if it does not exist.

prefix

Character indicating an optional prefix to be added to output file names.

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.

thresh

Numeric indicating the minimum threshold for the lower HPD limits of signature exposures (default is 0.01). Exposures with a lower HPD limit below this value will be shown in grey. This value is passed to plot_exposures.

hpd_prob

Numeric value in the interval (0, 1), indicating the desired probability content of HPD intervals (default is 0.95). This value is passed to plot_exposures.

signature_names

Character vector containing the name of each signature. Only needed if mcmc_samples is not provided and the exposures were obtained via signature fitting (rather than extraction). This value is passed to plot_exposures.

exp_margin_bottom

Numeric indicating the bottom margin of the exposures barplots, in inches (default is 10.5). This value is passed to plot_exposures.

exp_legend_pos

Character indicating the position of the legend in the exposures barplot. Admits values "top", "bottom", "center", "left", "right", "topleft", "topright", "bottomleft" and "bottomright" (default is "topleft"). This value is passed to plot_exposures.

exp_legend_cex

Numeric indicating the relative size of the legend in the exposures barplot (default is 2). This value is passed to plot_exposures.

exp_cex_names

Numeric indicating the relative size of sample labels in the exposures barplot (default is 1.9). This value is passed to plot_exposures.

rec_legend_pos

Character indicating the position of the legend in the spectrum reconstruction plots. Admits values "top", "bottom", "center", "left", "right", "topleft", "topright", "bottomleft" and "bottomright" (default is "topleft"). This value is passed to plot_reconstruction.

rec_legend_cex

Numeric indicating the relative size of the legend in the reconstruction plots (default is 2). This value is passed to plot_reconstruction.

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. This value is passed to plot_exposures and plot_reconstruction.

boxes

Logical indicating whether boxes should be drawn around spectrum, signature and reconstruction plots (default is TRUE). This value is passed to plot_spectrum and plot_reconstruction.

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. This value is passed to plot_spectrum and plot_reconstruction.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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 results using MCMC samples
plot_all(mcmc_samples = samples, out_path = ".", prefix = "Test1")

# Plot results using retrieved signatures and exposures
plot_all(counts = counts_21breast, signatures = signatures,
         exposures = exposures, opportunities = "human-genome",
         out_path = ".", prefix = "Test2")

## End(Not run)

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