View source: R/fitToSignatures.R
fitToSignatures | R Documentation |
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
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(...)
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 |
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.