fitToSignatures: Linear least-squares (non-negative) fitting

View source: R/fitToSignatures.R

fitToSignaturesR Documentation

Linear least-squares (non-negative) fitting

Description

Calculate the contribution of each mutational signature in a sample, given a vector of mutation contexts. This is done by least-squares fitting, i.e. find a linear non-negative combination of mutation signatures that optimally reconstructs the mutation matrix. This is performed by 'fitToSignatures()'

Only performing least-squares fitting is however potentially prone to overfitting. 'fitToSignaturesStrict()' tries to solve this problem by performing an initial fit, then iteratively removing the signature with the lowest contribution and with fitting then repeated. Each time the cosine distance between the original and reconstructed mutation context profile is calculated. Iterations are stopped when cosine distance > max.delta. The second-last set of signatures is then returned.

'fitToSignaturesFast()' and 'fitToSignaturesFastStrict()' are wrappers for 'fitToSignatures(..., use.lsq.r=F)' and 'fitToSignaturesStrict(..., use.lsq.r=F)' for backwards compatibility

Usage

fitToSignatures(
  mut.context.counts,
  signature.profiles,
  use.lsq.r = USE_LSQ_R,
  scale.contrib = T,
  verbose = F
)

fitToSignaturesFast(...)

fitToSignaturesStrict(
  mut.context.counts,
  signature.profiles,
  max.delta = 0.004,
  detailed.output = F,
  use.lsq.r = USE_LSQ_R,
  scale.contrib = T,
  verbose = F
)

fitToSignaturesFastStrict(...)

Arguments

signature.profiles

A matrix containing the mutational signature profiles, where rows are the mutation contexts and the columns are the mutational signatures.

use.lsq.r

If TRUE, least squares fitting will be performed using the slow R function 'lsqnonneg()'. If FALSE, the much faster NNLM::nnlm() will be used (written in C++)

scale.contrib

If TRUE, the signature contributions will be scaled so that the total signature contribution is equal to the total number of mutations. The reason for this is that when performing least squares fitting, there are unaccounted for mutations (aka residual; not necessarily an integer amount of mutations).

verbose

Show progress messages?

max.delta

See description.

detailed.output

Only for 'fitToSignaturesStrict()'. Also return results from the iterative fitting? Includes: cosine similarity between the original and reconstructed mutation context; signatures removed at each iteration. Useful for plotting fitting performance.

mut.contexts

A vector of mutation contexts, or a matrix where rows are samples and columns are mutation contexts

Value

If vector is provided to mut.contexts, a vector returned containing the the absolute contribution of each signature (i.e. the number of mutations contributing to each mutational signature). If a matrix is provided, a matrix of absolute contributions is returned


UMCUGenetics/mutSigExtractor documentation built on Aug. 30, 2024, 2:12 p.m.