GenerateNoisyTumors: Generate noisy tumors from available exposures

View source: R/GenerateNoisyTumors.R

GenerateNoisyTumorsR Documentation

Generate noisy tumors from available exposures

Description

Generate noisy tumors from available exposures

Usage

GenerateNoisyTumors(
  seed,
  dir,
  input.exposure,
  signatures,
  n.binom.size = NULL,
  overwrite = TRUE
)

Arguments

seed

A random seed to use.

dir

The directory in which to put the output; will be created if necessary.

input.exposure

A matrix of exposures.

signatures

A matrix of signatures.

n.binom.size

If non NULL, use negative binomial noise with this size parameter; see NegBinomial. If NULL, then use Poisson distribution to do the resampling.

overwrite

If TRUE, overwrite existing directories and files.

Value

A list with the elements

exposures

The numbers of mutations due to each signature after adding noise

spectra

The spectra based on the noisy signature exposures.

Examples


# Generate synthetic tumors for Indel (ID) using negative binomial distribution
input.sigs.ID <- cosmicsig::COSMIC_v3.2$signature$GRCh37$ID
real.exposures.ID <- PCAWG7::exposure$PCAWG$ID
cancer.types <- PCAWG7::CancerTypes()[1:5]
ID.synthetic.tumors <-
  GenerateSyntheticTumors(seed = 191906,
                          dir = file.path(tempdir(), "ID.synthetic.tumors"),
                          cancer.types = cancer.types,
                          samples.per.cancer.type = 30,
                          input.sigs = input.sigs.ID,
                          real.exposures = real.exposures.ID,
                          distribution = "neg.binom",
                          sample.prefix.name = "SP.Syn."
  )

# Add noise to the exposures
ID.noisy.tumors <-
  GenerateNoisyTumors(seed = 892513,
                      dir = file.path(tempdir(), "ID.noisy.tumors"),
                      input.exposure = ID.synthetic.tumors$ground.truth.exposures,
                      signatures = ID.synthetic.tumors$ground.truth.signatures,
                      n.binom.size = 1)

# Plot the synthetic and noisy catalog and exposures
ICAMS::PlotCatalogToPdf(catalog = ID.synthetic.tumors$ground.truth.catalog,
                        file = file.path(tempdir(), "ID.synthetic.catalog.pdf"))
mSigAct::PlotExposureToPdf(exposure = ID.synthetic.tumors$ground.truth.exposures,
                           file = file.path(tempdir(), "ID.synthetic.exposures.pdf"),
                           cex.xaxis = 0.7)
ICAMS::PlotCatalogToPdf(catalog = ID.noisy.tumors$spectra,
                        file = file.path(tempdir(), "ID.noisy.catalog.pdf"))
mSigAct::PlotExposureToPdf(exposure = ID.noisy.tumors$exposures,
                           file = file.path(tempdir(), "ID.noisy.exposures.pdf"),
                           cex.xaxis = 0.7)


steverozen/SynSigGen documentation built on April 1, 2022, 8:54 p.m.