| Title: | Quantify and visualize variability of mutational signatures within and across samples |
|---|---|
| Description: | This package allows users to import mutational signature attribution (a.k.a. exposure) matrices and compute, visualize, and test their variabilities within and across samples. |
| Authors: | Maike Morrison [aut] (ORCID: <https://orcid.org/0000-0003-0430-1401>), Nicolas Alcala [aut, cre] (ORCID: <https://orcid.org/0000-0002-5961-5064>), Worldwide Cancer Research [fnd] (Grant 24-0106), French Ligue Nationale Contre le Cancer [fnd] |
| Maintainer: | Nicolas Alcala <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.99.8 |
| Built: | 2026-10-11 10:39:30 UTC |
| Source: | https://github.com/bioc/sigvar |
Vector of named colors for use in plotting the relative activities of mutational signatures.
data(all_sig_pal)data(all_sig_pal)
all_sig_palA vector of HEX color codes for mutational signature activities.
Data from: Riva et al. Nat Genet (2020)
data(carcinogens_mice_SBS)data(carcinogens_mice_SBS)
An object of class tbl_df (inherits from tbl, data.frame) with 181 rows and 47 columns.
Data from: Riva et al. Nat Genet (2020)
data(carcinogens_mice_SBS.refs)data(carcinogens_mice_SBS.refs)
An object of class tbl_df (inherits from tbl, data.frame) with 96 rows and 13 columns.
COSMIC 3.0 Indel mutational signatures from the COSMIC website
data(COSMIC3.0_ID)data(COSMIC3.0_ID)
COSMIC3.0_IDA tibble with 83 rows and 18 columns:
Type of ID
Proportion of ID in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
COSMIC 3.0 Single base substitutions mutational signatures from the COSMIC website
data(COSMIC3.0_SBS)data(COSMIC3.0_SBS)
COSMIC3.0_SBSA tibble with 96 rows and 68 columns:
Type of SBS
Proportion of SBS in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
COSMIC 3.1 Copy Number mutational signatures from Mangiante et al. Nat Genet 55, 607–618 (2023). https://doi.org/10.1038/s41588-023-01321-1
data(COSMIC3.1_CN)data(COSMIC3.1_CN)
COSMIC3.1_CNA tibble with 48 rows and 8 columns:
Type of segment
Proportion of Copy number segments in each category
COSMIC 3.3 Copy Number mutational signatures from the COSMIC website
data(COSMIC3.3_CN)data(COSMIC3.3_CN)
COSMIC3.3_CNA tibble with 48 rows and 8 columns:
Type of segment
Proportion of Copy number segments in each category
https://cancer.sanger.ac.uk/signatures/downloads/
COSMIC 3.3 Double base mutational signatures from the COSMIC website
data(COSMIC3.3_DBS)data(COSMIC3.3_DBS)
COSMIC3.3_DBSA tibble with 78 rows and 12 columns:
Type of ID
Proportion of DBS in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
Mice COSMIC 3.3 Double base mutational signatures from the COSMIC website
data(COSMIC3.3_DBS_mm10)data(COSMIC3.3_DBS_mm10)
COSMIC3.3_DBS_mm10A tibble with 78 rows and 12 columns:
Type of ID
Proportion of DBS in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
COSMIC 3.3 Indel mutational signatures from the COSMIC website
data(COSMIC3.3_ID)data(COSMIC3.3_ID)
COSMIC3.3_IDA tibble with 83 rows and 19 columns:
Type of ID
Proportion of ID in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
COSMIC 3.3.1 Single base substitutions mutational signatures from the COSMIC website
data(COSMIC3.3.1_SBS)data(COSMIC3.3.1_SBS)
COSMIC3.3.1_SBSA tibble with 96 rows and 80 columns:
Type of SBS
Proportion of SBS in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
Mice COSMIC 3.3.1 Single base substitutions mutational signatures from the COSMIC website
data(COSMIC3.3.1_SBS_mm10)data(COSMIC3.3.1_SBS_mm10)
COSMIC3.3.1_SBS_mm10A tibble with 96 rows and 80 columns:
Type of SBS
Proportion of SBS in each class for each signature
https://cancer.sanger.ac.uk/signatures/downloads/
Compute the cosine similarity matrix for a set of mutational signatures.
cossim(ref_sigs)cossim(ref_sigs)
ref_sigs |
A matrix with K columns containing non-negative entries that sum to 1. Each column represents a signature (e.g., SBS1, SBS2), each row represents a mutation type (e.g., |
A K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry S[j,k] is the similarity between signature j and signature k, equaling 1 if the categories are to be treated as identical and equaling 0 if they are to be treated as totally dissimilar. The default value is S = diag(K).
# Compute the cosine similarity matrix for the lung cancer # in never smoker datasets from Zhang et al. 2021 data(Sherlock_LCINS_SBS.refs, package = "sigvar") cossim(ref_sigs = as.matrix(Sherlock_LCINS_SBS.refs[, seq_len(14)]))# Compute the cosine similarity matrix for the lung cancer # in never smoker datasets from Zhang et al. 2021 data(Sherlock_LCINS_SBS.refs, package = "sigvar") cossim(ref_sigs = as.matrix(Sherlock_LCINS_SBS.refs[, seq_len(14)]))
Data from: Ensembl
data(EGFR_context_counts_ordered)data(EGFR_context_counts_ordered)
An object of class table of length 96.
Data from: Intogen database
data(EGFR_drivers_intogen_SBS96)data(EGFR_drivers_intogen_SBS96)
An object of class tbl_df (inherits from tbl, data.frame) with 96 rows and 4 columns.
Data from: Moody et al. Nat Genet (2021)
data(ESCC_countries_SBS)data(ESCC_countries_SBS)
An object of class tbl_df (inherits from tbl, data.frame) with 552 rows and 31 columns.
Data from: Moody et al. Nat Genet (2021)
data(ESCC_countries_SBS.refs)data(ESCC_countries_SBS.refs)
An object of class tbl_df (inherits from tbl, data.frame) with 96 rows and 30 columns.
Data from: Moody, S., Senkin, S., Islam, S.M.A. et al. Mutational signatures in esophageal squamous cell carcinoma from eight countries with varying incidence. Nat Genet 53, 1553–1563 (2021).
data(ESCC_sig_activity)data(ESCC_sig_activity)
ESCC_sig_activityA dataframe with 552 rows and 46 columns:
Country where each sample was collected
Incidence level (High or Low) of ESCC in the region where the sample was collected
Unique sample ID
Relative abundance of mutational signatures in each sample. These columns sum to 1 for each row.
https://doi.org/10.1038/s41588-021-00928-6
Data from: Moody, S., Senkin, S., Islam, S.M.A. et al. Mutational signatures in esophageal squamous cell carcinoma from eight countries with varying incidence. Nat Genet 53, 1553–1563 (2021).
data(ESCC_sig_similarity)data(ESCC_sig_similarity)
ESCC_sig_similarityA dataframe with 43 rows and 43 columns:
Pairwise cosine similarities between mutational signatures.
https://doi.org/10.1038/s41588-021-00928-6
This function computes the population genetic statistic Fst on any matrix with rows that sum to 1. Values of 1 are achieved when each row is a permutation of (1,0,..., 0) and at least two categories have non-zero abundance across all rows. The value equals 0 when each row is identical.
fst( relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL, normalized = FALSE )fst( relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL, normalized = FALSE )
relab_matrix |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents
a sample, each column represents a category, and each entry represents the abundance of that category in the sample.
If |
K |
Optional; an integer specifying the number of categories in the data. Default is |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight Fst by the distance between samples. |
group |
Optional; a string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each row (sample) belongs to. Use if |
normalized |
Optional; should normalized Fst be used? Default is |
A numeric value between 0 and 1.
# Compute the Fst of # the following compositional vectors: q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) fst(relative_abundances) # Incorporating weights: # Compute fst ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) fst(relative_abundances, w = row_weights) # Compute fst assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 fst(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) fst(relative_abundances, w = row_weights, S = similarity_matrix)# Compute the Fst of # the following compositional vectors: q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) fst(relative_abundances) # Incorporating weights: # Compute fst ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) fst(relative_abundances, w = row_weights) # Compute fst assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 fst(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) fst(relative_abundances, w = row_weights, S = similarity_matrix)
This function computes the normalized Fst given the number of rows and the mean abundance of the most abundant category. We employ the normalization employed in the FSTruct package by Morrison, Alcala, and Rosenberg (2020).
fst_norm(relab_matrix, K = ncol(relab_matrix))fst_norm(relab_matrix, K = ncol(relab_matrix))
relab_matrix |
A matrix with |
K |
Optional; an integer specifying the number of categories in the data. Default is |
A numeric value between 0 and 1.
# Compute the normalized fst of # the following compositional vectors: q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) fst_norm(relative_abundances)# Compute the normalized fst of # the following compositional vectors: q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) fst_norm(relative_abundances)
get_SBS96_driver_spectrum
get_SBS96_driver_spectrum(driverlist, ref_genome)get_SBS96_driver_spectrum(driverlist, ref_genome)
driverlist |
a table containing a list of drivers alterations, with columns chr, pos, and alt |
ref_genome |
BSgenome reference genome |
A a named integer table (length 96) containing the SBS spectrum of the transcript
data(TP53_drivers_intogen_LUAD, package = "sigvar") ref_genome <- "BSgenome.Hsapiens.UCSC.hg38" library(ref_genome, character.only = TRUE) TP53_LUAD.driver.spectrum <- get_SBS96_driver_spectrum(TP53_drivers_intogen_LUAD,ref_genome) print(TP53_LUAD.driver.spectrum)data(TP53_drivers_intogen_LUAD, package = "sigvar") ref_genome <- "BSgenome.Hsapiens.UCSC.hg38" library(ref_genome, character.only = TRUE) TP53_LUAD.driver.spectrum <- get_SBS96_driver_spectrum(TP53_drivers_intogen_LUAD,ref_genome) print(TP53_LUAD.driver.spectrum)
get_SBS96_spectrum
get_SBS96_spectrum( transcript = "ENST00000269305.9", organism = "Homo sapiens", ref_genome )get_SBS96_spectrum( transcript = "ENST00000269305.9", organism = "Homo sapiens", ref_genome )
transcript |
the ensembl ID of the transcript |
organism |
the name of the organism associated with the transcript (species) |
ref_genome |
BSgenome reference genome |
A 96 x 1 matrix containing the SBS spectrum of the transcript
# Run on ref_genome <- "BSgenome.Hsapiens.UCSC.hg38" library(ref_genome, character.only = TRUE) spectrum <- get_SBS96_spectrum(transcript = "ENST00000269305.9", ref_genome=ref_genome) print(spectrum)# Run on ref_genome <- "BSgenome.Hsapiens.UCSC.hg38" library(ref_genome, character.only = TRUE) spectrum <- get_SBS96_spectrum(transcript = "ENST00000269305.9", ref_genome=ref_genome) print(spectrum)
This function computes the Gini-Simpson index, a statistical measure of variability also known as the heterozygosity, of a vector of non-negative entries which sum to 1. The function returns a number between 0 and 1 which quantifies the variability of the vector. Values of 0 are achieved when the vector is a permutation of (1,0,..., 0). The value approaches 1 as the number of categories K increases when the vector is equal to (1/K, 1/K, ..., 1/K).
het(q, K = length(q), S = diag(K))het(q, K = length(q), S = diag(K))
q |
A vector with |
K |
Optional; an integer specifying the number of categories in the data. Default is |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
A numeric value between 0 and 1.
# Compute unweighted Gini-Simpson index: het(q = c(0.4, 0.3, 0.3)) # Compute Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(3) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het(q = c(0.4, 0.3, 0.3), S = similarity_matrix)# Compute unweighted Gini-Simpson index: het(q = c(0.4, 0.3, 0.3)) # Compute Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(3) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het(q = c(0.4, 0.3, 0.3), S = similarity_matrix)
This function computes the mean Gini-Simpson index, a statistical measure of variability also known as the heterozygosity, of a set of vectors of non-negative entries which sum to 1. The function returns a number between 0 and 1 which quantifies the mean variability of the vectors. Values of 0 are achieved when each vector is a permutation of (1,0,..., 0). The value approaches 1 as the number of categories K increases when the vectors are equal to (1/K, 1/K, ..., 1/K).
het_mean(relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL)het_mean(relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL)
relab_matrix |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents
a sample, each column represents a category, and each entry represents the abundance of that category in the sample.
If |
K |
Optional; an integer specifying the number of categories in the data. Default is |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight Fst by the distance between samples. |
group |
Optional; a string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each row (sample) belongs to. Use if |
A numeric value between 0 and 1.
# To compute the mean Gini-Simpson index of # the following compositional vectors... q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # we could compute the mean manually: mean(vapply(X = list(q1, q2, q3, q4), FUN = het, FUN.VALUE = numeric(1))) # Or we could use het_mean: relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) het_mean(relative_abundances) # Incorporating weights: # Compute mean Gini-Simpson index ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) het_mean(relative_abundances, w = row_weights) # Compute mean Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het_mean(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) het_mean(relative_abundances, w = row_weights, S = similarity_matrix)# To compute the mean Gini-Simpson index of # the following compositional vectors... q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # we could compute the mean manually: mean(vapply(X = list(q1, q2, q3, q4), FUN = het, FUN.VALUE = numeric(1))) # Or we could use het_mean: relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) het_mean(relative_abundances) # Incorporating weights: # Compute mean Gini-Simpson index ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) het_mean(relative_abundances, w = row_weights) # Compute mean Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het_mean(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) het_mean(relative_abundances, w = row_weights, S = similarity_matrix)
This function computes the Gini-Simpson index of a "pooled" vector equal to colMeans(relab_matrix). Values of 0 are achieved when this pooled vector is a permutation of (1,0,..., 0). The value approaches 1 as the number of categories K increases when this pooled vector is equal to (1/K, 1/K, ..., 1/K).
het_pooled( relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL )het_pooled( relab_matrix, K = NULL, S = NULL, w = NULL, time = NULL, group = NULL )
relab_matrix |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents
a sample, each column represents a category, and each entry represents the abundance of that category in the sample.
If |
K |
Optional; an integer specifying the number of categories in the data. Default is |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight Fst by the distance between samples. |
group |
Optional; a string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each row (sample) belongs to. Use if |
A numeric value between 0 and 1.
# To compute the pooled Gini-Simpson index of # the following compositional vectors... q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # we could compute the mean manually: qPooled <- (q1 + q2 + q3 + q4) / 4 het(qPooled) # Or we could use het_pooled: relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) het_pooled(relative_abundances) # Incorporating weights: # Compute pooled Gini-Simpson index ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) het_pooled(relative_abundances, w = row_weights) # Compute pooled Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het_pooled(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) het_pooled(relative_abundances, w = row_weights, S = similarity_matrix)# To compute the pooled Gini-Simpson index of # the following compositional vectors... q1 <- c(1, 0, 0, 0) q2 <- c(0.5, 0.5, 0, 0) q3 <- c(1 / 4, 1 / 4, 1 / 4, 1 / 4) q4 <- c(0, 0, 1, 0) # we could compute the mean manually: qPooled <- (q1 + q2 + q3 + q4) / 4 het(qPooled) # Or we could use het_pooled: relative_abundances <- matrix(c(q1, q2, q3, q4), byrow = TRUE, nrow = 4 ) het_pooled(relative_abundances) # Incorporating weights: # Compute pooled Gini-Simpson index ignoring # rows 2 and 3 row_weights <- c(0.5, 0, 0, 0.5) het_pooled(relative_abundances, w = row_weights) # Compute pooled Gini-Simpson index assuming that # categories 1 and 2 are identical: similarity_matrix <- diag(4) similarity_matrix[1, 2] <- 1 similarity_matrix[2, 1] <- 1 het_pooled(relative_abundances, S = similarity_matrix) # Assume categories 1 and 2 are identical AND # ignore rows 2 and 4: row_weights <- c(0.5, 0, 0.5, 0) het_pooled(relative_abundances, w = row_weights, S = similarity_matrix)
import_SigProfiler
import_SigProfiler(folder = ".")import_SigProfiler(folder = ".")
folder |
a folder containing SigProfilerExtractor results |
A list of tibbles containing the SigProfiler activity matrices
# Import dummy SigProfilerExtractor output results SPfolder <- system.file("extdata", "SP", package = "sigvar") Qlist <- import_SigProfiler(SPfolder) print(Qlist) # Plot imported signatures plot_dots(Qlist[[1]], normalized = FALSE)# Import dummy SigProfilerExtractor output results SPfolder <- system.file("extdata", "SP", package = "sigvar") Qlist <- import_SigProfiler(SPfolder) print(Qlist) # Plot imported signatures plot_dots(Qlist[[1]], normalized = FALSE)
Data from: Intogen database
data(Intogen_EGFR_LUAD)data(Intogen_EGFR_LUAD)
An object of class tbl_df (inherits from tbl, data.frame) with 25 rows and 13 columns.
Copy Number and Single Base Substitution mutational signature attributions from Mangiante et al. Nat Genet 55, 607–618 (2023). https://doi.org/10.1038/s41588-023-01321-1
data(MESOMICS_CN_SBS)data(MESOMICS_CN_SBS)
MESOMICS_CN_SBSA tibble with 120 rows and 41 columns:
Identifier of the patient
Identifier of the tumor sample
Patient sex
Patient age at diagnosis
Patient exposure status
Survival status (dead or alive) and time in months
Quantitative asbestos exposure variables
Tumor histological type (WHO)
Copy number burden
Copy number signature attributions
Single Base Substitution signature attributions
Data on single Base Substitution mutational signature attributions from Riva et al. Nat Genet 52, 1189–1197 (2020). https://doi.org/10.1038/s41588-020-0692-4
data(mutsig_carcinogens_mice_bootstrap_p_vals)data(mutsig_carcinogens_mice_bootstrap_p_vals)
mutsig_carcinogens_mice_bootstrap_p_valsA tibble with 29 rows and 7 columns:
Organ of tumor and exposure status
Exposure substance
Tissue of origin
Tumor/exposure reference each tumor/exposure group was compared to (either "Spontaneous_liver" or "Spontaneous_lung" )
P-values comparing values of across-sample heterogeneity between group and group_2
P-values comparing values of within-sample diversity between group and group_2
P-values comparing the pooled diversity between group and group_2
Single Base Substitution mutational signature attributions from Riva et al. Nat Genet 52, 1189–1197 (2020). https://doi.org/10.1038/s41588-020-0692-4
data(mutsig_carcinogens_mice_SBS)data(mutsig_carcinogens_mice_SBS)
mutsig_carcinogens_mice_SBSA tibble with 181 rows and 46 columns:
Identifier of the tumor
Number of mutations for each signature
Tissue of origin
Type of cancer
Treatment dose
Known or suspected carcinogen chemical administered
Single Base Substitution mutational signature definitions from Riva et al. Nat Genet 52, 1189–1197 (2020). https://doi.org/10.1038/s41588-020-0692-4
data(mutsig_carcinogens_mice_SBS.refs)data(mutsig_carcinogens_mice_SBS.refs)
mutsig_carcinogens_mice_SBS.refsA tibble with 96 rows and 13 columns:
Substitution type (e.g., C>A, T>G)
Substitution type with 5' and 3' context (e.g., ACA)
Proportion of mutations in each class for each signature
Double Base Substitution mutational signature attributions to COSMIC signatures from the Pan Cancer Whole-Genome consortium (PCAWG). Oct 19 2019 version
data(PCAWG_SigProfiler_COSMIC_DBS)data(PCAWG_SigProfiler_COSMIC_DBS)
PCAWG_SigProfiler_COSMIC_DBSA tibble with 2,670 rows and 14 columns:
Type of cancer
Identifier of the tumor
Number of mutations for each signature
...
Indel mutational signature attributions to COSMIC signatures from the Pan Cancer Whole-Genome consortium (PCAWG). Oct 19 2019 version
data(PCAWG_SigProfiler_COSMIC_ID)data(PCAWG_SigProfiler_COSMIC_ID)
PCAWG_SigProfiler_COSMIC_IDA tibble with 2,780 rows and 20 columns:
Type of cancer
Identifier of the tumor
Number of mutations for each signature
...
Single Base Substitution mutational signature attributions to COSMIC signatures from the Pan Cancer Whole-Genome consortium (PCAWG). Oct 19 2019 version
data(PCAWG_SigProfiler_COSMIC_SBS)data(PCAWG_SigProfiler_COSMIC_SBS)
PCAWG_SigProfiler_COSMIC_SBSA tibble with 2,780 rows and 68 columns:
Type of cancer
Identifier of the tumor
Number of mutations for each signature
...
This function generates a dot plot with signatures along the y-axis, group/populations along the x-axis, dot size corresponding to the fraction of samples in each population containing a signature, and dot color corresponding to the mean relative activity of mutations to that signature.
plot_dots( sig_activity, group = colnames(sig_activity)[1], K = ncol(sig_activity) - 1 - as.numeric(!missing(facet)), max_dotsize = 5, pivot = FALSE, median = FALSE, normalized = TRUE, facet, threshold = 0 )plot_dots( sig_activity, group = colnames(sig_activity)[1], K = ncol(sig_activity) - 1 - as.numeric(!missing(facet)), max_dotsize = 5, pivot = FALSE, median = FALSE, normalized = TRUE, facet, threshold = 0 )
sig_activity |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents a sample, each column represents a mutational signature, and each entry represents the abundance of that signature in the sample. If |
group |
A string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each sample belongs to. Default is the first column of |
K |
Optional; the number of signatures in the matrix. Default is
|
max_dotsize |
Optional; a number specifying the maximum size for each dot. |
pivot |
Optional; set |
median |
Optional; specify |
normalized |
Optional; specify |
facet |
Optional; a string specifying the name of the column by which you would like to facet your plot. |
threshold |
Optional; a number between 0 and 1. For each signature, the size of the associated dot corresponds to the proportion of tumors with that signature at an abundance exceeding this threshold. Default is |
A ggplot object containing a dot plot visualization of the mean mutational signature activities
# Make an example matrix. # Each row is a sample. Rows sum to 1. sig_activity <- matrix( c( "A", .4, .2, .4, "A", .5, .3, .2, "A", .5, .4, .1, "B", .6, .1, .3, "B", .6, .3, .1 ), nrow = 5, byrow = TRUE ) colnames(sig_activity) <- c("pop", "SBS1", "SBS2", "SBS3") sig_activity <- dplyr::mutate(data.frame(sig_activity), dplyr::across( c(SBS1, SBS2, SBS3), as.numeric )) plot_dots(sig_activity, K = 3, # How many categories per vector? group = "pop" )# Make an example matrix. # Each row is a sample. Rows sum to 1. sig_activity <- matrix( c( "A", .4, .2, .4, "A", .5, .3, .2, "A", .5, .4, .1, "B", .6, .1, .3, "B", .6, .3, .1 ), nrow = 5, byrow = TRUE ) colnames(sig_activity) <- c("pop", "SBS1", "SBS2", "SBS3") sig_activity <- dplyr::mutate(data.frame(sig_activity), dplyr::across( c(SBS1, SBS2, SBS3), as.numeric )) plot_dots(sig_activity, K = 3, # How many categories per vector? group = "pop" )
Plot an SBS mutational spectrum
plot_SBS_spectrum(SBS_table)plot_SBS_spectrum(SBS_table)
SBS_table |
A matrix with rows corresponding to the 96 single-base substitutions and columns corresponding to distinct mutational spectra you wish to plot. |
A ggplot2 bar chart depicting SBS mutational spectra
data(COSMIC3.3.1_SBS, package = "sigvar") SBS_table <- dplyr::select(COSMIC3.3.1_SBS, SBS1, SBS5) plot_SBS_spectrum(SBS_table)data(COSMIC3.3.1_SBS, package = "sigvar") SBS_table <- dplyr::select(COSMIC3.3.1_SBS, SBS1, SBS5) plot_SBS_spectrum(SBS_table)
This function enables graphical visualization of a matrix of compositional data. In the output plot, each vertical bar represents a single vector; the height of each color in the bar corresponds to the abundance of each category in that vector. Because this function produces a ggplot object, its output can be modified using standard ggplot2 syntax.
plot_signature_prop( relab_matrix, group = NULL, time = NULL, w = NULL, K = NULL, arrange = FALSE )plot_signature_prop( relab_matrix, group = NULL, time = NULL, w = NULL, K = NULL, arrange = FALSE )
relab_matrix |
A matrix with |
group |
Optional; a string specifying the name of the column that describes which group each row (sample) belongs to. Use if |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight the samples by the distance between them in the visualization. |
w |
Optional; a vector of length |
K |
Optional; an integer specifying the number of categories in the data. Default is |
arrange |
Optional; controls horizontal ordering of samples and vertical ordering of categories.
If |
A ggplot object containing a bar plot visualization of the relative abundance matrix.
# Make an example matrix of compositional data # Each row is an individual. Rows sum to 1. population_A <- matrix( c( .5, .3, .2, .4, .2, .4, .5, .4, .1, .6, .1, .3, .2, 0, .8 ), nrow = 5, byrow = TRUE ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = FALSE ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = "horizontal" ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = "vertical" ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = TRUE # could also be "both" ) # You can modify the plot as you would any ggplot2 object plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = TRUE ) + # Below are example, optional modifications to the default plot ggplot2::ggtitle("Population A") + ggplot2::scale_fill_brewer("Blues") + ggplot2::scale_color_brewer("Blues") + ggplot2::xlab("Individuals") # Note that both scale_fill and scale_color are needed to change the color of the bars. # Plot a dataset which has 2 populations population_B <- matrix( c( .9, 0, .1, .6, .4, 0, .7, 0, .3, .3, .4, .3, .5, .3, .2 ), nrow = 5, byrow = TRUE ) populations_AB <- cbind( data.frame(c( "A", "A", "A", "A", "A", "B", "B", "B", "B", "B" )), rbind(population_A, population_B) ) colnames(populations_AB) <- c("population", "category_1", "category_2", "category_3") plot_signature_prop(relab_matrix = populations_AB, group = "population") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "vertical") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "horizontal") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "both")# Make an example matrix of compositional data # Each row is an individual. Rows sum to 1. population_A <- matrix( c( .5, .3, .2, .4, .2, .4, .5, .4, .1, .6, .1, .3, .2, 0, .8 ), nrow = 5, byrow = TRUE ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = FALSE ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = "horizontal" ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = "vertical" ) plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = TRUE # could also be "both" ) # You can modify the plot as you would any ggplot2 object plot_signature_prop( relab_matrix = population_A, K = 3, # How many categories per vector? arrange = TRUE ) + # Below are example, optional modifications to the default plot ggplot2::ggtitle("Population A") + ggplot2::scale_fill_brewer("Blues") + ggplot2::scale_color_brewer("Blues") + ggplot2::xlab("Individuals") # Note that both scale_fill and scale_color are needed to change the color of the bars. # Plot a dataset which has 2 populations population_B <- matrix( c( .9, 0, .1, .6, .4, 0, .7, 0, .3, .3, .4, .3, .5, .3, .2 ), nrow = 5, byrow = TRUE ) populations_AB <- cbind( data.frame(c( "A", "A", "A", "A", "A", "B", "B", "B", "B", "B" )), rbind(population_A, population_B) ) colnames(populations_AB) <- c("population", "category_1", "category_2", "category_3") plot_signature_prop(relab_matrix = populations_AB, group = "population") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "vertical") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "horizontal") plot_signature_prop(relab_matrix = populations_AB, group = "population", arrange = "both")
Data from: Morton et al. Science (2021)
data(radiation_sigs_morton)data(radiation_sigs_morton)
An object of class data.frame with 356 rows and 16 columns.
Data from: Morton et al. Science (2021)
data(radiation_sigs_morton_cossim)data(radiation_sigs_morton_cossim)
An object of class matrix (inherits from array) with 13 rows and 13 columns.
Data from: Senkin et al. (2023). Geographic variation of mutagenic exposures in kidney cancer genomes. MedRxiv, 14, 2023.06.20.23291538. https://doi.org/10.1101/2023.06.20.23291538
data(rcc_sig_activity)data(rcc_sig_activity)
rcc_sig_activityA dataframe with 962 rows and 31 columns:
Unique sample ID
Country where each sample was collected
Age-standardized rate (ASR) of RCC incidence in each country
Relative abundance of mutational signatures in each sample. These columns sum to 1 for each row.
https://doi.org/10.1101/2023.06.20.23291538
Data from: Senkin et al. (2023). Geographic variation of mutagenic exposures in kidney cancer genomes. MedRxiv, 14, 2023.06.20.23291538. https://doi.org/10.1101/2023.06.20.23291538
data(rcc_sim)data(rcc_sim)
rcc_simA dataframe with 28 rows and 28 columns:
Cosine similarity between mutational signatures.
https://doi.org/10.1101/2023.06.20.23291538
Single Base Substitution mutational signature attributions to COSMIC signatures from the Pan Cancer Whole-Genome consortium (PCAWG). Oct 19 2019 version
data(sbs_palette)data(sbs_palette)
sbs_paletteA vector of RGB color codes for COSMIC SBS signatures.
Data from: Zhang et al. Nat Genet (2021)
data(Sherlock_LCINS_SBS)data(Sherlock_LCINS_SBS)
An object of class spec_tbl_df (inherits from tbl_df, tbl, data.frame) with 232 rows and 15 columns.
Data from: Zhang et al. Nat Genet (2021)
data(Sherlock_LCINS_SBS.refs)data(Sherlock_LCINS_SBS.refs)
An object of class tbl_df (inherits from tbl, data.frame) with 96 rows and 16 columns.
Data from: Zhang et al. Nat Genet (2021)
data(Sherlock_LCINS.metadata)data(Sherlock_LCINS.metadata)
An object of class tbl_df (inherits from tbl, data.frame) with 232 rows and 24 columns.
sigboot uses bootstrapping to evaluate differences in within-sample diversity and across-sample heterogeneity of mutational signature activity between pairs of groups of tumor samples. sigboot takes the same options as sigvar, so, as with sigvar, you can separately analyze multiple populations or groups of samples (specify group), and account for cosine similarity among signatures (specify S). sigboot follows the bootstrapping procedure defined by Efron and Tibshirani (1993). Details on the bootstrapping procedure are available in the Methods section of the accompanying paper.
sigboot( sig_activity, n_replicates, group, K = NULL, S = NULL, w = NULL, time = NULL, normalized = FALSE, seed = NULL, alternative = "two.sided" )sigboot( sig_activity, n_replicates, group, K = NULL, S = NULL, w = NULL, time = NULL, normalized = FALSE, seed = NULL, alternative = "two.sided" )
sig_activity |
A matrix or data frame with |
n_replicates |
The number of bootstrap replicate matrices to generate for each provided relative abundance matrix. |
group |
A string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each sample belongs to. |
K |
Optional; an integer specifying the number of mutational signatures included in |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row (or another continuous, increasing variable). Include if you wish to weight SVA by the temporal distance between samples. |
normalized |
Optional; should the across-sample variability (Fst) be normalized by its upper bound conditional on the mean activity of the most abundant signature be used as the measure of across-sample variability? Default is |
seed |
Optional; an integer to be used as a random seed for the simulations. |
alternative |
Optional; do you want to do a one- or two-sided test? Default is |
A named list containing the following entries:
P_values: The probability of observing the observed difference in variability between each pair of groups if there were no difference between groups. Computed as the fraction of bootstrap differences greater than or equal to the observed difference. Depends on what alternative is specified ("greater", "less", or "two.sided").
bootstrap_distribution_plot: The distribution of bootstrap replicate differences in each variability value. The observed differences are shown in red. The further the red points are from 0, the more significant the statistical difference between groups.
observed_difference: The observed difference in diversity statistics between the groups.
bootstrap_difference: The bootstrap replicate difference in diversity statistics between the groups.
# Estimate the uncertainty in the across-sample and mean within-sample variability of # mutational signatures in ESCC samples grouped by country # We provide a cosine similarity matrix in order to account for cosine similarity among signatures data(smoker_sigs_chen, package = "sigvar") data(smoker_sigs_chen_cossim, package = "sigvar") smoker_boot <- sigboot( sig_activity = smoker_sigs_chen, K = 3, n_replicates = 500, group = "Smoker", S = smoker_sigs_chen_cossim, seed = 1 ) # We find that there is a strong, significant difference between smokers and non-smokers # in their mean within-sample diversity, but that the difference in across-sample heterogeneity # is less strong smoker_boot$P_values # We can visualize this result by looking at the observed differences between # smokers and non-smokers and the bootstrap replicates, which assume no difference # between these two groups smoker_boot$bootstrap_distribution_plot# Estimate the uncertainty in the across-sample and mean within-sample variability of # mutational signatures in ESCC samples grouped by country # We provide a cosine similarity matrix in order to account for cosine similarity among signatures data(smoker_sigs_chen, package = "sigvar") data(smoker_sigs_chen_cossim, package = "sigvar") smoker_boot <- sigboot( sig_activity = smoker_sigs_chen, K = 3, n_replicates = 500, group = "Smoker", S = smoker_sigs_chen_cossim, seed = 1 ) # We find that there is a strong, significant difference between smokers and non-smokers # in their mean within-sample diversity, but that the difference in across-sample heterogeneity # is less strong smoker_boot$P_values # We can visualize this result by looking at the observed differences between # smokers and non-smokers and the bootstrap replicates, which assume no difference # between these two groups smoker_boot$bootstrap_distribution_plot
Across-sample variability is quantified by computing the population-genetic statistic Fst across the rows of the signature activity table. This method is based on the R package FAVA, which implements an Fst-based assessment of Variability across vectors of relative Abundances. Mean within-sample variability is quantified by computing the mean Gini-Simpson index across all samples. Specify group if your table of signature activities contains multiple populations of samples which you wish to compare. Specifying S allows sigvar to account for the pairwise cosine similarity among signatures. Specifying w or time allows for uneven weighting of the samples.
sigvar( sig_activity, K = NULL, group = NULL, S = NULL, w = NULL, time = NULL, normalized = FALSE )sigvar( sig_activity, K = NULL, group = NULL, S = NULL, w = NULL, time = NULL, normalized = FALSE )
sig_activity |
A matrix or data frame with rows containing non-negative entries that sum to 1. Each row represents a sample, each column represents a mutational signature, and each entry represents the abundance of that signature in the sample. If |
K |
Optional; an integer specifying the number of mutational signatures included in |
group |
Optional; a string (or vector of strings) specifying the name(s) of the column(s) that describes which group(s) each sample belongs to. Use if |
S |
Optional; a K x K similarity matrix with diagonal elements equal to 1 and off-diagonal elements between 0 and 1. Entry |
w |
Optional; a vector of length |
time |
Optional; a string specifying the name of the column that describes the sampling time for each row. Include if you wish to weight the variability measures by the distance between adjacent samples in the matrix. |
normalized |
Optional; should normalized Fst be used as the measure of across-sample variability? Default is |
A data frame with columns corresponding to the across-sample variability and the mean within-sample variability for the provided samples.
# Compute the across-sample and mean within-sample variability of mutational signatures # in ESCC samples grouped by country # We provide a cosine similarity matrix in order to account for cosine similarity among signatures data(smoker_sigs_chen, package = "sigvar") data(smoker_sigs_chen_cossim, package = "sigvar") sigvar(sig_activity = smoker_sigs_chen, K = 3, group = "Smoker", S = smoker_sigs_chen_cossim)# Compute the across-sample and mean within-sample variability of mutational signatures # in ESCC samples grouped by country # We provide a cosine similarity matrix in order to account for cosine similarity among signatures data(smoker_sigs_chen, package = "sigvar") data(smoker_sigs_chen_cossim, package = "sigvar") sigvar(sig_activity = smoker_sigs_chen, K = 3, group = "Smoker", S = smoker_sigs_chen_cossim)
Data from: Chen, J., Yang, H., Teo, A.S.M. et al. Genomic landscape of lung adenocarcinoma in East Asians. Nat Genet 52, 177–186 (2020).
data(smoker_sigs_chen)data(smoker_sigs_chen)
smoker_sigs_chenA dataframe with 88 rows and 20 columns:
Unique identifier for each patient
Smoking status for each patient: "Smoker" or "Non-smoker"
Patient metadata
Activity of smoking mutational signature
Activity of APOBEC mutational signature
Activity of ageing mutational signature
https://doi.org/10.1038/s41588-019-0569-6
Data from: Chen, J., Yang, H., Teo, A.S.M. et al. Genomic landscape of lung adenocarcinoma in East Asians. Nat Genet 52, 177–186 (2020).
data(smoker_sigs_chen_cossim)data(smoker_sigs_chen_cossim)
smoker_sigs_chen_cossimA dataframe with 3 rows and 3 columns:
Pairwise cosine similarities between mutational signatures.
https://doi.org/10.1038/s41588-019-0569-6
This function takes a vector of sampling times,
and computes a normalized vector which can be used to weight each sample based on
the time between the subsequent and the preceding samples. The weighting vector
is defined such that each entry, , where and
for not equal to 1 or I. and .
time_weights(times, group = NULL)time_weights(times, group = NULL)
times |
A numeric vector of sampling times. Each entry must be non-negative and greater than the previous entry. |
group |
Optional; a character vector specifying the group identity of each sampling time. Use if there are samples from multiple replicates or subjects in one data set. |
A numeric vector of weights with length equal to the length of times.
Each weight represents the normalized temporal distance between adjacent samples.
Weights sum to 1 when group is NULL, or sum to the number of unique groups
when group is specified.
time_vector = c(1, 8, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 44, 50, 57, 64) time_weights(times = time_vector)time_vector = c(1, 8, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 44, 50, 57, 64) time_weights(times = time_vector)
Data from: Ensembl
data(TP53_context_counts_ordered)data(TP53_context_counts_ordered)
An object of class table of length 96.
Data from: Intogen database
data(TP53_drivers_intogen_LUAD)data(TP53_drivers_intogen_LUAD)
An object of class spec_tbl_df (inherits from tbl_df, tbl, data.frame) with 202 rows and 10 columns.
Data from: Intogen database
data(TP53_drivers_intogen_SBS96)data(TP53_drivers_intogen_SBS96)
An object of class tbl_df (inherits from tbl, data.frame) with 96 rows and 4 columns.
Data from: Zhang et al. (2021). Genomic and evolutionary classification of lung cancer in never smokers. Nature Genetics, 53(9), 1348–1359. https://doi.org/10.1038/s41588-021-00920-0
data(zhang_sig_activity)data(zhang_sig_activity)
zhang_sig_activityA dataframe with 39 rows and 213 columns:
Unique ID for each subject
...
Subject smoking status ("Non-smoker" or "Passive smoker")
...
Relative abundance of mutational signatures in each sample. These columns sum to 1 for each row.
https://doi.org/10.1038/s41588-021-00920-0
Data from: Zhang et al. (2021). Genomic and evolutionary classification of lung cancer in never smokers. Nature Genetics, 53(9), 1348–1359. https://doi.org/10.1038/s41588-021-00920-0
data(zhang_sig_similarity)data(zhang_sig_similarity)
zhang_sig_similarityA dataframe with 14 rows and 14 columns:
Pairwise cosine similarities between mutational signatures.
https://doi.org/10.1038/s41588-021-00920-0