diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml new file mode 100644 index 00000000..ed7650c7 --- /dev/null +++ b/.github/workflows/pkgdown.yaml @@ -0,0 +1,48 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: + +name: pkgdown + +jobs: + pkgdown: + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::pkgdown, local::. + needs: website + + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4.4.1 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.gitignore b/.gitignore index 24ec0037..4654003f 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ inst/extdata/COSMIC_v3.4_SBS_GRCh37.rds inst/extdata/COSMIC_v3.4_SV_GRCh38.rds inst/extdata/human_T2T_gene_info.rds inst/extdata/ce11_gene_info.rds +docs diff --git a/DESCRIPTION b/DESCRIPTION index b6a4debe..e0a31f2d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: sigminer Title: Extract, Analyze and Visualize Mutational Signatures for Genomic Variations -Version: 2.2.2 +Version: 2.3.0 Authors@R: c( person("Shixiang", "Wang", , "w_shixiang@163.com", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-9855-7357")), @@ -26,7 +26,7 @@ Description: Genomic alterations including single nucleotide substitution, extract, analyze and visualize signatures from genomic alteration records, thus providing new insight into cancer study. License: MIT + file LICENSE -URL: https://github.com/ShixiangWang/sigminer +URL: https://github.com/ShixiangWang/sigminer, https://shixiangwang.github.io/sigminer/, https://shixiangwang.github.io/sigminer-book/ BugReports: https://github.com/ShixiangWang/sigminer/issues Depends: R (>= 3.5) diff --git a/R/data.R b/R/data.R index d59e6df2..dcfd4ceb 100644 --- a/R/data.R +++ b/R/data.R @@ -19,6 +19,15 @@ NULL #' data(centromeres.hg38) NULL +#' Location of Centromeres at Genome Build T2T +#' @docType data +#' @name centromeres.T2T +#' @format A data.frame +#' @source from T2T study +#' @examples +#' data(centromeres.T2T) +NULL + #' Location of Centromeres at Genome Build mm10 #' @docType data #' @name centromeres.mm10 @@ -62,6 +71,15 @@ NULL #' data(chromsize.hg38) NULL +#' Chromosome Size of Genome Build T2T +#' @docType data +#' @name chromsize.T2T +#' @format A data.frame +#' @source from T2T study +#' @examples +#' data(chromsize.T2T) +NULL + #' Chromosome Size of Genome Build mm10 #' @docType data #' @name chromsize.mm10 @@ -96,6 +114,15 @@ NULL #' data(cytobands.hg38) NULL +#' Location of Chromosome Cytobands at Genome Build T2T +#' @docType data +#' @name cytobands.T2T +#' @format A data.frame +#' @source from T2T study +#' @examples +#' data(cytobands.T2T) +NULL + #' Location of Chromosome Cytobands at Genome Build mm10 #' @docType data #' @name cytobands.mm10 @@ -130,6 +157,15 @@ NULL #' data(transcript.hg38) NULL +#' Merged Transcript Location at Genome Build T2T +#' @docType data +#' @name transcript.T2T +#' @format A `data.table` +#' @source from T2T study. +#' @examples +#' data(transcript.T2T) +NULL + #' Merged Transcript Location at Genome Build mm10 #' @docType data #' @name transcript.mm10 diff --git a/_pkgdown.yml b/_pkgdown.yml index 4a77b734..9b69d80e 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -9,9 +9,6 @@ template: primary: "#0054AD" border-radius: 0.5rem btn-border-radius: 0.25rem - # params: - # bootswatch: united -destination: docs authors: Shixiang Wang: @@ -126,18 +123,22 @@ reference: - CN.features - centromeres.hg19 - centromeres.hg38 + - centromeres.T2T - centromeres.mm10 - centromeres.mm9 - chromsize.hg19 - chromsize.hg38 + - chromsize.T2T - chromsize.mm10 - - - chromsize.mm9 + - chromsize.mm9 - cytobands.hg19 - cytobands.hg38 + - cytobands.T2T - cytobands.mm10 - cytobands.mm9 - transcript.hg19 - transcript.hg38 + - transcript.T2T - transcript.mm10 - transcript.mm9 - title: Helpers diff --git a/docs/404.html b/docs/404.html deleted file mode 100644 index 60a20e21..00000000 --- a/docs/404.html +++ /dev/null @@ -1,125 +0,0 @@ - - -
- - - - -YEAR: 2019 -COPYRIGHT HOLDER: Shixiang Wang, Xue-Song Liu -- -
Copyright (c) 2019 Shixiang Wang, Xue-Song Liu
-Copyright (c) 2018 Geoffrey Macintyre, Anand Mayakonda
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-vignettes/cnsignature.Rmd
- cnsignature.Rmd
--Exploring copy number signatures with recently developed approach -have been described at The -repertoire of copy number alteration signatures in human cancer.
-A more general introduction please read Extract, -Analyze and Visualize Mutational Signatures with Sigminer.
-
-library(sigminer)
-#> sigminer version 2.2.2
-#> - Star me at https://github.com/ShixiangWang/sigminer
-#> - Run hello() to see usage and citation.
For this analysis, data with six columns are required.
-
-load(system.file("extdata", "toy_segTab.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-set.seed(1234)
-segTabs$minor_cn <- sample(c(0, 1), size = nrow(segTabs), replace = TRUE)
-cn <- read_copynumber(segTabs,
- seg_cols = c("chromosome", "start", "end", "segVal"),
- genome_measure = "wg", complement = TRUE, add_loh = TRUE
-)
-#> ℹ [2023-12-12 17:49:02.252718]: Started.
-#> ℹ [2023-12-12 17:49:02.275248]: Genome build : hg19.
-#> ℹ [2023-12-12 17:49:02.27739]: Genome measure: wg.
-#> ℹ [2023-12-12 17:49:02.279307]: When add_loh is TRUE, use_all is forced to TRUE.
-#> Please drop columns you don't want to keep before reading.
-#> ✔ [2023-12-12 17:49:02.311056]: Chromosome size database for build obtained.
-#> ℹ [2023-12-12 17:49:02.312975]: Reading input.
-#> ✔ [2023-12-12 17:49:02.314494]: A data frame as input detected.
-#> ✔ [2023-12-12 17:49:02.316376]: Column names checked.
-#> ✔ [2023-12-12 17:49:02.324201]: Column order set.
-#> ✔ [2023-12-12 17:49:02.332668]: Chromosomes unified.
-#> ✔ [2023-12-12 17:49:02.352654]: Value 2 (normal copy) filled to uncalled chromosomes.
-#> ✔ [2023-12-12 17:49:02.359564]: Data imported.
-#> ℹ [2023-12-12 17:49:02.3611]: Segments info:
-#> ℹ [2023-12-12 17:49:02.362549]: Keep - 477
-#> ℹ [2023-12-12 17:49:02.363963]: Drop - 0
-#> ✔ [2023-12-12 17:49:02.365851]: Segments sorted.
-#> ℹ [2023-12-12 17:49:02.367199]: Adding LOH labels...
-#> ℹ [2023-12-12 17:49:02.369816]: Joining adjacent segments with same copy number value. Be patient...
-#> ✔ [2023-12-12 17:49:02.500946]: 410 segments left after joining.
-#> ✔ [2023-12-12 17:49:02.502757]: Segmental table cleaned.
-#> ℹ [2023-12-12 17:49:02.504189]: Annotating.
-#> ✔ [2023-12-12 17:49:02.518467]: Annotation done.
-#> ℹ [2023-12-12 17:49:02.520063]: Summarizing per sample.
-#> ✔ [2023-12-12 17:49:02.539559]: Summarized.
-#> ℹ [2023-12-12 17:49:02.541093]: Generating CopyNumber object.
-#> ✔ [2023-12-12 17:49:02.542976]: Generated.
-#> ℹ [2023-12-12 17:49:02.544371]: Validating object.
-#> ✔ [2023-12-12 17:49:02.545781]: Done.
-#> ℹ [2023-12-12 17:49:02.547409]: 0.295 secs elapsed.
-cn
-#> An object of class CopyNumber
-#> =============================
-#> sample n_of_seg n_of_cnv n_of_amp n_of_del n_of_vchr
-#> 1: TCGA-DF-A2KN-01A-11D-A17U-01 34 6 5 1 4
-#> 2: TCGA-19-2621-01B-01D-0911-01 34 8 5 3 5
-#> 3: TCGA-B6-A0X5-01A-21D-A107-01 29 8 4 4 2
-#> 4: TCGA-A8-A07S-01A-11D-A036-01 39 11 2 9 4
-#> 5: TCGA-26-6174-01A-21D-1842-01 44 13 8 5 8
-#> 6: TCGA-CV-7432-01A-11D-2128-01 41 16 7 9 9
-#> 7: TCGA-06-0644-01A-02D-0310-01 47 19 5 14 8
-#> 8: TCGA-A5-A0G2-01A-11D-A042-01 40 21 5 16 10
-#> 9: TCGA-99-7458-01A-11D-2035-01 49 26 10 16 13
-#> 10: TCGA-05-4417-01A-22D-1854-01 53 37 33 4 17
-#> n_loh cna_burden
-#> 1: 15 0.000
-#> 2: 20 0.095
-#> 3: 18 0.083
-#> 4: 21 0.106
-#> 5: 24 0.113
-#> 6: 24 0.188
-#> 7: 33 0.158
-#> 8: 23 0.375
-#> 9: 33 0.304
-#> 10: 29 0.617
-cn@data
-#> chromosome start end segVal sample
-#> 1: chr1 3218923 116319008 2 TCGA-05-4417-01A-22D-1854-01
-#> 2: chr1 116324707 120523902 1 TCGA-05-4417-01A-22D-1854-01
-#> 3: chr1 149879545 247812431 4 TCGA-05-4417-01A-22D-1854-01
-#> 4: chr10 423671 135224372 3 TCGA-05-4417-01A-22D-1854-01
-#> 5: chr11 458784 19461653 3 TCGA-05-4417-01A-22D-1854-01
-#> ---
-#> 406: chr6 1016984 170898549 2 TCGA-DF-A2KN-01A-11D-A17U-01
-#> 407: chr7 746917 158385118 2 TCGA-DF-A2KN-01A-11D-A17U-01
-#> 408: chr8 617885 145225107 2 TCGA-DF-A2KN-01A-11D-A17U-01
-#> 409: chr9 790234 140938075 2 TCGA-DF-A2KN-01A-11D-A17U-01
-#> 410: chrX 1 155270560 2 TCGA-DF-A2KN-01A-11D-A17U-01
-#> minor_cn loh .loh_frac
-#> 1: 1.0000000 FALSE NA
-#> 2: 0.0000000 TRUE NA
-#> 3: 0.5000000 TRUE 0.1175943
-#> 4: 1.0000000 FALSE NA
-#> 5: 1.0000000 FALSE NA
-#> ---
-#> 406: 0.3333333 TRUE 0.9979494
-#> 407: 1.0000000 FALSE NA
-#> 408: 1.0000000 FALSE NA
-#> 409: 0.5000000 TRUE 0.8328715
-#> 410: NA FALSE NA
--If you want to try other type of copy number signatures, change the -method argument.
-
-tally_s <- sig_tally(cn, method = "S")
-#> ℹ [2023-12-12 17:49:02.67201]: Started.
-#> ℹ [2023-12-12 17:49:02.676258]: When you use method 'S', please make sure you have set 'join_adj_seg' to FALSE and 'add_loh' to TRUE in 'read_copynumber() in the previous step!
-#> ✔ [2023-12-12 17:49:02.706049]: Matrix generated.
-#> ℹ [2023-12-12 17:49:02.707747]: 0.036 secs elapsed.
-
-str(tally_s$all_matrices, max.level = 1)
-#> List of 2
-#> $ CN_40: int [1:10, 1:40] 0 0 0 0 0 0 0 0 0 0 ...
-#> ..- attr(*, "dimnames")=List of 2
-#> $ CN_48: int [1:10, 1:48] 0 0 0 0 0 0 0 0 0 0 ...
-#> ..- attr(*, "dimnames")=List of 2
-sig_denovo = sig_auto_extract(tally_s$all_matrices$CN_48)
-#> Select Run 3, which K = 2 as best solution.
-head(sig_denovo$Signature)
-#> Sig1 Sig2
-#> 0:homdel:0-100Kb 0.000000 0.000000e+00
-#> 0:homdel:100Kb-1Mb 0.000000 0.000000e+00
-#> 0:homdel:>1Mb 0.000000 0.000000e+00
-#> 1:LOH:0-100Kb 3.609460 3.819129e-242
-#> 1:LOH:100Kb-1Mb 6.316554 2.814800e-127
-#> 1:LOH:1Mb-10Mb 13.535473 2.784288e-190
This directly calculates the contribution of 19 reference -signatures.
-
-act_refit = sig_fit(t(tally_s$all_matrices$CN_48), sig_index = "ALL", sig_db = "CNS_TCGA")
-#> ℹ [2023-12-12 17:49:03.675575]: Started.
-#> ✔ [2023-12-12 17:49:03.677097]: Signature index detected.
-#> ℹ [2023-12-12 17:49:03.678478]: Checking signature database in package.
-#> ℹ [2023-12-12 17:49:03.694931]: Checking signature index.
-#> ℹ [2023-12-12 17:49:03.699371]: Valid index for db 'CNS_TCGA':
-#> CN1 CN2 CN3 CN4 CN5 CN6 CN7 CN8 CN9 CN10 CN11 CN12 CN13 CN14 CN15 CN16 CN17 CN18 CN19
-#> ✔ [2023-12-12 17:49:03.700851]: Database and index checked.
-#> ✔ [2023-12-12 17:49:03.702355]: Signature normalized.
-#> ℹ [2023-12-12 17:49:03.703705]: Checking row number for catalog matrix and signature matrix.
-#> ✔ [2023-12-12 17:49:03.705038]: Checked.
-#> ℹ [2023-12-12 17:49:03.706365]: Checking rownames for catalog matrix and signature matrix.
-#> ✔ [2023-12-12 17:49:03.707705]: Checked.
-#> ✔ [2023-12-12 17:49:03.709023]: Method 'QP' detected.
-#> ✔ [2023-12-12 17:49:03.715184]: Corresponding function generated.
-#> ℹ [2023-12-12 17:49:03.716575]: Calling function.
-#> ℹ [2023-12-12 17:49:03.718255]: Fitting sample: TCGA-05-4417-01A-22D-1854-01
-#> ℹ [2023-12-12 17:49:03.719948]: Fitting sample: TCGA-06-0644-01A-02D-0310-01
-#> ℹ [2023-12-12 17:49:03.721412]: Fitting sample: TCGA-19-2621-01B-01D-0911-01
-#> ℹ [2023-12-12 17:49:03.722872]: Fitting sample: TCGA-26-6174-01A-21D-1842-01
-#> ℹ [2023-12-12 17:49:03.724322]: Fitting sample: TCGA-99-7458-01A-11D-2035-01
-#> ℹ [2023-12-12 17:49:03.725782]: Fitting sample: TCGA-A5-A0G2-01A-11D-A042-01
-#> ℹ [2023-12-12 17:49:03.727225]: Fitting sample: TCGA-A8-A07S-01A-11D-A036-01
-#> ℹ [2023-12-12 17:49:03.728763]: Fitting sample: TCGA-B6-A0X5-01A-21D-A107-01
-#> ℹ [2023-12-12 17:49:03.730274]: Fitting sample: TCGA-CV-7432-01A-11D-2128-01
-#> ℹ [2023-12-12 17:49:03.73176]: Fitting sample: TCGA-DF-A2KN-01A-11D-A17U-01
-#> ✔ [2023-12-12 17:49:03.733244]: Done.
-#> ℹ [2023-12-12 17:49:03.734592]: Generating output signature exposures.
-#> ✔ [2023-12-12 17:49:03.736503]: Done.
-#> ℹ [2023-12-12 17:49:03.737906]: 0.062 secs elapsed.
We can use some threshold to keep really contributed signautres.
- -For de novo signatures:
-
-show_sig_profile(sig_denovo, mode = "copynumber", method = "S", style = "cosmic")
Show the activity/exposure.
-
-show_sig_exposure(sig_denovo)
For reference signatures, you can just select what you want:
-
-show_sig_profile(
- get_sig_db("CNS_TCGA")$db[, rownames(act_refit2)],
- style = "cosmic",
- mode = "copynumber", method = "S", check_sig_names = FALSE)
Similarly for showing activity.
-
-show_sig_exposure(act_refit2)
NOTE that this case shows relatively large difference with different -approaches, so you need to pick based on your data size/quality and -double-check the results. In general, for small-size data set, the -refitting approach is recommended.
-To assign the de-novo signatures to reference signatures, we use -cosine similarity.
-
-get_sig_similarity(sig_denovo, sig_db = "CNS_TCGA")
-#> -Comparing against COSMIC signatures
-#> ------------------------------------
-#> --Found Sig1 most similar to CN1
-#> Aetiology: See https://cancer.sanger.ac.uk/signatures/cn/ [similarity: 0.706]
-#> --Found Sig2 most similar to CN2
-#> Aetiology: See https://cancer.sanger.ac.uk/signatures/cn/ [similarity: 0.771]
-#> ------------------------------------
-#> Return result invisiblely.
vignettes/sigminer.Rmd
- sigminer.Rmd
Assume you have already gotten a catalog matrix (sample-by-component) -like below:
-
-library(sigminer)
-#> sigminer version 2.2.2
-#> - Star me at https://github.com/ShixiangWang/sigminer
-#> - Run hello() to see usage and citation.
-data("simulated_catalogs")
-mat <- t(simulated_catalogs$set1)
-
-mat[1:5, 1:5]
-#> A[C>A]A A[C>A]C A[C>A]G A[C>A]T C[C>A]A
-#> Sample_1 911 761 88 744 883
-#> Sample_2 195 175 19 174 225
-#> Sample_3 95 51 12 55 142
-#> Sample_4 131 71 14 77 170
-#> Sample_5 33 10 2 14 55
Extract signatures with:
-
-# Here I reduce the values for n_bootstrap and n_nmf_run for reducing the run time. In practice,
-# you should keep default or increase the values for better estimation. The input data here is
-# simulated from 10 mutational signatures
-e1 <- bp_extract_signatures(mat, range = 8:12, n_bootstrap = 5, n_nmf_run = 10)
Check which signature number is proper:
-
-bp_show_survey2(e1, highlight = 10)
-#> Variables can be used: signature_number, silhouette, sample_cosine_distance, L1_error, L2_error, exposure_positive_correlation, signature_similarity_within_cluster, signature_similarity_across_cluster, silhouette_sample
Get the 10
signatures:
-obj <- bp_get_sig_obj(e1, 10)
Show signature profile:
-
-show_sig_profile(obj, mode = "SBS", style = "cosmic")
-Show signature activity (a.k.a. exposure) profile:
-
-show_sig_exposure(obj, rm_space = TRUE)
Calculate the similarity to COSMIC reference signatures:
-
-sim <- get_sig_similarity(obj, sig_db = "SBS")
-#> -Comparing against COSMIC signatures
-#> ------------------------------------
-#> --Found Sig1 most similar to SBS12
-#> Aetiology: Unknown [similarity: 0.932]
-#> --Found Sig2 most similar to SBS13
-#> Aetiology: Activity of APOBEC family of cytidine deaminases [similarity: 0.97]
-#> --Found Sig3 most similar to SBS5
-#> Aetiology: Unknown (clock-like signature) [similarity: 0.95]
-#> --Found Sig4 most similar to SBS3
-#> Aetiology: Defective homologous recombination DNA damage repair [similarity: 0.927]
-#> --Found Sig5 most similar to SBS8
-#> Aetiology: Unknown [similarity: 0.934]
-#> --Found Sig6 most similar to SBS18
-#> Aetiology: Damage by reactive oxygen species [similarity: 0.975]
-#> --Found Sig7 most similar to SBS1
-#> Aetiology: Spontaneous deamination of 5-methylcytosine (clock-like signature) [similarity: 0.76]
-#> --Found Sig8 most similar to SBS6
-#> Aetiology: Defective DNA mismatch repair [similarity: 0.957]
-#> --Found Sig9 most similar to SBS17b
-#> Aetiology: Unknown [similarity: 0.888]
-#> --Found Sig10 most similar to SBS2
-#> Aetiology: Activity of APOBEC family of cytidine deaminases [similarity: 0.986]
-#> ------------------------------------
-#> Return result invisiblely.
Please go to reference -list for well organized functions and documentation.
-For more about mutational signature and sigminer -usage, you can read sigminer-book.
-The cancer genome is shaped by various mutational processes over its lifetime, stemming from exogenous and cell-intrinsic DNA damage, and error-prone DNA replication, leaving behind characteristic mutational spectra, termed mutational signatures. This package, sigminer, helps users to extract, analyze and visualize signatures from genome alteration records, thus providing new insight into cancer study.
-For pipeline tool, please see its co-evolutionary CLI sigflow.
-SBS signatures:
- -Copy number signatures:
- - -DBS signatures:
- -INDEL (i.e. ID) signatures:
- -Genome rearrangement signatures:
- -You can install the stable release of sigminer from CRAN with:
-
-install.packages("BiocManager")
-BiocManager::install("sigminer", dependencies = TRUE)
You can install the development version of sigminer from Github with:
-
-remotes::install_github("ShixiangWang/sigminer", dependencies = TRUE)
-# For Chinese users, run
-remotes::install_git("https://gitee.com/ShixiangWang/sigminer", dependencies = TRUE)
You can also install sigminer from conda bioconda
channel with
A complete documentation of sigminer can be read online at https://shixiangwang.github.io/sigminer-book/. All functions are well organized and documented at https://shixiangwang.github.io/sigminer/reference/index.html. For usage of a specific function fun
, run ?fun
in your R console to see its documentation.
If you use sigminer in academic field, please cite one of the following papers.
-Please properly cite the following references when you are using any corresponding features. The references are also listed in the function documentation. Very thanks to the works, sigminer cannot be created without the giants.
-The software is made available for non commercial research purposes only under the MIT. However, notwithstanding any provision of the MIT License, the software currently may not be used for commercial purposes without explicit written permission after contacting patents’ authors.
-Related patents:
-https://kms.shanghaitech.edu.cn/handle/2MSLDSTB/127042
-MIT © 2019-Present Shixiang Wang, Xue-Song Liu
-MIT © 2018 Anand Mayakonda
-Sigminer v1-v2 are supported by Cancer Biology Group @ShanghaiTech
-NEWS.md
-
-
-get_sig_db("latest_RNA-SBS_GRCh37")
-get_sig_db("latest_SV_GRCh38")
samps
option to show_sig_exposure()
.Example:
-
-
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature exposure
-p1 <- show_sig_exposure(sig2, rm_space = TRUE)
-p1
-
-expo = sig_exposure(sig2)
-show_sig_exposure(expo,
- rm_space = TRUE,
- samps = colnames(expo)[order(colSums(expo))])
read_vcf()
.read_maf_minimal()
to support a minimal MAF-like data as input.sig_tally()
.sigprofiler_extract()
to help generate input matrix file for calling SigProfiler directly.sigprofiler_extract()
.sigprofiler_reorder()
for utils in generating SigProfiler input matrix file with standard mutation types order.latest_CN_GRCh37
(#412).get_sig_similarity()
now uses “SBS” as default reference.show_cn_circos()
.group_enrichment2()
.sig_tally()
.CNS_TCGA
.group_enrichment()
with reference group support.Example:
-
-
-set.seed(1234)
-df <- dplyr::tibble(
- g1 = rep(LETTERS[1:3], c(50, 40, 10)),
- g2 = rep(c("AA", "VV", "XX"), c(50, 40, 10)),
- e1 = sample(c("P", "N"), 100, replace = TRUE),
- e2 = rnorm(100)
-)
-
-x1 = group_enrichment(df, grp_vars = c("g1", "g2"),
- enrich_vars = c("e1", "e2"),
- ref_group = c("B", "VV"))
-x1
read_copynumber_seqz()
to include minor copy number. (Thanks to yancey)range
check in sig_estimate()
. (#391)output_*
function by adding option sig_db
.sigminer::get_genome_annotation()
before loading it.get_pLOH_score()
return nothing for sample without LOH.sig_unify_extract()
as an unified signature extractor.CNS_TCGA
database.y_limits
option in show_sig_profile()
(#381).get_pLOH_score()
for representing the genome that displayed LOH.read_copynumber_ascat()
for reading ASCAT result ASCAT object in .rds
format.get_intersect_size()
for getting overlap size between intervals.get_Aneuploidy_score()
to remove short arms of chr13/14/15/21/22 from calculation.show_sig_feature_corrplot()
(#376).read_vcf()
.sig_tally()
(#370).sigprofiler_extract()
extracting copy number signatures and rolled up sigprofiler version (#369).output_sig()
error in handling exposure plot with >9 signatures (#366).limitsize = FALSE
for ggsave()
or ggsave2()
for handling big figure.mm9
genome build.call_component
.read_vcf()
with ##
commented VCF files.
-
-for (i in c("latest_SBS_GRCh37", "latest_DBS_GRCh37", "latest_ID_GRCh37",
- "latest_SBS_GRCh38", "latest_DBS_GRCh38",
- "latest_SBS_mm9", "latest_DBS_mm9",
- "latest_SBS_mm10", "latest_DBS_mm10",
- "latest_SBS_rn6", "latest_DBS_rn6")) {
- message(i)
- get_sig_db(i)
-}
keep_only_pass
to FALSE
at default.get_sig_rec_similarity()
.output_tally()
and show_catalogue()
.show_group_enrichment()
(#353) & added a new option to cluster rows.bp_show_survey()
.torch
check.read_sv_as_rs()
and sig_tally.RS()
for simplified genome rearrangement classification matrix generation (experimental).bp_extract_signatures()
with lpSolve
package instead of using my problematic code.mm10
in read_vcf()
.bp_extract_signatures()
(#332). PAY ATTENTION: this may affect results.show_sig_profile_loop()
.sig_names
option.https://anaconda.org/bioconda/r-sigminer/
-ms
strategy in sig_auto_extract()
by assigning each signature to its best matched reference signatures.get_shannon_diversity_index()
to get diversity index for signatures (#333).get_sig_exposure()
.bp_get_clustered_sigs()
to get clustered mean signatures.highlight
is added to show_sig_number_survey()
and bp_show_survey2()
to highlight a selected number.cut_p_value
is added to show_group_enrichment()
to cut continous p values as binned regions.sig_extract()
is provided.sig_extract()
and sig_auto_extract()
instead of loading NMF package firstly.auto_reduce
in sig_fit()
is modified from 0.99 to 0.95 and similarity update threshold updated from >0
to >=0.01
.pConstant
option from sig_extract()
and sig_estimate()
. Now a auto-check function is created for avoiding the error from NMF package due to no contribution of a component in all samples.bp_show_survey2()
to plot a simplified version for signature number survey (#330).read_xena_variants()
to read variant data from UCSC Xena as a MAF
object for signature analysis.get_sig_rec_similarity()
for getting reconstructed profile similarity for Signature
object (#293).bp_
which are combined to provide a best practice for extracting signatures in cancer researches. See more details, run ?bp
in your R console.future
warnings.show_cor()
, thanks to @Miachol.y_tr
option in show_sig_profile()
to transform y axis values.read_copynumber()
.
-complement = FALSE
as default.use_all
and complement
.show_sig_bootstrap()
(#298).group_enrichment()
and show_group_enrichment()
(#277).?sigminer
documentation.ms
strategy to select optimal solution by maximizing cosine similarity to reference signatures.same_size_clustering()
for same size clustering.show_cosmic()
to support reading COSMIC signatures in web browser (#288).rel_threshold
behavior in sig_fit()
and get_sig_exposure()
. Made them more consistent and allowed un-assigned signature contribution (#285).SBS_mm9
.data.frame
as input object for sig
in get_sig_similarity()
and sig_fit()
.g_label
option in show_group_distribution()
to better control group names.test
option and variable checking in show_cor()
.output_sig()
to output signature exposure distribution (#280).show_cor()
for general association analysis.show_group_distribution()
to control segments.add_labels()
, thanks to TaoTao for reporting.,
seperated indices in show_cosmic_signatures.set_order
in get_sig_similarity()
(#274).output_sig()
.show_sig_bootstrap_error()
, now it is “Reconstruction error (L2 norm)”auto_reduce
option in sig_fit*
functions to improve signature fitting.sig_fit()
.sig_auto_extract()
to ‘optimal’.get_sig_cancer_type_index()
.sigprofiler_extract()
to reduce failure in when refit
is enabled.output_sig()
.show_group_distribution()
.optimize
option in sig_extract()
and sig_auto_extract()
.,
in sig_fit()
and sig_fit_bootstrap*
functions.output_*
functions from sigflow.sig_tally()
.highlight_genes
in show_cn_group_profile()
to show gene labels.get_sig_cancer_type_index()
to get reference signature index.show_group_distribution()
to show group distribution.show_cn_profile()
to show specified ranges and add copy number value labels.nnls
instead of pracma
for NNLS implementation in sig_fit()
.BSgenome.Hsapiens.1000genomes.hs37d5
in sig_tally()
.MT
to M
in mutation data.show_sig_exposure()
.letter_colors
as an unexported discrete palette.transform_seg_table()
.show_cn_group_profile()
.show_cn_freq_circos()
.sig_orders
option in show_sig_profile()
function now can select and order signatures to plot.show_sig_profile_loop()
for better signature profile visualization.read_copynumber()
, got 200% improvement.read_copynumber()
, got 20% improvement.cosine()
function.get_sig_db()
to let users directly load signature database.sigprofiler_extract()
and sigprofiler_import()
to call SigProfiler and import results.read_vcf()
for simply reading VCF files.show_sig_profile_heatmap()
.read_copynumber_seqz()
to read sequenza result directory.read_copynumber()
.read_maf()
.sig_fit()
to ‘NNLS’ and implement it with pracma package (#216).use_all
option in read_copynumber()
working correctly.MRSE
to RMSE
.show_sig_bootstrap_*()
for plotting aggregated values.get_groups()
for clustering.highlight_size
for show_sig_bootstrap_*()
.sig_fit()
function to better visualize a few samples.lsei
package was removed from CRAN, here I reset default method to ‘QP’ and tried best to keep the LS usage in sigminer (#189).show_sig_profile()
and added input checking for this function.furrr
, solution is from https://github.com/DavisVaughan/furrr/issues/107.sig_fit()
for methods QP
and SA
.show_sig_fit()
and show_sig_bootstrap_*
functions.sig_fit_bootstrap_batch
for more useful in practice.show_groups()
to show the signature contribution in each group from get_groups()
.get_groups()
to result of sig_fit()
.sig_fit_bootstrap_batch()
.sig_tally()
.cores > 1
(#161).sig_fit()
.sig_fit_bootstrap()
for bootstrap results.Imports
to Suggests
.report_bootstrap_p_value()
to report p values.data()
.fuzzyjoin
package from dependency.ggalluvial
package to field suggsets
.All users, this is a break-through version of sigminer, most of functions have been modified, more features are implemented. Please read the reference list to see the function groups and their functionalities.
-Please read the vignette for usage.
-I Hope it helps your research work and makes a new contribution to the scientific community.
-R/data.R
- CN.features.Rd
Classification Table of Copy Number Features Devised by Wang et al. for Method 'W'
-A data.table
with "sigminer.features" class name
Generate from code under data_raw/
-data(CN.features)
S4 class for storing summarized absolute copy number profile.
-data
data.table of absolute copy number calling.
summary.per.sample
data.table of copy number variation summary per sample.
genome_build
genome build version, should be one of 'hg19' or 'hg38'.
genome_measure
Set 'called' will use autosomo called segments size to compute total size -for CNA burden calculation, this option is useful for WES and target sequencing. -Set 'wg' will autosome size from genome build, this option is useful for WGS, SNP etc..
annotation
data.table of annotation for copy number segments.
dropoff.segs
data.table of copy number segments dropped from raw input.
S4 class for storing summarized MAF. It is from maftools
package.
More about MAF object please see maftools.
-data
data.table of MAF file containing all non-synonymous variants.
variants.per.sample
table containing variants per sample
variant.type.summary
table containing variant types per sample
variant.classification.summary
table containing variant classification per sample
gene.summary
table containing variant classification per gene
summary
table with basic MAF summary stats
maf.silent
subset of main MAF containing only silent variants
clinical.data
clinical data associated with each sample/Tumor_Sample_Barcode in MAF.
Add Horizontal Arrow with Text Label to a ggplot
-a ggplot
.
position at x axis.
position at y axis.
text label.
a small space between arrow and text.
vertical adjustment, set to 0 to align with the bottom, -0.5 for the middle, and 1 (the default) for the top.
length of the arrow segment.
length of the arrow.
type of the arrow.
font size.
font family.
font face.
a ggplot
object.
Add text labels to a ggplot object, such as the result -from show_sig_profile.
-add_labels(
- p,
- x,
- y,
- y_end = NULL,
- n_label = NULL,
- labels = NULL,
- revert_order = FALSE,
- font_size = 5,
- font_family = "serif",
- font_face = c("plain", "bold", "italic"),
- ...
-)
a ggplot
.
position at x axis.
position at y axis.
end position of y axis when n_label
is set.
the number of label, when this is set,
-the position of labels at y axis is auto-generated
-according to y
and y_end
.
text labels or a similarity
object from get_sig_similarity.
if TRUE
, revert label order.
font size.
font family.
font face.
other parameters passing to ggplot2::annotate.
a ggplot
object.
# Load mutational signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature profile
-p <- show_sig_profile(sig2, mode = "SBS")
-
-# Method 1
-p1 <- add_labels(p,
- x = 0.75, y = 0.3, y_end = 0.9, n_label = 3,
- labels = paste0("text", 1:3)
-)
-p1
-
-# Method 2
-p2 <- add_labels(p,
- x = c(0.15, 0.6, 0.75), y = c(0.3, 0.6, 0.9),
- labels = paste0("text", 1:3)
-)
-p2
-
-# Method 3
-sim <- get_sig_similarity(sig2)
-p3 <- add_labels(p,
- x = c(0.15, 0.6, 0.75), y = c(0.25, 0.55, 0.8),
- labels = sim, font_size = 2
-)
-p3
R/best_practice.R
- bp.Rd
These functions are combined to provide a best practice for optimally -identifying mutational signatures and attributing their activities (exposures) -in tumor samples. They are listed in order to use.
bp_extract_signatures()
for extracting signatures.
bp_show_survey()
for showing measures change under different
-signature numbers to help user select optimal signature number.
-At default, an aggregated score (named score) is generated to
-suggest the best solution.
bp_show_survey2()
for showing simplified signature number survey like
-show_sig_number_survey()
.
bp_get_sig_obj()
for get a (list of) Signature
object which is common
-used in sigminer for analysis and visualization.
bp_attribute_activity()
for optimizing signature activities (exposures).
-NOTE: the activities from extraction step may be better!
-You can also use sig_extract to get optimal NMF result from multiple NMF runs.
-Besides, you can use sig_fit to quantify exposures based on signatures extracted
-from bp_extract_signatures()
.
bp_extract_signatures_iter()
for extracting signature in a iteration way.
bp_cluster_iter_list()
for clustering (hclust
with average linkage)
-iterated signatures to help collapse
-multiple signatures into one. The result cluster can be visualized by
-plot()
or factoextra::fviz_dend()
.
bp_get_clustered_sigs()
for getting clustered (grouped) mean signatures from signature clusters.
Extra: bp_get_stats
() for obtaining stats for signatures and samples of a solution.
-These stats are aggregated (averaged) as the stats for a solution
-(specific signature number).
Extra: bp_get_rank_score()
for obtaining rank score for all signature numbers.
bp_extract_signatures(
- nmf_matrix,
- range = 2:5,
- n_bootstrap = 20L,
- n_nmf_run = 50,
- RTOL = 0.001,
- min_contribution = 0,
- cores = min(4L, future::availableCores()),
- cores_solution = min(cores, length(range)),
- seed = 123456L,
- handle_hyper_mutation = TRUE,
- report_integer_exposure = FALSE,
- only_core_stats = nrow(nmf_matrix) > 100,
- cache_dir = file.path(tempdir(), "sigminer_bp"),
- keep_cache = FALSE,
- pynmf = FALSE,
- use_conda = TRUE,
- py_path = "/Users/wsx/anaconda3/bin/python"
-)
-
-bp_extract_signatures_iter(
- nmf_matrix,
- range = 2:5,
- sim_threshold = 0.95,
- max_iter = 10L,
- n_bootstrap = 20L,
- n_nmf_run = 50,
- RTOL = 0.001,
- min_contribution = 0,
- cores = min(4L, future::availableCores()),
- cores_solution = min(cores, length(range)),
- seed = 123456L,
- handle_hyper_mutation = TRUE,
- report_integer_exposure = FALSE,
- only_core_stats = nrow(nmf_matrix) > 100,
- cache_dir = file.path(tempdir(), "sigminer_bp"),
- keep_cache = FALSE,
- pynmf = FALSE,
- use_conda = FALSE,
- py_path = "/Users/wsx/anaconda3/bin/python"
-)
-
-bp_cluster_iter_list(x, k = NULL, include_final_iteration = TRUE)
-
-bp_get_clustered_sigs(SigClusters, cluster_label)
-
-bp_get_sig_obj(obj, signum = NULL)
-
-bp_get_stats(obj)
-
-bp_get_rank_score(obj)
-
-bp_show_survey2(
- obj,
- x = "signature_number",
- left_y = "silhouette",
- right_y = "L2_error",
- left_name = left_y,
- right_name = right_y,
- left_color = "black",
- right_color = "red",
- left_shape = 16,
- right_shape = 18,
- shape_size = 4,
- highlight = NULL
-)
-
-bp_show_survey(
- obj,
- add_score = FALSE,
- scales = c("free_y", "free"),
- fixed_ratio = TRUE
-)
-
-bp_attribute_activity(
- input,
- sample_class = NULL,
- nmf_matrix = NULL,
- method = c("bt", "stepwise"),
- bt_use_prop = FALSE,
- return_class = c("matrix", "data.table"),
- use_parallel = FALSE,
- cache_dir = file.path(tempdir(), "sigminer_attribute_activity"),
- keep_cache = FALSE
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
a numeric
vector containing the ranks of factorization to try. Note that duplicates are removed
-and values are sorted in increasing order. The results are notably returned in this order.
number of bootstrapped (resampling) catalogs used.
-When it is 0
, the original (input) mutation catalog is used for NMF decomposition,
-this is not recommended, just for testing, user should not set it to 0
.
number of NMF runs for each bootstrapped or original catalog. -At default, in total n_bootstrap x n_nmf_run (i.e. 1000) NMF runs are used -for the task.
a threshold proposed by Nature Cancer paper to control how to
-filter solutions of NMF. Default is 0.1%
(from reference #2),
-only NMF solutions with KLD (KL deviance) <= 100.1%
minimal KLD are kept.
a component contribution threshold to filer out small -contributed components.
number of cpu cores to run NMF.
cores for processing solutions, default is equal to argument cores
.
a random seed to make reproducible result.
default is TRUE
, handle hyper-mutant samples.
if TRUE
, report integer signature
-exposure by bootstrapping technique.
if TRUE
, only calculate the core stats for signatures and samples.
a directory for keep temp result files.
if TRUE
, keep cache results.
if TRUE
, use Python NMF driver Nimfa.
-The seed currently is not used by this implementation, so the only way to reproduce
-your result is setting keep_cache = TRUE
.
if TRUE
, create an independent conda environment to run NMF.
path to Python executable file, e.g. '/Users/wsx/anaconda3/bin/python'. In my
-test, it is more stable than use_conda=TRUE
. You can install the Nimfa package by yourself
-or set use_conda
to TRUE
to install required Python environment, and then set this option.
a similarity threshold for selecting samples to auto-rerun
-the extraction procedure (i.e. bp_extract_signatures()
), default is 0.95
.
the maximum iteration size, default is 10, i.e., at most run -the extraction procedure 10 times.
result from bp_extract_signatures_iter()
or a list of
-Signature
objects.
an integer sequence specifying the cluster number to get silhouette.
if FALSE
, exclude final iteration result
-from clustering for input from bp_extract_signatures_iter()
, not applied
-if input is a list of Signature
objects.
result from bp_cluster_iter_list()
.
cluster labels for a specified cluster number, obtain it
-from SigClusters$sil_df
.
a ExtractionResult
object from bp_extract_signatures()
.
a integer vector to extract the corresponding Signature
object(s).
-If it is NULL
(default), all will be returned.
column name for left y axis.
column name for right y axis.
label name for left y axis.
label name for right y axis.
color for left axis.
color for right axis.
shape setting.
a integer
to highlight a x
.
if FALSE
, don't show score and label optimal points by
-rank score.
one of "free_y" (default) and "free" to control the scales -of plot facet.
if TRUE
(default), make the x/y axis ratio fixed.
result from bp_extract_signatures()
or a Signature object.
a named string vector whose names are sample names
-and values are class labels (i.e. cancer subtype). If it is NULL
(the default),
-treat all samples as one group.
one of 'bt' (use bootstrap exposure median, from reference #2, -the most recommended way in my personal view) or stepwise' -(stepwise reduce and update signatures then do signature fitting -with last signature sets, from reference #2, the result tends to assign -the contribution of removed signatures to the remaining signatures, -maybe I misunderstand the paper method? PAY ATTENTION).
this parameter is only used for bt
method to reset
-low contributing signature activity (relative activity <0.01
). If TRUE
,
-use empirical P value calculation way (i.e. proportion, used by reference #2
),
-otherwise a t.test
is applied.
string, 'matrix' or 'data.table'.
if TRUE
, use parallel computation based on furrr package.
-It can also be an integer for specifying cores.
It depends on the called function.
-The signature extraction approach is adopted from reference #1, #2, and -the whole best practice is adopted from the pipeline used by reference #3. -I implement the whole procedure with R code based on the method description -of papers. The code is well organized, tested and documented so user will -find it pretty simple and useful. Besides, the structure of the results is -very clear to see and also visualize like other approaches provided by sigminer.
-The survey plot provides a pretty good way to facilitate the signature number
-selection. A score
measure is calculated as the weighted mean of selected
-measures and visualized as the first sub-plot. The optimal number is highlighted
-with red color dot and the best values for each measures are also
-highlighted with orange color dots. The detail of 6 measures shown in plot are
-explained as below.
score
- an aggregated score based on rank scores from selected measures below.
-The higher, the better. When two signature numbers have the same score,
-the larger signature number is preferred (this is a rare situation, you
-have to double check other measures).
silhouette
- the average silhouette width for signatures, also named as ASW in reference #2.
-The signature number with silhouette decreases sharply is preferred.
distance
- the average sample reconstructed cosine distance, the lower value is better.
error
- the average sample reconstructed error calculated with L2 formula
-(i.e. L2 error). This lower value is better. This measure represents a
-similar concept like distance
above, they are all used to quantify how well
-sample mutation profiles can be reconstructed from signatures, but distance
-cares the whole mutation profile similarity while error
here cares value difference.
pos cor
- the average positive signature exposure correlation coefficient.
-The lower value is better. This measure is constructed based on my understanding
-about signatures: mutational signatures are typically treated as independent
-recurrent patterns, so their activities are less correlated.
similarity
- the average similarity within in a signature cluster.
-Like silhouette
, the point decreases sharply is preferred.
-In the practice, results from multiple NMF runs are clustered
-with "clustering with match" algorithm proposed by reference #2. This value
-indicates if the signature profiles extracted from different NMF runs are similar.
Alexandrov, Ludmil B., et al. "Deciphering signatures of mutational processes operative in human cancer." Cell reports 3.1 (2013): 246-259.
-Degasperi, Andrea, et al. "A practical framework and online tool for mutational signature analyses show intertissue variation and driver dependencies." Nature cancer 1.2 (2020): 249-263.
-Alexandrov, Ludmil B., et al. “The repertoire of mutational signatures in human cancer.” Nature 578.7793 (2020): 94-101.
-See sig_estimate, sig_extract, sig_auto_extract, -sigprofiler_extract for other approaches.
data("simulated_catalogs")
-# \donttest{
-# Here I reduce the values for n_bootstrap and n_nmf_run
-# for reducing the run time.
-# In practice, you should keep default or increase the values
-# for better estimation.
-#
-# The input data here is simulated from 10 mutational signatures
-
-# e1 <- bp_extract_signatures(
-# t(simulated_catalogs$set1),
-# range = 8:12,
-# n_bootstrap = 5,
-# n_nmf_run = 10
-# )
-#
-# To avoid computation in examples,
-# Here just load the result
-# (e1$signature and e1$exposure set to NA to reduce package size)
-load(system.file("extdata", "e1.RData", package = "sigminer"))
-
-
-# See the survey for different signature numbers
-# The suggested solution is marked as red dot
-# with highest integrated score.
-p1 <- bp_show_survey(e1)
-p1
-# You can also exclude plotting and highlighting the score
-p2 <- bp_show_survey(e1, add_score = FALSE)
-p2
-
-# You can also plot a simplified version
-p3 <- bp_show_survey2(e1, highlight = 10)
-p3
-
-# Obtain the suggested solution from extraction result
-obj_suggested <- bp_get_sig_obj(e1, e1$suggested)
-obj_suggested
-# If you think the suggested signature number is not right
-# Just pick up the solution you want
-obj_s8 <- bp_get_sig_obj(e1, 8)
-
-# Track the reconstructed profile similarity
-rec_sim <- get_sig_rec_similarity(obj_s8, t(simulated_catalogs$set1))
-rec_sim
-
-# After extraction, you can assign the signatures
-# to reference COSMIC signatures
-# More see ?get_sig_similarity
-sim <- get_sig_similarity(obj_suggested)
-# Visualize the match result
-if (require(pheatmap)) {
- pheatmap::pheatmap(sim$similarity)
-}
-
-# You already got the activities of signatures
-# in obj_suggested, however, you can still
-# try to optimize the result.
-# NOTE: the optimization step may not truly optimize the result!
-expo <- bp_attribute_activity(e1, return_class = "data.table")
-expo$abs_activity
-# }
-
-if (FALSE) {
-# Iterative extraction:
-# This procedure will rerun extraction step
-# for those samples with reconstructed catalog similarity
-# lower than a threshold (default is 0.95)
-e2 <- bp_extract_signatures_iter(
- t(simulated_catalogs$set1),
- range = 9:11,
- n_bootstrap = 5,
- n_nmf_run = 5,
- sim_threshold = 0.99
-)
-e2
-# When the procedure run multiple rounds
-# you can cluster the signatures from different rounds by
-# the following command
-# bp_cluster_iter_list(e2)
-
-## Extra utilities
-rank_score <- bp_get_rank_score(e1)
-rank_score
-stats <- bp_get_stats(e2$iter1)
-# Get the mean reconstructed similarity
-1 - stats$stats_sample$cosine_distance_mean
-}
Location of Centromeres at Genome Build mm10
-A data.frame
-Generate from https://hgdownload.soe.ucsc.edu/goldenPath/mm10/database/gap.txt.gz
-data(centromeres.mm10)
Location of Centromeres at Genome Build mm9
-A data.frame
-Generate from https://hgdownload.soe.ucsc.edu/goldenPath/mm9/database/ -with code:
- -data(centromeres.mm9)
Chromosome Size of Genome Build mm10
-A data.frame
-Generate from UCSC gold path http://hgdownload.cse.ucsc.edu/goldenPath/mm10/bigZips/mm10.chrom.sizes
-data(chromsize.mm10)
Chromosome Size of Genome Build mm9
-A data.frame
-Generate from UCSC gold path http://hgdownload.cse.ucsc.edu/goldenPath/mm9/bigZips/mm9.chrom.sizes
-data(chromsize.mm9)
Calculate Cosine Measures
-cosine(x, y)
a numeric vector or matrix with column representing vector to calculate similarity.
must be same format as x
.
a numeric value or matrix
.
Location of Chromosome Cytobands at Genome Build mm10
-A data.frame
-from UCSC http://hgdownload.cse.ucsc.edu/goldenpath/mm10/database/cytoBand.txt.gz
-data(cytobands.mm10)
Location of Chromosome Cytobands at Genome Build mm9
-A data.frame
-from UCSC http://hgdownload.cse.ucsc.edu/goldenpath/mm9/database/cytoBand.txt.gz
-data(cytobands.mm9)
R/enrich_component_strand_bias.R
- enrich_component_strand_bias.Rd
See sig_tally for examples.
-enrich_component_strand_bias(mat)
a sample-by-component matrix from sig_tally with strand bias labels "T:" and "B:".
a data.table
sorted by p_value
.
R/get_Aneuploidy_score.R
- get_Aneuploidy_score.Rd
This implements a Cohen-Sharir method (see reference) like "Aneuploidy Score" computation. -You can read the source code to see how it works. Basically, it follows -the logic of Cohen-Sharir method but with some difference in detail implementation. -Their results should be counterpart, but with no data validation for now. -Please raise an issue if you find problem/bugs in this function.
-get_Aneuploidy_score(
- data,
- ploidy_df = NULL,
- genome_build = "hg19",
- rm_black_arms = FALSE
-)
a CopyNumber object or a data.frame
containing at least
-'chromosome', 'start', 'end', 'segVal', 'sample' these columns.
default is NULL
, compute ploidy by segment-size weighted copy number
-aross autosome, see get_cn_ploidy. You can also provide a data.frame
with 'sample'
-and 'ploidy' columns.
genome build version, should be 'hg19', 'hg38', 'mm9' or 'mm10'.
if TRUE
, remove short arms of chr13/14/15/21/22 from calculation
-as documented in reference #3.
A data.frame
Cohen-Sharir, Y., McFarland, J. M., Abdusamad, M., Marquis, C., Bernhard, S. V., Kazachkova, M., ... & Ben-David, U. (2021). Aneuploidy renders cancer cells vulnerable to mitotic checkpoint inhibition. Nature, 1-6.
Logic reference: https://github.com/quevedor2/aneuploidy_score/.
Taylor, Alison M., et al. "Genomic and functional approaches to understanding cancer aneuploidy." Cancer cell 33.4 (2018): 676-689.
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-df <- get_Aneuploidy_score(cn)
-df
-
-df2 <- get_Aneuploidy_score(cn@data)
-df2
-
-df3 <- get_Aneuploidy_score(cn@data,
- ploidy_df = get_cn_ploidy(cn@data)
-)
-df3
Setting aes(label=..p.adj..)
in ggpubr::compare_means()
does not
-show adjust p values. The returned result of this function can be combined with ggpubr::stat_pvalue_manual()
to fix
-this problem.
get_adj_p(
- data,
- .col,
- .grp = "Sample",
- comparisons = NULL,
- method = "wilcox.test",
- p.adjust.method = "fdr",
- p.digits = 3L,
- ...
-)
https://github.com/kassambara/ggpubr/issues/143
-a data.frame
containing column for groups and column for comparison.
column name for comparison.
column name for groups.
Default is NULL
, use all combination in group column.
-It can be a list of length-2 vectors. The entries in the vector are either
-the names of 2 values on the x-axis or the 2 integers that correspond to the
-index of the groups of interest, to be compared.
a character string indicating which method to be used for comparing means. -It can be 't.test', 'wilcox.test' etc..
correction method, default is 'fdr'. Run p.adjust.methods
to
-see all available options.
how many significant digits are to be used.
other arguments passed to ggpubr::compare_means()
a data.frame
containing comparison result
More info see ggpubr::compare_means()
, ggpubr::stat_compare_means()
and stats::p.adjust()
.
library(ggpubr)
-# T-test
-stat.test <- compare_means(
- len ~ dose,
- data = ToothGrowth,
- method = "t.test",
- p.adjust.method = "fdr"
-)
-stat.test
-# Create a simple box plot
-p <- ggboxplot(ToothGrowth, x = "dose", y = "len")
-p
-
-# Add p values
-my_comparisons <- list(c("0.5", "1"), c("1", "2"), c("0.5", "2"))
-p + stat_compare_means(method = "t.test", comparisons = my_comparisons)
-
-# Try adding adjust p values
-# proposed by author of ggpubr
-# however it does not work
-p + stat_compare_means(aes(label = ..p.adj..), method = "t.test", comparisons = my_comparisons)
-
-# Solution:
-# calculate adjust p values and their location
-# then use stat_pvalue_manual() function
-p_adj <- get_adj_p(ToothGrowth, .col = "len", .grp = "dose")
-p_adj
-p + stat_pvalue_manual(p_adj, label = "p.adj")
-
-# Show selected comparisons
-# Of note, p value is ajusted
-# for three comparisons, but only
-# two are showed in figure
-p_adj <- get_adj_p(ToothGrowth,
- .col = "len", .grp = "dose",
- comparisons = list(c("0.5", "1"), c("1", "2"))
-)
-p + stat_pvalue_manual(p_adj, label = "p.adj")
R/get_bayesian_result.R
- get_bayesian_result.Rd
Sometimes, we may want to use or inspect specified run result from sig_auto_extract. -This function is designed for this purpose.
-get_bayesian_result(run_info)
a data.frame
with 1 row and two necessary columns Run
and file
.
a list
.
load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-res <- sig_auto_extract(cn_tally_W$nmf_matrix, result_prefix = "Test_copynumber", nrun = 1)
-
-# All run info are stored in res$Raw$summary_run
-# Obtain result of run 1
-res_run1 <- get_bayesian_result(res$Raw$summary_run[1, ])
Get CNV Frequency Table
-get_cn_freq_table(
- data,
- genome_build = "hg19",
- cutoff = 2L,
- resolution_factor = 1L
-)
a CopyNumber
object or a data.frame containing
-at least 'chromosome', 'start', 'end', 'segVal', 'sample' these columns.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
copy number value cutoff for splitting data into AMP and DEL.
-The values equal to cutoff are discarded. Default is 2
, you can also set
-a length-2 vector, e.g. c(2, 2)
.
an integer to control the resolution.
-When it is 1
(default), compute frequency in each cytoband.
-When it is 2
, use compute frequency in each half cytoband.
a data.table
.
Get Ploidy from Absolute Copy Number Profile
-get_cn_ploidy(data)
a CopyNumber object or a data.frame
containing at least 'chromosome', 'start',
-'end', 'segVal' these columns.
a value or a data.table
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-df <- get_cn_ploidy(cn)
-df
Get Genome Annotation
-'chr_size' for chromosome size, -'centro_loc' for location of centromeres, -'cytobands' for location of chromosome cytobands -and 'transcript' for location of transcripts.
chromosomes start with 'chr'
one of 'hg19', 'hg38'
a data.frame
containing annotation data
df1 <- get_genome_annotation()
-df1
-
-df2 <- get_genome_annotation(genome_build = "hg38")
-df2
-
-df3 <- get_genome_annotation(data_type = "centro_loc")
-df3
-
-df4 <- get_genome_annotation(data_type = "centro_loc", genome_build = "hg38")
-df4
-
-df5 <- get_genome_annotation(data_type = "cytobands")
-df5
-
-df6 <- get_genome_annotation(data_type = "cytobands", genome_build = "hg38")
-df6
R/get_group_comparison.R
- get_group_comparison.Rd
Compare genotypes/phenotypes based on signature groups (samples are assigned to
-several groups). For categorical
-type, calculate fisher p value (using stats::fisher.test) and count table.
-In larger than 2 by 2 tables, compute p-values by Monte Carlo simulation.
-For continuous type, calculate anova p value (using stats::aov),
-summary table and Tukey Honest significant difference (using stats::TukeyHSD).
-The result of this function can be plotted by show_group_comparison()
.
get_group_comparison(
- data,
- col_group,
- cols_to_compare,
- type = "ca",
- NAs = NA,
- verbose = FALSE
-)
a data.frame
containing signature groups and genotypes/phenotypes
-(including categorical and continuous type data) want to analyze. User need to
-construct this data.frame
by him/herself.
column name of signature groups.
column names of genotypes/phenotypes want to summarize based on groups.
a characater vector with length same as cols_to_compare
,
-'ca' for categorical type and 'co' for continuous type.
default is NA
, filter NA
s for categorical columns.
-Otherwise a value (either length 1 or length same as cols_to_compare
) fill NA
s.
if TRUE
, print extra information.
a list
contains data, summary, p value etc..
# \donttest{
-load(system.file("extdata", "toy_copynumber_signature_by_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-# Assign samples to clusters
-groups <- get_groups(sig, method = "k-means")
-
-set.seed(1234)
-
-groups$prob <- rnorm(10)
-groups$new_group <- sample(c("1", "2", "3", "4", NA), size = nrow(groups), replace = TRUE)
-
-# Compare groups (filter NAs for categorical coloumns)
-groups.cmp <- get_group_comparison(groups[, -1],
- col_group = "group",
- cols_to_compare = c("prob", "new_group"),
- type = c("co", "ca"), verbose = TRUE
-)
-
-# Compare groups (Set NAs of categorical columns to 'Rest')
-groups.cmp2 <- get_group_comparison(groups[, -1],
- col_group = "group",
- cols_to_compare = c("prob", "new_group"),
- type = c("co", "ca"), NAs = "Rest", verbose = TRUE
-)
-# }
R/get_groups.R
- get_groups.Rd
One of key results from signature analysis is to cluster samples into different
-groups. This function takes Signature
object as input
-and return the membership in each cluster.
get_groups(
- Signature,
- method = c("consensus", "k-means", "exposure", "samples"),
- n_cluster = NULL,
- match_consensus = TRUE
-)
a Signature
object obtained either from sig_extract or sig_auto_extract.
-Now it can be used to relative exposure result in data.table
format from sig_fit.
grouping method, more see details, could be one of the following:
'consensus' - returns the cluster membership based on the hierarchical clustering of the consensus matrix,
-it can only be used for the result obtained by sig_extract()
with multiple runs using NMF package.
'k-means' - returns the clusters by k-means.
'exposure' - assigns a sample into a group whose signature exposure -is dominant.
'samples' - returns the cluster membership based on the contribution of signature to each sample,
-it can only be used for the result obtained by sig_extract()
using NMF package.
only used when the method
is 'k-means'.
only used when the method
is 'consensus'.
-If TRUE
, the result will match order as shown in consensus map.
a data.table
object
Users may find there are bigger differences between using method 'samples' and 'exposure' but -they use a similar idear to find dominant signature, here goes the reason:
-Method 'samples' using data directly from NMF decomposition, this means the two matrix
-W
(basis matrix or signature matrix) and H
(coefficient matrix or exposure matrix) are
-the results of NMF. For method 'exposure', it uses the signature exposure loading matrix.
-In this situation, each signture represents a number of mutations (alterations)
-about implementation please see source code of sig_extract()
function.
# \donttest{
-# Load copy number prepare object
-load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Extract copy number signatures
-library(NMF)
-sig <- sig_extract(cn_tally_W$nmf_matrix, 2,
- nrun = 10
-)
-
-# Methods 'consensus' and 'samples' are from NMF::predict()
-g1 <- get_groups(sig, method = "consensus", match_consensus = TRUE)
-g1
-g2 <- get_groups(sig, method = "samples")
-g2
-
-# Use k-means clustering
-g3 <- get_groups(sig, method = "k-means")
-g3
-# }
R/get_intersect_size.R
- get_intersect_size.Rd
Get Overlap Size between Interval x and y
-get_intersect_size(x.start, x.end, y.start, y.end)
start position of interval x.
start position of interval x.
start position of interval x.
start position of interval x.
a numeric vector.
-R/get_pLOH_score.R
- get_pLOH_score.Rd
pLOH score represents the genome that displayed LOH.
-get_pLOH_score(data, rm_chrs = c("chrX", "chrY"), genome_build = "hg19")
a CopyNumber object or a data.frame
containing at least
-'chromosome', 'start', 'end', 'segVal', "minor_cn", 'sample' these columns.
chromosomes to be removed in calculation. Default is sex -chromosomes (recommended).
genome build version, should be 'hg19', 'hg38', 'mm9' or 'mm10'.
A data.frame
Steele, Christopher D., et al. "Signatures of copy number alterations in human cancer." bioRxiv (2021).
-# \donttest{
-# Load toy dataset of absolute copynumber profile
-load(system.file("extdata", "toy_segTab.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-set.seed(1234)
-segTabs$minor_cn <- sample(c(0, 1), size = nrow(segTabs), replace = TRUE)
-cn <- read_copynumber(segTabs,
- seg_cols = c("chromosome", "start", "end", "segVal"),
- genome_measure = "wg", complement = TRUE, add_loh = TRUE
-)
-
-df <- get_pLOH_score(cn)
-df
-
-df2 <- get_pLOH_score(cn@data)
-df2
-# }
R/get_shannon_diversity_index.R
- get_shannon_diversity_index.Rd
$$H = - \sum_{i=1}^n{p_i ln(p_i)}$$
-where n
is the number
-of signatures identified in the signature with exposure > cutoff
,
-and pi
is the normalized exposure of the ith signature with
-exposure > cutoff
. Exposures of signatures were normalized to
-sum to 1
.
get_shannon_diversity_index(rel_expo, cutoff = 0.001)
a data.frame
with numeric columns indicating
-relative signature exposures for each sample. Typically
-this data can be obtained from get_sig_exposure()
.
a relative exposure cutoff for filtering signatures,
-default is 0.1%
.
a data.frame
Steele, Christopher D., et al. "Undifferentiated sarcomas develop through distinct evolutionary pathways." Cancer Cell 35.3 (2019): 441-456.
-# Load mutational signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Get signature exposure
-rel_expo <- get_sig_exposure(sig2, type = "relative")
-rel_expo
-diversity_index <- get_shannon_diversity_index(rel_expo)
-diversity_index
R/get_sig_cancer_type_index.R
- get_sig_cancer_type_index.Rd
Obtain Signature Index for Cancer Types
-signature type.
sequencing type.
data source.
keyword to search in the signature index database.
a list
.
l1 <- get_sig_cancer_type_index()
-l2 <- get_sig_cancer_type_index(sig_type = "SBS")
-l3 <- get_sig_cancer_type_index(sig_type = "DBS", source = "PCAWG", seq_type = "WGS")
-l4 <- get_sig_cancer_type_index(sig_type = "ID")
-l5 <- get_sig_cancer_type_index(keyword = "breast")
-l1
-l2
-l3
-l4
-l5
Reference mutational signatures and their aetiologies, -mainly obtained from COSMIC database -(SigProfiler results) and cleaned before saving into -sigminer package. You can obtain:
COSMIC legacy SBS signatures.
COSMIC v3 SBS signatures.
COSMIC v3 DBS signatures.
COSMIC v3 ID (indel) signatures.
SBS and RS (rearrangement) signatures from Nik lab 2020 Nature Cancer paper.
RS signatures from BRCA560 and USARC cohorts.
Copy number signatures from USARC cohort and TCGA.
Copy number signatures from Liu lab 2023. It supports both PCAWG and TCGA cohort.
get_sig_db(sig_db = "legacy")
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
a list
.
Steele, Christopher D., et al. "Signatures of copy number alterations in human cancer." Nature 606.7916 (2022): 984-991.
Alexandrov, Ludmil B., et al. "The repertoire of mutational signatures in human cancer." Nature 578.7793 (2020): 94-101.
Steele, Christopher D., et al. "Undifferentiated sarcomas develop through distinct evolutionary pathways." Cancer Cell 35.3 (2019): 441-456.
Ziyu Tao, et al. "The repertoire of copy number alteration signatures in human cancer." Briefings in Bioinformatics (2023): bbad053.
s1 <- get_sig_db()
-s2 <- get_sig_db("SBS")
-s3 <- get_sig_db("DBS")
-s4 <- get_sig_db("DBS_mm10")
-s5 <- get_sig_db("SBS_Nik_lab")
-s6 <- get_sig_db("ID")
-s7 <- get_sig_db("RS_BRCA560")
-s8 <- get_sig_db("RS_USARC")
-s9 <- get_sig_db("RS_Nik_lab")
-s10 <- get_sig_db("CNS_USARC")
-s11 <- get_sig_db("CNS_TCGA")
-s12 <- get_sig_db("CNS_TCGA176")
-s13 <- get_sig_db("CNS_PCAWG176")
-s1
-s2
-s3
-s4
-s5
-s6
-s7
-s8
-s9
-s10
-s11
-s12
-s13
R/get_sig_exposure.R
- get_sig_exposure.Rd
The expected number of mutations (or copy number segment records) with each signature was -determined after a scaling transformation V ~ WH = W'H' where W' = WU' and H' = UH. -The scaling matrix U is a KxK diagnal matrix (K is signature number, U' is the inverse of U) -with the element corresponding to the L1-norm of column vectors of W -(ie. the sum of the elements of the vector). As a result, the k-th row vector of the final -matrix H' represents the absolute exposure (activity) of the k-th process across samples -(e.g., for SBS, the estimated (or expected) number of mutations generated by the k-th process). -Of note, for copy number signatures, only components of feature CN was used for calculating H'.
-get_sig_exposure(
- Signature,
- type = c("absolute", "relative"),
- rel_threshold = 0.01
-)
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw exposure matrix with column representing samples (patients) and row
-representing signatures.
'absolute' for signature exposure and 'relative' for signature relative exposure.
only used when type is 'relative', relative exposure less
-than (<=
) this value will be set to 0 and thus all signature exposures
-may not sum to 1. This is similar to this argument in sig_fit.
a data.table
Kim, Jaegil, et al. "Somatic ERCC2 mutations are associated with a distinct genomic signature in urothelial tumors." -Nature genetics 48.6 (2016): 600.
-# Load mutational signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Get signature exposure
-expo1 <- get_sig_exposure(sig2)
-expo1
-expo2 <- get_sig_exposure(sig2, type = "relative")
-expo2
R/get_sig_feature_association.R
- get_sig_feature_association.Rd
Association of signature exposures with other features will be performed using one of two procedures: -for a continuous association variable (including ordinal variable), correaltion is performed; -for a binary association variable, samples will be divided into two groups and Mann-Whitney U-test -is performed to test for differences in signature exposure medians between the two groups. -See get_tidy_association for cleaning association result.
-get_sig_feature_association(
- data,
- cols_to_sigs,
- cols_to_features,
- type = "ca",
- method_co = c("spearman", "pearson", "kendall"),
- method_ca = stats::wilcox.test,
- min_n = 0.01,
- verbose = FALSE,
- ...
-)
a data.frame
contains signature exposures and other features
colnames for signature exposure
colnames for other features
a character vector containing 'ca' for categorical variable and 'co' for continuous variable,
-it must have the same length as cols_to_features
.
method for continuous variable, default is "spearman", could also be "pearson" and "kendall".
method for categorical variable, default is "wilcox.test"
a minimal fraction (e.g. 0.01) or a integer number (e.g. 10) for filtering some variables with few positive events. -Default is 0.01.
if TRUE
, print extra message.
other arguments passing to test functions, like cor.test
.
a list
. For 'co' features, 'measure' means correlation coefficient.
-For 'ca' features, 'measure' means difference in means of signature exposure.
R/get_reconstructed_similarity.R
- get_sig_rec_similarity.Rd
See bp_extract_signatures for examples.
-get_sig_rec_similarity(Signature, nmf_matrix)
a Signature
object.
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
a data.table
.
R/get_sig_similarity.R
- get_sig_similarity.Rd
The reference signatures can be either a Signature
object specified by Ref
argument
-or known COSMIC signatures specified by sig_db
argument.
-Two COSMIC databases are used for comparisons - "legacy" which includes 30 signaures,
-and "SBS" - which includes updated/refined 65 signatures. This function is modified
-from compareSignatures()
in maftools package.
-NOTE: all reference signatures are generated from gold standard tool:
-SigProfiler.
get_sig_similarity(
- Signature,
- Ref = NULL,
- sig_db = c("SBS", "legacy", "DBS", "ID", "TSB", "SBS_Nik_lab", "RS_Nik_lab",
- "RS_BRCA560", "RS_USARC", "CNS_USARC", "CNS_TCGA", "CNS_TCGA176", "CNS_PCAWG176",
- "SBS_hg19", "SBS_hg38", "SBS_mm9", "SBS_mm10", "DBS_hg19", "DBS_hg38", "DBS_mm9",
- "DBS_mm10", "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ", "latest_SBS_GRCh37",
- "latest_DBS_GRCh37", "latest_ID_GRCh37", "latest_SBS_GRCh38", "latest_DBS_GRCh38",
- "latest_SBS_mm9", "latest_DBS_mm9", "latest_SBS_mm10", "latest_DBS_mm10",
- "latest_SBS_rn6", "latest_DBS_rn6", "latest_CN_GRCh37",
-
- "latest_RNA-SBS_GRCh37", "latest_SV_GRCh38"),
- db_type = c("", "human-exome", "human-genome"),
- method = "cosine",
- normalize = c("row", "feature"),
- feature_setting = sigminer::CN.features,
- set_order = TRUE,
- pattern_to_rm = NULL,
- verbose = TRUE
-)
a Signature
object or a component-by-signature matrix/data.frame
-(sum of each column is 1) or a normalized component-by-sample matrix/data.frame
-(sum of each column is 1).
-More please see examples.
default is NULL
, can be a same object as Signature
.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
only used when sig_db
is enabled.
-"" for keeping default, "human-exome" for transforming to exome frequency of component,
-and "human-genome" for transforming to whole genome frequency of component.
-Currently only works for 'SBS'.
default is 'cosine' for cosine similarity.
one of "row" and "feature". "row" is typically used -for common mutational signatures. "feature" is designed by me to use when input -are copy number signatures.
a data.frame
used for classification.
-Only used when method is "Wang" ("W").
-Default is CN.features. Users can also set custom input with "feature",
-"min" and "max" columns available. Valid features can be printed by
-unique(CN.features$feature)
.
if TRUE
, order the return similarity matrix.
patterns for removing some features/components in similarity
-calculation. A vector of component name is also accepted.
-The remove operation will be done after normalization. Default is NULL
.
if TRUE
, print extra info.
a list
containing smilarities, aetiologies if available, best match and RSS.
Alexandrov, Ludmil B., et al. "The repertoire of mutational signatures in human cancer." Nature 578.7793 (2020): 94-101.
-Degasperi, Andrea, et al. "A practical framework and online tool for mutational signature analyses show intertissue variation and driver dependencies." Nature cancer 1.2 (2020): 249-263.
-Steele, Christopher D., et al. "Undifferentiated sarcomas develop through distinct evolutionary pathways." Cancer Cell 35.3 (2019): 441-456.
-Nik-Zainal, Serena, et al. "Landscape of somatic mutations in 560 breast cancer whole-genome sequences." Nature 534.7605 (2016): 47-54.
-Steele, Christopher D., et al. "Signatures of copy number alterations in human cancer." Nature 606.7916 (2022): 984-991.
-# Load mutational signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-s1 <- get_sig_similarity(sig2, Ref = sig2)
-s1
-
-s2 <- get_sig_similarity(sig2)
-s2
-s3 <- get_sig_similarity(sig2, sig_db = "SBS")
-s3
-
-# Set order for result similarity matrix
-s4 <- get_sig_similarity(sig2, sig_db = "SBS", set_order = TRUE)
-s4
-
-## Remove some components
-## in similarity calculation
-s5 <- get_sig_similarity(sig2,
- Ref = sig2,
- pattern_to_rm = c("T[T>G]C", "T[T>G]G", "T[T>G]T")
-)
-s5
-
-## Same to DBS and ID signatures
-x1 <- get_sig_db("DBS_hg19")
-x2 <- get_sig_db("DBS_hg38")
-s6 <- get_sig_similarity(x1$db, x2$db)
-s6
R/get_tidy_association.R
- get_tidy_association.Rd
Get Tidy Signature Association Results
-get_tidy_association(cor_res, p_adjust = FALSE, method = "fdr")
data returned by get_sig_feature_association()
logical, if TRUE
, adjust p values by data type.
p value correction method, see stats::p.adjust for -more detail.
a data.frame
This function takes a data.frame
as input, compares proportion of positive
-cases or mean measure in one subgroup and the remaining samples.
group_enrichment(
- df,
- grp_vars = NULL,
- enrich_vars = NULL,
- cross = TRUE,
- co_method = c("t.test", "wilcox.test"),
- ref_group = NA
-)
a data.frame
.
character vector specifying group variables to split samples -into subgroups (at least 2 subgroups, otherwise this variable will be skipped).
character vector specifying measure variables to be compared.
-If variable is not numeric, only binary cases are accepted in the form of
-TRUE/FALSE
or P/N
(P for positive cases and N for negative cases).
-Of note, NA
values set to negative cases.
logical, default is TRUE
, combine all situations provided by
-grp_vars
and enrich_vars
. For examples, c('A', 'B')
and c('C', 'D')
-will construct 4 combinations(i.e. "AC", "AD", "BC" and "BD"). A variable can
-not be in both grp_vars
and enrich_vars
, such cases will be automatically
-drop. If FALSE
, use pairwise combinations, see section "examples" for use cases.
test method for continuous variable, default is 't.test'.
reference group set in grp_vars
.
a data.table
with following columns:
grp_var
: group variable name.
enrich_var
: enrich variable (variable to be compared) name.
grp1
: the first group name, should be a member in grp_var
column.
grp2
: the remaining samples, marked as 'Rest'.
grp1_size
: sample size for grp1
.
grp1_pos_measure
: for binary variable, it stores the proportion of
-positive cases in grp1
; for continuous variable, it stores mean value.
grp2_size
: sample size for grp2
.
grp2_pos_measure
: same as grp1_pos_measure
but for grp2
.
measure_observed
: for binary variable, it stores odds ratio;
-for continuous variable, it stores scaled mean ratio.
measure_tested
: only for binary variable, it stores
-estimated odds ratio and its 95% CI from fisher.test()
.
p_value
: for binary variable, it stores p value from fisher.test()
;
-for continuous variable, it stores value from wilcox.test()
or t.test()
.
type
: one of "binary" and "continuous".
method
: one of "fish.test", "wilcox.test" and "t.test".
set.seed(1234)
-df <- dplyr::tibble(
- g1 = factor(abs(round(rnorm(99, 0, 1)))),
- g2 = rep(LETTERS[1:4], c(50, 40, 8, 1)),
- e1 = sample(c("P", "N"), 99, replace = TRUE),
- e2 = rnorm(99)
-)
-
-print(str(df))
-print(head(df))
-
-# Compare g1:e1, g1:e2, g2:e1 and g2:e2
-x1 <- group_enrichment(df, grp_vars = c("g1", "g2"), enrich_vars = c("e1", "e2"))
-x1
-
-# Only compare g1:e1, g2:e2
-x2 <- group_enrichment(df,
- grp_vars = c("g1", "g2"),
- enrich_vars = c("e1", "e2"),
- co_method = "wilcox.test",
- cross = FALSE
-)
-x2
-
-# \donttest{
-# Visualization
-p1 <- show_group_enrichment(x1, fill_by_p_value = TRUE)
-p1
-p2 <- show_group_enrichment(x1, fill_by_p_value = FALSE)
-p2
-p3 <- show_group_enrichment(x1, return_list = TRUE)
-p3
-# }
More details see group_enrichment()
.
group_enrichment2(
- df,
- subset_var,
- grp_vars,
- enrich_vars,
- co_method = c("t.test", "wilcox.test"),
- ref_group = NA
-)
a data.frame
.
a column for subsetting.
character vector specifying group variables to split samples -into subgroups (at least 2 subgroups, otherwise this variable will be skipped).
character vector specifying measure variables to be compared.
-If variable is not numeric, only binary cases are accepted in the form of
-TRUE/FALSE
or P/N
(P for positive cases and N for negative cases).
-Of note, NA
values set to negative cases.
test method for continuous variable, default is 't.test'.
reference group set in grp_vars
.
This can be used for SNV/INDEL count matrix. For copy number analysis, -please skip it.
-handle_hyper_mutation(nmf_matrix)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
a matrix
.
Kim, Jaegil, et al. "Somatic ERCC2 mutations are associated with a distinct genomic signature in urothelial tumors." -Nature genetics 48.6 (2016): 600.
-Say Hello to Users
-hello()
hello()
- Data input, classes and operation-Read genomic variation data as an R object and more. - |
- |
---|---|
- - | -Read Absolute Copy Number Profile |
-
- - | -Read Absolute Copy Number Profile from Sequenza Result Directory |
-
- - | -Read Copy Number Data from ASCAT Result Files |
-
- - | -Read MAF Files |
-
- - | -Read Structural Variation Data as RS object |
-
- - | -Read VCF Files as MAF Object |
-
- - | -Read UCSC Xena Variant Format Data as MAF Object |
-
- - | -Class CopyNumber |
-
- - | -Class MAF |
-
- - | -Subsetting CopyNumber object |
-
- Core pipeline 1 - de novo signature identification-Identify signatures from genomic variation profile. After reading data, the following functions construct the standard pipeline for most users. - |
- |
- - | -Tally a Genomic Alteration Object |
-
- - | -Handle Hypermutant Samples |
-
-
|
- Estimate Signature Number |
-
- - | -An Unified Interface to Extract Signatures |
-
- - | -Extract Signatures through NMF |
-
- - | -Extract Signatures through the Automatic Relevance Determination Technique |
-
-
|
- Extract Signatures with SigProfiler |
-
-
|
- A Best Practice for Signature Extraction and Exposure (Activity) Attribution |
-
- Core pipeline 2 - signature exposure fitting and optimization-Quantify exposure in at least one sample with reference signatures. It can also be used to optimize signature exposure from pipeline 1 and analyze exposure instability. - |
- |
- - | -Tally a Genomic Alteration Object |
-
- - | -Handle Hypermutant Samples |
-
- - | -Obtain Signature Index for Cancer Types |
-
- - | -Fit Signature Exposures with Linear Combination Decomposition |
-
- - | -Obtain Bootstrap Distribution of Signature Exposures of a Certain Tumor Sample |
-
- - | -Exposure Instability Analysis of Signature Exposures with Bootstrapping |
-
- - | -Report P Values from bootstrap Results |
-
- Signature visualization-Show signature profile and exposure. - |
- |
- - | -Show Alteration Catalogue Profile |
-
- - | -Show Signature Profile |
-
- - | -Show Signature Profile with Loop Way |
-
- - | -Show Signature Profile with Heatmap |
-
- - | -Plot Signature Exposure |
-
- - | -Show Signature Information in Web Browser |
-
- - | -Plot Reference (Mainly COSMIC) Signature Profile |
-
- - | -Show Signature Consensus Map |
-
- Fit and bootstrap visualization-Show signature fit and bootstrap analysis results. - |
- |
- - | -Show Signature Fit Result |
-
-
|
- Show Signature Bootstrap Analysis Results |
-
- Output analysis results to local machine-Save results and plots as files. For automatic analysis, please use sigflow. - |
- |
- - | -Output Tally Result in Barplots |
-
- - | -Output Signature Results |
-
- - | -Output Signature Fitting Results |
-
- - | -Output Signature Bootstrap Fitting Results |
-
- Signature object operation-Obtain or modify |
- |
-
|
- Obtain or Modify Signature Information |
-
- Signature analysis and corresponding visualization-Analyze signatures and output the result to visualization. - |
- |
- - | -Calculate Similarity between Identified Signatures and Reference Signatures |
-
- - | -Get Reconstructed Profile Cosine Similarity, RSS, etc. |
-
- - | -Get Signature Exposure from 'Signature' Object |
-
- - | -Calculate Association between Signature Exposures and Other Features |
-
- - | -Get Tidy Signature Association Results |
-
- - | -A Simple and General Way for Association Analysis |
-
- - | -Draw Corrplot for Signature Exposures and Other Features |
-
- - | -Show Signature Contribution in Clusters |
-
- - | -Get Sample Groups from Signature Decomposition Information |
-
- - | -Get Comparison Result between Signature Groups |
-
- - | -Plot Group Comparison Result |
-
- - | -General Group Enrichment Analysis |
-
- - | -Show Group Enrichment Result |
-
- - | -Group Enrichment Analysis with Subsets |
-
- - | -Show Groupped Variable Distribution |
-
- - | -Map Groups using Sankey |
-
- - | -Performs Strand Bias Enrichment Analysis for a Given Sample-by-Component Matrix |
-
-
|
- Simulation Analysis |
-
- - | -Get Shannon Diversity Index for Signatures |
-
- Package datasets-Datasets used for signature identification and analysis (some stored in |
- |
- - | -A List of Simulated SBS-96 Catalog Matrix |
-
- - | -Classification Table of Copy Number Features Devised by Wang et al. for Method 'W' |
-
- - | -Location of Centromeres at Genome Build hg19 |
-
- - | -Location of Centromeres at Genome Build hg38 |
-
- - | -Location of Centromeres at Genome Build mm10 |
-
- - | -Location of Centromeres at Genome Build mm9 |
-
- - | -Chromosome Size of Genome Build hg19 |
-
- - | -Chromosome Size of Genome Build hg38 |
-
- - | -Chromosome Size of Genome Build mm10 |
-
- - | -Chromosome Size of Genome Build mm9 |
-
- - | -Location of Chromosome Cytobands at Genome Build hg19 |
-
- - | -Location of Chromosome Cytobands at Genome Build hg38 |
-
- - | -Location of Chromosome Cytobands at Genome Build mm10 |
-
- - | -Location of Chromosome Cytobands at Genome Build mm9 |
-
- - | -Merged Transcript Location at Genome Build hg19 |
-
- - | -Merged Transcript Location at Genome Build hg38 |
-
- - | -Merged Transcript Location at Genome Build mm10 |
-
- - | -Merged Transcript Location at Genome Build mm9 |
-
- Helpers-Helper functions used in the sigminer package. - |
- |
- - | -Get Curated Reference Signature Database |
-
- - | -Convert Signatures between different Genomic Distribution of Components |
-
- - | -Get Genome Annotation |
-
- - | -Get Specified Bayesian NMF Result from Run |
-
- - | -Get Adjust P Values from Group Comparison |
-
- - | -Set Color Style for Plotting |
-
- - | -Add Horizontal Arrow with Text Label to a ggplot |
-
- - | -Add Text Labels to a ggplot |
-
- - | -Calculate Cosine Measures |
-
- - | -Get CNV Frequency Table |
-
- - | -Same Size Clustering |
-
- - | -Get Overlap Size between Interval x and y |
-
- Copy number analysis and visualization-Functions for analyzing copy number data and visualization. - |
- |
- - | -Transform Copy Number Table |
-
- - | -Get Ploidy from Absolute Copy Number Profile |
-
- - | -Get Aneuploidy Score from Copy Number Profile |
-
- - | -Get proportions of pLOH score from Allele Specific Copy Number Profile |
-
- - | -Score Copy Number Profile |
-
- - | -Show Sample Copy Number Profile |
-
- - | -Show Copy Number Profile in Circos |
-
- - | -Show Summary Copy Number Profile for Sample Groups |
-
- - | -Show Copy Number Variation Frequency Profile with Circos |
-
- - | -Show Copy Number Distribution either by Length or Chromosome |
-
- - | -Show Copy Number Feature Distributions |
-
- - | -Show Copy Number Components |
-
- Extra documentation-Extra function and introduction. - |
- |
- - | -Say Hello to Users |
-
- - | -sigminer: Extract, Analyze and Visualize Signatures for Genomic Variations |
-
Output Signature Bootstrap Fitting Results
-output_bootstrap(x, result_dir, mut_type = "SBS", sig_db = mut_type)
result from sig_fit_bootstrap_batch.
a result directory.
one of 'SBS', 'DBS', 'ID' or 'CN'.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
Nothing.
-Output Signature Fitting Results
-output_fit(x, result_dir, mut_type = "SBS", sig_db = mut_type)
result from sig_fit.
a result directory.
one of 'SBS', 'DBS', 'ID' or 'CN'.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
Nothing.
-Output Signature Results
-output_sig(sig, result_dir, mut_type = "SBS", sig_db = mut_type)
a Signature
object.
a result directory.
one of 'SBS', 'DBS', 'ID' or 'CN'.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
Nothing.
-Output Tally Result in Barplots
-output_tally(x, result_dir, mut_type = "SBS")
a matrix with row representing components (motifs) and column -representing samples.
a result directory.
one of 'SBS', 'DBS', 'ID' or 'CN'.
Nothing.
-See magrittr::%>%
for details.
lhs %>% rhs
Read absolute copy number profile for preparing CNV signature
-analysis. See detail part of sig_tally()
to see how to handle sex to get correct
-summary.
read_copynumber(
- input,
- pattern = NULL,
- ignore_case = FALSE,
- seg_cols = c("Chromosome", "Start.bp", "End.bp", "modal_cn"),
- samp_col = "sample",
- add_loh = FALSE,
- loh_min_len = 10000,
- loh_min_frac = 0.05,
- join_adj_seg = TRUE,
- skip_annotation = FALSE,
- use_all = add_loh,
- min_segnum = 0L,
- max_copynumber = 20L,
- genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
- genome_measure = c("called", "wg"),
- complement = FALSE,
- ...
-)
a data.frame
or a file or a directory contains copy number profile.
an optional regular expression used to select part of files if
-input
is a directory, more detail please see list.files()
function.
logical. Should pattern-matching be case-insensitive?
four strings used to specify chromosome, start position,
-end position and copy number value in input
, respectively.
-Default use names from ABSOLUTE calling result.
a character used to specify the sample column name. If input
-is a directory and cannot find samp_col
, sample names will use file names
-(set this parameter to NULL
is recommended in this case).
if TRUE
, add LOH labels to segments. NOTE a column
-'minor_cn' must exist to indicate minor allele copy number value.
-Sex chromosome will not be labeled.
The length cut-off for labeling a segment as 'LOH'.
-Default is 10Kb
.
When join_adj_seg
set to TRUE
, only the length fraction
-of LOH region is larger than this value will be labeled as 'LOH'.
-Default is 30%.
if TRUE
(default), join adjacent segments with
-same copy number value. This is helpful for precisely count the number of breakpoint.
-When set use_all=TRUE
, the mean function will be applied to extra numeric columns
-and unique string columns will be pasted by comma for joined records.
if TRUE
, skip annotation step, it may affect some analysis
-and visualization functionality, but speed up reading data.
default is FALSE
. If True
, use all columns from raw input.
minimal number of copy number segments within a sample.
bigger copy number within a sample will be reset to this value.
genome build version, should be 'hg19', 'hg38', 'mm9' or 'mm10'.
default is 'called', can be 'wg' or 'called'. -Set 'called' will use called segments size to compute total size for CNA burden calculation, -this option is useful for WES and target sequencing. -Set 'wg' will use autosome size from genome build, this option is useful for WGS, SNP etc..
if TRUE
, complement chromosome (except 'Y') does not show in input data
-with normal copy 2.
other parameters pass to data.table::fread()
a CopyNumber object.
-# Load toy dataset of absolute copynumber profile
-load(system.file("extdata", "toy_segTab.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-# \donttest{
-cn <- read_copynumber(segTabs,
- seg_cols = c("chromosome", "start", "end", "segVal"),
- genome_build = "hg19", complement = FALSE
-)
-cn
-cn_subset <- subset(cn, sample == "TCGA-DF-A2KN-01A-11D-A17U-01")
-
-# Add LOH
-set.seed(1234)
-segTabs$minor_cn <- sample(c(0, 1), size = nrow(segTabs), replace = TRUE)
-cn <- read_copynumber(segTabs,
- seg_cols = c("chromosome", "start", "end", "segVal"),
- genome_measure = "wg", complement = TRUE, add_loh = TRUE
-)
-# Use tally method "S" (Steele et al.)
-tally_s <- sig_tally(cn, method = "S")
-
-tab_file <- system.file("extdata", "metastatic_tumor.segtab.txt",
- package = "sigminer", mustWork = TRUE
-)
-cn2 <- read_copynumber(tab_file)
-cn2
-# }
R/read_copynumber_ascat.R
- read_copynumber_ascat.Rd
Note, the result is not a CopyNumber
object, you need to generate it
-by yourself.
read_copynumber_ascat(x)
one or more .rds
format files which contains ASCAT
object from result of ascat.runAscat()
-in ASCAT package.
a tidy list
.
R/read_copynumber_seqz.R
- read_copynumber_seqz.Rd
Read Absolute Copy Number Profile from Sequenza Result Directory
-read_copynumber_seqz(target_dir, return_df = FALSE, ...)
a directory path.
if TRUE
, return a data.frame
directly, otherwise return a
-CopyNumber object.
other parameters passing to read_copynumber()
.
a data.frame
or a CopyNumber
object.
This function is a wrapper of maftools::read.maf. -Useless options in maftools::read.maf are dropped here. -You can also use maftools::read.maf to read the data. -All reference alleles and mutation alleles should be recorded in -positive strand format.
-read_maf(maf, verbose = TRUE)
-
-read_maf_minimal(dt)
tab delimited MAF file. File can also be gz compressed. Required. Alternatively, you can also provide already read MAF file as a dataframe.
TRUE logical. Default to be talkative and prints summary.
A data.frame contains at least the following columns: -"Tumor_Sample_Barcode", "Chromosome", "Start_Position", "End_Position", "Reference_Allele", "Tumor_Seq_Allele2"
read_maf_minimal()
: Read Maf data.frame from a minimal maf-like data
read_copynumber for reading copy number data to CopyNumber object.
# \donttest{
-laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools", mustWork = TRUE)
-if (!require("R.utils")) {
- message("Please install 'R.utils' package firstly")
-} else {
- laml <- read_maf(maf = laml.maf)
- laml
-
- laml_mini <- laml@data[, list(
- Tumor_Sample_Barcode, Chromosome,
- Start_Position, End_Position,
- Reference_Allele, Tumor_Seq_Allele2
- )]
- laml2 <- read_maf_minimal(laml_mini)
- laml2
-}
-# }
Read Structural Variation Data as RS object
-read_sv_as_rs(input)
a data.frame
or a file with the following columns:
-"sample", "chr1", "start1", "end1", "chr2", "start2", "end2", "strand1", "strand2", "svclass".
-NOTE: If column "svclass" already exists in input, "strand1" and "strand2" are optional.
-If "svclass" is not provided, read_sv_as_rs()
will compute it by
-"strand1","strand2"(strand1/strand2),"chr1" and "chr2":
translocation, if mates are on different chromosomes.
inversion (+/-) and (-/+), if mates on the same chromosome.
deletion (+/+), if mates on the same chromosome.
tandem-duplication (-/-), if mates on the same chromosome.
a list
MAF file is more recommended. In this function, we will mimic
-the MAF object from the key c(1, 2, 4, 5, 7)
columns of VCF file.
read_vcf(
- vcfs,
- samples = NULL,
- genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
- keep_only_pass = FALSE,
- verbose = TRUE
-)
VCF file paths.
sample names for VCF files.
genome build version like "hg19".
if TRUE
, keep only 'PASS' mutation for analysis.
if TRUE
, print extra info.
a MAF.
-vcfs <- list.files(system.file("extdata", package = "sigminer"), "*.vcf", full.names = TRUE)
-# \donttest{
-maf <- read_vcf(vcfs)
-maf <- read_vcf(vcfs, keep_only_pass = TRUE)
-# }
Read UCSC Xena Variant Format Data as MAF Object
-read_xena_variants(path)
a path to variant file.
a MAF
object.
# \donttest{
-if (requireNamespace("UCSCXenaTools")) {
- library(UCSCXenaTools)
- options(use_hiplot = TRUE)
- example_file <- XenaGenerate(subset = XenaDatasets == "mc3/ACC_mc3.txt") %>%
- XenaQuery() %>%
- XenaDownload()
- x <- read_xena_variants(example_file$destfiles)
- x@data
- y <- sig_tally(x)
- y
-}
-# }
R/sig_fit_bootstrap.R
- report_bootstrap_p_value.Rd
See examples in sig_fit_bootstrap.
-report_bootstrap_p_value(x, thresholds = c(0.01, 0.05, 0.1))
a (list of) result from sig_fit_bootstrap.
a vector of relative exposure threshold for calculating p values.
a (list of) matrix
This is a wrapper for several implementation that classify samples into -same size clusters, the details please see this blog. -The source code is modified based on code from the blog.
-a data/distance matrix.
if TRUE
, treat mat
as a distance matrix.
integer, number of sample within a cluster.
algorithm.
method.
a vector.
-set.seed(1234L)
-x <- rbind(
- matrix(rnorm(100, sd = 0.3), ncol = 2),
- matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2)
-)
-colnames(x) <- c("x", "y")
-
-y1 <- same_size_clustering(x, clsize = 10)
-y11 <- same_size_clustering(as.matrix(dist(x)), clsize = 10, diss = TRUE)
-
-y2 <- same_size_clustering(x, clsize = 10, algo = "hcbottom", method = "ward.D")
-
-y3 <- same_size_clustering(x, clsize = 10, algo = "kmvar")
-y33 <- same_size_clustering(as.matrix(dist(x)), clsize = 10, algo = "kmvar", diss = TRUE)
Returns quantification of copy number profile and events including -tandem duplication and Chromothripisis etc. -Only copy number data from autosome is used here. -Some of the quantification methods are rough, -you use at your risk. You should do some extra work to check the -result scores.
-scoring(object, TD_size_cutoff = c(1000, 100000, 2000000), TD_cn_cutoff = Inf)
a object of CopyNumber.
a length-3 numeric vector used to specify the start, midpoint, end -segment size for determining tandem duplication size range, midpoint is used to split -TD into short TD and long TD. Default is 1Kb to 100Kb for short TD, 100Kb to 2Mb for long -TD.
a number defining the maximum copy number of TD,
-default is Inf
, i.e. no cutoff.
a data.table
with following scores:
cnaBurden: CNA burden representing the altered genomic fraction as previously reported.
cnaLoad: CNA load representing the quantity of copy number alteration.
MACN: mean altered copy number (MACN) reflecting the property of altered copy number segments, -calculated as -$$MACN = \frac{\sum_{i} CN_i}{N_{cnv}}$$ -where \(CN_i\) is the copy number of altered segment \(i\), \(N_{cnv}\) is -the number of CNV.
weightedMACN: same as MACN but weighted with segment length. -$$MACN_{weighted} = \frac{\sum_{i} (CN_i \times L_{i})}{ \sum_{i} L_{i} }$$ -where \(L_{i}\) is the length of altered copy number segment \(i\).
Ploidy: ploidy, the formula is same as weightedMACN
but using all copy number segments instead of
-altered copy number segments.
TDP_pnas: tandem duplication phenotype score from https://www.pnas.org/doi/10.1073/pnas.1520010113
,
-the threshold k
in reference is omitted.
-$$TDP = - \frac{\sum_{chr} |TD_{obs}-TD_{exp}|}{TD_{total}}$$
-where \(TD_{total}\) is the number of TD, \(TD_{obs}\) and
-\(TD_exp\) are observed number of TD and expected number of TD for each chromosome.
TDP: tandem duplication score used defined by our group work, -TD represents segment with copy number greater than 2. -$$TD = \frac{TD_{total}}{\sum_{chr} |TD_{obs}-TD_{exp}|+1}$$
sTDP: TDP score for short TD.
lTDP: TDP score for long TD.
TDP_size : TDP region size (Mb).
sTDP_size: sTDP region size (Mb).
lTDP_size: lTDP region size(Mb).
Chromoth_state: chromothripsis state score, -according to reference doi:10.1016/j.cell.2013.02.023 -, -chromothripsis frequently leads to massive loss of segments on -the affected chromosome with segmental losses being interspersed with regions displaying -normal (disomic) copy-number (e.g., copy-number states oscillating between -copy-number = 1 and copy-number = 2), form tens to hundreds of locally clustered DNA rearrangements. -Most of methods use both SV and CNV to infer chromothripsis, here we roughly quantify it with -$$\sum_{chr}{N_{OsCN}^2}$$ -where \(N_{OsCN}\) is the number of oscillating copy number pattern "2-1-2" for each chromosome.
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-d <- scoring(cn)
-d
-
-d2 <- scoring(cn, TD_cn_cutoff = 4L)
-d2
Show Alteration Catalogue Profile
-result from sig_tally or a -matrix with row representing components (motifs) and -column representing samples
signature type for plotting, now supports 'copynumber', 'SBS', -'DBS', 'ID' and 'RS' (genome rearrangement signature).
method for copy number feature classification in sig_tally, -can be one of "Wang" ("W"), "S".
normalize method.
plot style, one of 'default' and 'cosmic'.
default is NULL
, show sum of all samples in one row.
-If not NULL
, show specified samples.
set the sample names shown in plot.
x axis lab.
y axis lab.
other arguments passing to show_sig_profile.
a ggplot
object
# \donttest{
-data("simulated_catalogs")
-p <- show_catalogue(simulated_catalogs$set1, style = "cosmic")
-p
-# }
Another visualization method for copy number profile like show_cn_profile.
-a CopyNumber object or a data.frame
containing at least 'chromosome', 'start',
-'end', 'segVal' these columns.
default is NULL
, can be a chracter vector representing multiple samples or
-number of samples to show.
-If data argument is a data.frame
, a column called sample must exist.
if TRUE
(default), show title with sample ID.
chromosomes start with 'chr'.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
colors for the heatmaps. If it is NULL
, set to
-circlize::colorRamp2(c(1, 2, 4), c("blue", "black", "red"))
.
side of the heatmaps.
other parameters passing to circlize::circos.genomicHeatmap.
a circos plot
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-# \donttest{
-show_cn_circos(cn, samples = 1)
-show_cn_circos(cn, samples = "TCGA-99-7458-01A-11D-2035-01")
-
-## Remove title
-show_cn_circos(cn, samples = 1, show_title = FALSE)
-
-## Subset chromosomes
-show_cn_circos(cn, samples = 1, chrs = c("chr1", "chr2", "chr3"))
-
-## Arrange plots
-layout(matrix(1:4, 2, 2))
-show_cn_circos(cn, samples = 4)
-
-layout(1) # reset layout
-# }
Show classified components ("Wang" ("W") method) for copy number data.
-show_cn_components(
- parameters,
- method = "Wang",
- show_weights = TRUE,
- log_y = FALSE,
- return_plotlist = FALSE,
- base_size = 12,
- nrow = 2,
- align = "hv",
- ...
-)
a data.frame
contain parameter components, obtain this
-from sig_tally function.
method for feature classification, can be one of -"Wang" ("W"), "S" (for method described in Steele et al. 2019), -"X" (for method described in Tao et al. 2023).
default is TRUE
, show weights for each component.
-Only used when method is "Macintyre".
logical, if TRUE
, show log10
based y axis, only
-works for input from "Wang" ("W") method.
if TRUE
, return a list of ggplot objects but a combined plot.
overall font size.
(optional) Number of rows in the plot grid.
(optional) Specifies whether graphs in the grid should be horizontally ("h") or -vertically ("v") aligned. Options are "none" (default), "hv" (align in both directions), "h", and "v".
other options pass to plot_grid
function of cowplot package.
a ggplot
object
R/show_cn_distribution.R
- show_cn_distribution.Rd
Visually summarize copy number distribution either by copy number segment length
-or chromosome. Input is a CopyNumber object, genome_build
option will
-read from genome_build
slot of object.
show_cn_distribution(
- data,
- rm_normal = TRUE,
- mode = c("ld", "cd"),
- fill = FALSE,
- scale_chr = TRUE,
- base_size = 14
-)
a CopyNumber object.
logical. Whether remove normal copy (i.e. "segVal" equals 2), default is TRUE
.
either "ld" for distribution by CN length or "cd" for distribution by chromosome.
when mode
is "cd" and fill
is TRUE
, plot percentage instead of count.
logical. If TRUE
, normalize count to per Megabase unit.
overall font size.
a ggplot
object
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Plot distribution
-p1 <- show_cn_distribution(cn)
-p1
-p2 <- show_cn_distribution(cn, mode = "cd")
-p2
-p3 <- show_cn_distribution(cn, mode = "cd", fill = TRUE)
-p3
Show Copy Number Feature Distributions
-show_cn_features(
- features,
- method = "Wang",
- rm_outlier = FALSE,
- ylab = NULL,
- log_y = FALSE,
- return_plotlist = FALSE,
- base_size = 12,
- nrow = 2,
- align = "hv",
- ...
-)
a feature list
generate from sig_tally function.
method for feature classification, can be one of -"Wang" ("W"), "S" (for method described in Steele et al. 2019), -"X" (for method described in Tao et al. 2023).
default is FALSE
, if TRUE
, remove outliers. Only
-works when method is "Wang" ("W").
lab of y axis.
logical, if TRUE
, show log10
based y axis, only
-works for input from "Wang" ("W") method.
if TRUE
, return a list of ggplot objects but a combined plot.
overall font size.
(optional) Number of rows in the plot grid.
(optional) Specifies whether graphs in the grid should be horizontally ("h") or -vertically ("v") aligned. Options are "none" (default), "hv" (align in both directions), "h", and "v".
other options pass to plot_grid
function of cowplot
package.
a ggplot
object
R/show_cn_freq_circos.R
- show_cn_freq_circos.Rd
Show Copy Number Variation Frequency Profile with Circos
-show_cn_freq_circos(
- data,
- groups = NULL,
- cutoff = 2L,
- resolution_factor = 1L,
- title = c("AMP", "DEL"),
- chrs = paste0("chr", 1:22),
- genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
- cols = NULL,
- plot_ideogram = TRUE,
- track_height = 0.5,
- ideogram_height = 1,
- ...
-)
a CopyNumber
object or a data.frame containing
-at least 'chromosome', 'start', 'end', 'segVal', 'sample' these columns.
a named list or a column name for specifying groups.
copy number value cutoff for splitting data into AMP and DEL.
-The values equal to cutoff are discarded. Default is 2
, you can also set
-a length-2 vector, e.g. c(2, 2)
.
an integer to control the resolution.
-When it is 1
(default), compute frequency in each cytoband.
-When it is 2
, use compute frequency in each half cytoband.
length-2 titles for AMP and DEL.
chromosomes start with 'chr'.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
length-2 colors for AMP and DEL.
default is TRUE
, show ideogram.
track height in mm
unit.
ideogram height in mm
unit.
other parameters passing to circlize::circos.genomicLines.
Nothing.
-# \donttest{
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-show_cn_freq_circos(cn)
-ss <- unique(cn@data$sample)
-show_cn_freq_circos(cn, groups = list(a = ss[1:5], b = ss[6:10]), cols = c("red", "green"))
-# }
R/show_cn_group_profile.R
- show_cn_group_profile.Rd
Show Summary Copy Number Profile for Sample Groups
-show_cn_group_profile(
- data,
- groups = NULL,
- fill_area = TRUE,
- cols = NULL,
- chrs = paste0("chr", c(1:22, "X")),
- genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
- cutoff = 2L,
- resolution_factor = 1L,
- force_y_limit = TRUE,
- highlight_genes = NULL,
- repel = FALSE,
- nrow = NULL,
- ncol = NULL,
- return_plotlist = FALSE
-)
a CopyNumber
object or a data.frame containing
-at least 'chromosome', 'start', 'end', 'segVal', 'sample' these columns.
a named list or a column name for specifying groups.
default is TRUE
, fill area with colors.
length-2 colors for AMP and DEL.
chromosomes start with 'chr'.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
copy number value cutoff for splitting data into AMP and DEL.
-The values equal to cutoff are discarded. Default is 2
, you can also set
-a length-2 vector, e.g. c(2, 2)
.
an integer to control the resolution.
-When it is 1
(default), compute frequency in each cytoband.
-When it is 2
, use compute frequency in each half cytoband.
default is TRUE
, force multiple plots
gene list to highlight. -have same y ranges. You can also set a length-2 numeric value.
if TRUE
(default is FALSE
), repel highlight genes to
-avoid overlap.
number of rows in the plot grid when multiple samples are selected.
number of columns in the plot grid when multiple samples are selected.
default is FALSE
, if TRUE
, return a plot list instead of a combined plot.
a (list of) ggplot
object.
load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-p1 <- show_cn_group_profile(cn)
-p1
-# \donttest{
-ss <- unique(cn@data$sample)
-p2 <- show_cn_group_profile(cn, groups = list(a = ss[1:5], b = ss[6:10]))
-p2
-p3 <- show_cn_group_profile(cn,
- groups = list(g1 = ss[1:5], g2 = ss[6:10]),
- force_y_limit = c(-1, 1), nrow = 2
-)
-p3
-
-## Set custom cutoff for custom data
-data <- cn@data
-data$segVal <- data$segVal - 2L
-p4 <- show_cn_group_profile(data,
- groups = list(g1 = ss[1:5], g2 = ss[6:10]),
- force_y_limit = c(-1, 1), nrow = 2,
- cutoff = c(0, 0)
-)
-p4
-
-## Add highlight gene
-p5 <- show_cn_group_profile(cn, highlight_genes = c("TP53", "EGFR"))
-p5
-# }
Sometimes it is very useful to check details about copy number profile for one or multiple -samples. This function is designed to do this job and can be further modified by ggplot2 -related packages.
-a CopyNumber object or a data.frame
containing at least 'chromosome', 'start',
-'end', 'segVal' these columns.
default is NULL, can be a chracter vector representing multiple samples. If data
argument
-is a data.frame
, a column called sample
must exist.
number of samples to show, this is used for checking.
if TRUE
, show title for multiple samples.
one of NULL
, "s" (for labelling short segments < 1e7)
-or "a" (all segments).
chromosomes start with 'chr'.
a position range, e.g. "chr1:3218923-116319008"
. Only data
-overlaps with this range will be shown.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
limites for y axis.
number of rows in the plot grid when multiple samples are selected.
number of columns in the plot grid when multiple samples are selected.
default is FALSE
, if TRUE
, return a plot list instead of a combined plot.
a ggplot
object or a list
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-p <- show_cn_profile(cn, nrow = 2, ncol = 1)
-p
-# \donttest{
-p2 <- show_cn_profile(cn,
- nrow = 2, ncol = 1,
- position = "chr1:3218923-116319008"
-)
-p2
-# }
All variables must be continuous.
-The matrix will be returned as an element of ggplot
object.
-This is basically a wrapper of R package
-ggcorrplot.
show_cor(
- data,
- x_vars = colnames(data),
- y_vars = x_vars,
- cor_method = "spearman",
- vis_method = "square",
- lab = TRUE,
- test = TRUE,
- hc_order = FALSE,
- p_adj = NULL,
- ...
-)
a data.frame
.
variables/column names shown in x axis.
variables/column names shown in y axis.
method for correlation, default is 'spearman'.
visualization method, default is 'square', -can also be 'circle'.
logical value. If TRUE, add correlation coefficient on the plot.
if TRUE
, run test for correlation and mark significance.
logical value. If TRUE
,
-correlation matrix will be hc.ordered using hclust
function.
p adjust method, see stats::p.adjust for details.
other parameters passing to ggcorrplot::ggcorrplot()
.
a ggplot
object
show_sig_feature_corrplot for specific and more powerful -association analysis and visualization.
Show Signature Information in Web Browser
-show_cosmic(x = "home")
a string indicating location -("home" for COSMIC signature home, "legacy" for COSMIC v2 signatures, -"SBS" for COSMIC v3 SBS signatures, "DBS" for COSMIC v3 DBS signatures, -"ID" for COSMIC v3 INDEL signatures) or signature index (e.g. -"SBS1", "DBS2", "ID3").
Nothing.
-if (FALSE) {
-show_cosmic()
-show_cosmic("legacy")
-show_cosmic("SBS")
-show_cosmic("DBS")
-show_cosmic("ID")
-show_cosmic("SBS1")
-show_cosmic("DBS2")
-show_cosmic("ID3")
-}
R/show_cosmic_signature_profile.R
- show_cosmic_sig_profile.Rd
Plot Reference (Mainly COSMIC) Signature Profile
-show_cosmic_sig_profile(
- sig_index = NULL,
- show_index = TRUE,
- sig_db = "legacy",
- ...
-)
a vector for signature index. "ALL" for all signatures.
if TRUE
, show valid indices.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
other arguments passing to show_sig_profile.
a ggplot
object
# \donttest{
-show_cosmic_sig_profile()
-show_cosmic_sig_profile(sig_db = "SBS")
-show_cosmic_sig_profile(sig_index = 1:5)
-show_cosmic_sig_profile(sig_db = "SBS", sig_index = c("10a", "17a"))
-
-gg <- show_cosmic_sig_profile(sig_index = 1:5)
-gg$aetiology
-# }
Using result data from get_group_comparison, this function plots
-genotypes/phenotypes comparison between signature groups using ggplot2 package and return
-a list of ggplot
object contains individual and combined plots. The combined
-plot is easily saved to local using cowplot::save_plot()
. Of note, default fisher
-test p values are shown for categorical data and fdr values are shown for
-continuous data.
show_group_comparison(
- group_comparison,
- xlab = "group",
- ylab_co = NA,
- legend_title_ca = NA,
- legend_position_ca = "bottom",
- set_ca_sig_yaxis = FALSE,
- set_ca_custom_xlab = FALSE,
- show_pvalue = TRUE,
- ca_p_threshold = 0.01,
- method = "wilcox.test",
- p.adjust.method = "fdr",
- base_size = 12,
- font_size_x = 12,
- text_angle_x = 30,
- text_hjust_x = 0.2,
- ...
-)
a list
from result of get_group_comparison function.
lab name of x axis for all plots. if it is NA
, remove title for x axis.
lab name of y axis for plots of continuous type data. Of note,
-this argument should be a character vector has same length as group_comparison
,
-the location for categorical type data should mark with NA
.
legend title for plots of categorical type data.
legend position for plots of categorical type data.
-Of note,
-this argument should be a character vector has same length as group_comparison
,
-the location for continuous type data should mark with NA
.
if TRUE
, use y axis to show signature proportion instead of
-variable proportion.
only works when set_ca_sig_yaxis
is TRUE
. If
-TRUE
, set x labels using input xlab
, otherwise variable names will be used.
if TRUE
, show p values.
a p threshold for categorical variables, default is 0.01.
-A p value less than 0.01 will be shown as P < 0.01
.
a character string indicating which method to be used for comparing means. -It can be 't.test', 'wilcox.test' etc..
correction method, default is 'fdr'. Run p.adjust.methods
to
-see all available options.
overall font size.
font size for x.
text angle for x.
adjust x axis text
other paramters pass to ggpubr::compare_means()
or ggpubr::stat_compare_means()
-according to the specified method
.
a list
of ggplot
objects.
# \donttest{
-load(system.file("extdata", "toy_copynumber_signature_by_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-# Assign samples to clusters
-groups <- get_groups(sig, method = "k-means")
-
-set.seed(1234)
-
-groups$prob <- rnorm(10)
-groups$new_group <- sample(c("1", "2", "3", "4", NA), size = nrow(groups), replace = TRUE)
-
-# Compare groups (filter NAs for categorical coloumns)
-groups.cmp <- get_group_comparison(groups[, -1],
- col_group = "group",
- cols_to_compare = c("prob", "new_group"),
- type = c("co", "ca"), verbose = TRUE
-)
-
-# Compare groups (Set NAs of categorical columns to 'Rest')
-groups.cmp2 <- get_group_comparison(groups[, -1],
- col_group = "group",
- cols_to_compare = c("prob", "new_group"),
- type = c("co", "ca"), NAs = "Rest", verbose = TRUE
-)
-
-show_group_comparison(groups.cmp)
-
-ggcomp <- show_group_comparison(groups.cmp2)
-ggcomp$co_comb
-ggcomp$ca_comb
-# }
R/show_group_distribution.R
- show_group_distribution.Rd
This is a general function, it can be used in any proper analysis.
-show_group_distribution(
- data,
- gvar,
- dvar,
- fun = stats::median,
- order_by_fun = FALSE,
- alpha = 0.8,
- g_label = "label",
- g_angle = 0,
- g_position = "top",
- point_size = 1L,
- segment_size = 1L,
- segment_color = "red",
- xlab = NULL,
- ylab = NULL,
- nrow = 1L,
- background_color = c("#DCDCDC", "#F5F5F5")
-)
a data.frame
.
a group variable name/index.
a distribution variable name/index.
a function to summarize, default is stats::median, can also be mean.
if TRUE
, reorder the groups by summary measure computed
-by argument fun
.
alpha for points, range from 0 to 1.
a string 'label' (default) for labeling with sample size, -or 'norm' to show just group name, or a named vector to set facet labels.
angle for facet labels, default is 0
.
position for facet labels, default is 'top', can also -be 'bottom'.
size of point.
size of segment.
color of segment.
title for x axis.
title for y axis.
number of row.
background color for plot panel.
a ggplot
object.
# \donttest{
-set.seed(1234)
-data <- data.frame(
- yval = rnorm(120),
- gr = c(rep("A", 50), rep("B", 40), rep("C", 30))
-)
-p <- show_group_distribution(data,
- gvar = 2, dvar = 1,
- g_label = "norm",
- background_color = "grey"
-)
-p
-p2 <- show_group_distribution(data,
- gvar = "gr", dvar = "yval",
- g_position = "bottom",
- order_by_fun = TRUE,
- alpha = 0.3
-)
-p2
-
-# Set custom group names
-p3 <- show_group_distribution(data,
- gvar = 2, dvar = 1,
- g_label = c("A" = "X", "B" = "Y", "C" = "Z")
-)
-p3
-# }
See group_enrichment for examples. -NOTE the box fill and the box text have different meanings.
-show_group_enrichment(
- df_enrich,
- return_list = FALSE,
- scales = "free",
- add_text_annotation = TRUE,
- fill_by_p_value = TRUE,
- use_fdr = TRUE,
- cut_p_value = FALSE,
- cut_breaks = c(-Inf, -5, log10(0.05), -log10(0.05), 5, Inf),
- cut_labels = c("↓ 1e-5", "↓ 0.05", "non-significant", "↑ 0.05", "↑ 1e-5"),
- fill_scale = scale_fill_gradient2(low = "#08A76B", mid = "white", high = "red",
- midpoint = ifelse(fill_by_p_value, 0, 1)),
- cluster_row = FALSE,
- ...
-)
result data.frame
from group_enrichment.
if TRUE
, return a list of ggplot
object so user
-can combine multiple plots by other R packages like patchwork
.
Should scales be fixed ("fixed"
, the default),
-free ("free"
), or free in one dimension ("free_x"
,
-"free_y"
)?
if TRUE
, add text annotation in box.
-When show p value with filled color, the text indicates relative change;
-when show relative change with filled color, the text indicates p value.
if TRUE
, show log10 based p values with filled color.
-The +/- of p values indicates change direction.
-If p vlaues is mapped to fill, then text shows effect size, and vice versa.
if TRUE
, show FDR values instead of raw p-values.
if TRUE
, cut p values into 5 regions for better visualization.
-Only works when fill_by_p_value = TRUE
.
when cut_p_value
is TRUE
, this option set the (log10 based) breaks.
when cut_p_value
is TRUE
, this option set the labels.
a Scale
object generated by ggplot2
package to
-set color for continuous values.
if TRUE
, cluster rows with Hierarchical Clustering ('complete' method).
other parameters passing to ggplot2::facet_wrap, only used
-when return_list
is FALSE
.
a (list of) ggplot
object.
This feature is designed for signature analysis. However, users can also use -it in other similar situations.
-show_group_mapping(
- data,
- col_to_flow,
- cols_to_map,
- include_sig = FALSE,
- fill_na = FALSE,
- title = NULL,
- xlab = NULL,
- ylab = NULL,
- custom_theme = cowplot::theme_minimal_hgrid()
-)
a data.frame
containing signature group and other categorical groups.
length-1 character showing the column to flow, typically a signature group.
character vector showing colnames of other groups.
default if FALSE
, if TRUE
, showing signature group.
length-1 string to fill NA, default is FALSE
.
the title.
label for x axis.
label for y axis.
theme for plotting, default is cowplot::theme_minimal_hgrid()
.
a ggplot
object
# \donttest{
-data <- dplyr::tibble(
- Group1 = rep(LETTERS[1:5], each = 10),
- Group2 = rep(LETTERS[6:15], each = 5),
- zzzz = c(rep("xx", 20), rep("yy", 20), rep(NA, 10))
-)
-p1 <- show_group_mapping(data, col_to_flow = "Group1", cols_to_map = colnames(data)[-1])
-p1
-
-p2 <- show_group_mapping(data,
- col_to_flow = "Group1", cols_to_map = colnames(data)[-1],
- include_sig = TRUE
-)
-p2
-# }
See example section in sig_fit()
for an examples.
show_groups(grp_dt, ...)
a result data.table
from get_groups.
parameters passing to legend()
, e.g. x = "topleft"
.
nothing.
-R/show_sig_bootstrap.R
- show_sig_bootstrap.Rd
See details for description.
-show_sig_bootstrap_exposure(
- bt_result,
- sample = NULL,
- signatures = NULL,
- methods = "QP",
- plot_fun = c("boxplot", "violin"),
- agg_fun = c("mean", "median", "min", "max"),
- highlight = "auto",
- highlight_size = 4,
- palette = "aaas",
- title = NULL,
- xlab = FALSE,
- ylab = "Signature exposure",
- width = 0.3,
- dodge_width = 0.8,
- outlier.shape = NA,
- add = "jitter",
- add.params = list(alpha = 0.3),
- ...
-)
-
-show_sig_bootstrap_error(
- bt_result,
- sample = NULL,
- methods = "QP",
- plot_fun = c("boxplot", "violin"),
- agg_fun = c("mean", "median"),
- highlight = "auto",
- highlight_size = 4,
- palette = "aaas",
- title = NULL,
- xlab = FALSE,
- ylab = "Reconstruction error (L2 norm)",
- width = 0.3,
- dodge_width = 0.8,
- outlier.shape = NA,
- add = "jitter",
- add.params = list(alpha = 0.3),
- legend = "none",
- ...
-)
-
-show_sig_bootstrap_stability(
- bt_result,
- signatures = NULL,
- measure = c("RMSE", "CV", "MAE", "AbsDiff"),
- methods = "QP",
- plot_fun = c("boxplot", "violin"),
- palette = "aaas",
- title = NULL,
- xlab = FALSE,
- ylab = "Signature instability",
- width = 0.3,
- outlier.shape = NA,
- add = "jitter",
- add.params = list(alpha = 0.3),
- ...
-)
result object from sig_fit_bootstrap_batch.
a sample id.
signatures to show.
a subset of c("NNLS", "QP", "SA")
.
set the plot function.
set the aggregation function when sample
is NULL
.
set the color for optimal solution. Default is "auto", which use the same color as -bootstrap results, you can set it to color like "red", "gold", etc.
size for highlighting triangle, default is 4
.
the color palette to be used for coloring or filling by groups. -Allowed values include "grey" for grey color palettes; brewer palettes e.g. -"RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and -scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", -"lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".
plot main title.
character vector specifying x axis labels. Use xlab = FALSE to -hide xlab.
character vector specifying y axis labels. Use ylab = FALSE to -hide ylab.
numeric value between 0 and 1 specifying box width.
dodge width.
point shape of outlier. Default is 19. To hide outlier,
-specify outlier.shape = NA
. When jitter is added, then outliers will
-be automatically hidden.
character vector for adding another plot element (e.g.: dot plot or -error bars). Allowed values are one or the combination of: "none", -"dotplot", "jitter", "boxplot", "point", "mean", "mean_se", "mean_sd", -"mean_ci", "mean_range", "median", "median_iqr", "median_hilow", -"median_q1q3", "median_mad", "median_range"; see ?desc_statby for more -details.
parameters (color, shape, size, fill, linetype) for the -argument 'add'; e.g.: add.params = list(color = "red").
other parameters passing to ggpubr::ggboxplot or ggpubr::ggviolin.
character specifying legend position. Allowed values are one of -c("top", "bottom", "left", "right", "none"). To remove the legend use -legend = "none". Legend position can be also specified using a numeric -vector c(x, y); see details section.
measure to estimate the exposure instability, can be one of 'RMSE', 'CV', 'MAE' and 'AbsDiff'.
a ggplot
object
Functions:
show_sig_bootstrap_exposure - this function plots exposures from bootstrap samples with both dotted boxplot. -The optimal exposure (the exposure from original input) is shown as triangle point. Only one sample can be plotted.
show_sig_bootstrap_error - this function plots decomposition errors from bootstrap samples with both dotted boxplot. -The error from optimal solution (the decomposition error from original input) is shown as triangle point. Only one sample can be plotted.
show_sig_bootstrap_stability - this function plots the signature exposure instability for specified signatures. Currently, -the instability measure supports 3 types:
'RMSE' for Mean Root Squared Error (default) of bootstrap exposures and original exposures for each sample.
'CV' for Coefficient of Variation (CV) based on RMSE (i.e. RMSE / btExposure_mean
).
'MAE' for Mean Absolute Error of bootstrap exposures and original exposures for each sample.
'AbsDiff' for Absolute Difference between mean bootstram exposure and original exposure.
Huang X, Wojtowicz D, Przytycka TM. Detecting presence of mutational signatures in cancer with confidence. Bioinformatics. 2018;34(2):330–337. doi:10.1093/bioinformatics/btx604
-# \donttest{
-if (require("BSgenome.Hsapiens.UCSC.hg19")) {
- laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
- laml <- read_maf(maf = laml.maf)
- mt_tally <- sig_tally(
- laml,
- ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
- use_syn = TRUE
- )
-
- library(NMF)
- mt_sig <- sig_extract(mt_tally$nmf_matrix,
- n_sig = 3,
- nrun = 2,
- cores = 1
- )
-
- mat <- t(mt_tally$nmf_matrix)
- mat <- mat[, colSums(mat) > 0]
- bt_result <- sig_fit_bootstrap_batch(mat, sig = mt_sig, n = 10)
- ## Parallel computation
- ## bt_result = sig_fit_bootstrap_batch(mat, sig = mt_sig, n = 10, use_parallel = TRUE)
-
- ## At default, mean bootstrap exposure for each sample has been calculated
- p <- show_sig_bootstrap_exposure(bt_result, methods = c("QP"))
- ## Show bootstrap exposure (optimal exposure is shown as triangle)
- p1 <- show_sig_bootstrap_exposure(bt_result, methods = c("QP"), sample = "TCGA-AB-2802")
- p1
- p2 <- show_sig_bootstrap_exposure(bt_result,
- methods = c("QP"),
- sample = "TCGA-AB-3012",
- signatures = c("Sig1", "Sig2")
- )
- p2
-
- ## Show bootstrap error
- ## Similar to exposure above
- p <- show_sig_bootstrap_error(bt_result, methods = c("QP"))
- p
- p3 <- show_sig_bootstrap_error(bt_result, methods = c("QP"), sample = "TCGA-AB-2802")
- p3
-
- ## Show exposure (in)stability
- p4 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"))
- p4
- p5 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "MAE")
- p5
- p6 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "AbsDiff")
- p6
- p7 <- show_sig_bootstrap_stability(bt_result, methods = c("QP"), measure = "CV")
- p7
-} else {
- message("Please install package 'BSgenome.Hsapiens.UCSC.hg19' firstly!")
-}
-# }
This function is a wrapper of NMF::consensusmap()
.
show_sig_consensusmap(
- sig,
- main = "Consensus matrix",
- tracks = c("consensus:", "silhouette:"),
- lab_row = NA,
- lab_col = NA,
- ...
-)
a Signature
object obtained from sig_extract.
Main title as a character string or a grob.
Special additional annotation tracks to - highlight associations between basis components and - sample clusters:
matches each row
- (resp. column) to the most contributing basis component
- in basismap
(resp. coefmap
). In
- basismap
(resp. coefmap
), adding a track
- ':basis'
to annCol
(resp. annRow
)
- makes the column (resp. row) corresponding to the
- component being also highlited using the mathcing
- colours.
labels for the rows.
labels for the columns.
other parameters passing to NMF::consensusmap()
.
nothing
-Currently support copy number signatures and mutational signatures.
-show_sig_exposure(
- Signature,
- sig_names = NULL,
- groups = NULL,
- grp_order = NULL,
- grp_size = NULL,
- samps = NULL,
- cutoff = NULL,
- style = c("default", "cosmic"),
- palette = use_color_style(style),
- base_size = 12,
- font_scale = 1,
- rm_space = FALSE,
- rm_grid_line = TRUE,
- rm_panel_border = FALSE,
- hide_samps = TRUE,
- legend_position = "top"
-)
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw absolute exposure matrix with column representing samples (patients) and row
-representing signatures (signature names must end with different digital numbers,
-e.g. Sig1, Sig10, x12). If you named signatures with letters,
-you can specify them by sig_names
parameter.
set name of signatures, can be a character vector.
sample groups, default is NULL
.
order of groups, default is NULL
.
font size of groups.
sample vector to filter samples or sort samples, default is NULL
.
a cutoff value to remove hyper-mutated samples.
plot style, one of 'default' and 'cosmic', works when
-parameter set_gradient_color
is FALSE
.
palette used to plot, default use a built-in palette
-according to parameter style
.
overall font size.
a number used to set font scale.
default is FALSE
. If TRUE
, it will remove border color
-and expand the bar width to 1. This is useful when the sample size is big.
default is FALSE
, if TRUE
, remove grid lines of plot.
default is TRUE
for style 'cosmic',
-remove panel border to keep plot tight.
if TRUE
, hide sample names.
position of legend, default is 'top'.
a ggplot
object
# \donttest{
-# Load mutational signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature exposure
-p1 <- show_sig_exposure(sig2)
-p1
-
-# Load copy number signature
-load(system.file("extdata", "toy_copynumber_signature_by_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature exposure
-p2 <- show_sig_exposure(sig)
-p2
-# }
R/show_sig_feature_corrplot.R
- show_sig_feature_corrplot.Rd
This function is for association visualization. Of note,
-the parameters p_val
and drop
will affect the visualization
-of association results under p value threshold.
show_sig_feature_corrplot(
- tidy_cor,
- feature_list,
- sort_features = FALSE,
- sig_orders = NULL,
- drop = TRUE,
- return_plotlist = FALSE,
- p_val = 0.05,
- xlab = "Signatures",
- ylab = "Features",
- co_gradient_colors = scale_color_gradient2(low = "blue", mid = "white", high = "red",
- midpoint = 0),
- ca_gradient_colors = co_gradient_colors,
- plot_ratio = "auto",
- breaks_count = NULL
-)
data returned by get_tidy_association.
a character vector contains features want to be plotted. -If missing, all features will be used.
default is FALSE
, use feature order obtained from the previous
-step. If TRUE
, sort features as feature_list
.
signature levels for ordering.
if TRUE
, when a feature has no association with all signatures
-(p value larger than threshold set by p_val
), this feature will be removed
-from the plot. Otherwise, this feature (a row) will keep with all blank white.
if TRUE
, return as a list of ggplot
objects.
p value threshold. If p value larger than this threshold, -the result becomes blank white.
label for x axis.
label for y axis.
a Scale object representing gradient colors used to plot for continuous features.
a Scale object representing gradient colors used to plot for categorical features.
a length-2 numeric vector to set the height/width ratio.
breaks for sample count. If set it to NULL
,
-ggplot bin
scale will be used to automatically determine the
-breaks. If set it to NA
, aes
for sample will be not used.
a ggplot2
object
# \donttest{
-# The data is generated from Wang, Shixiang et al.
-load(system.file("extdata", "asso_data.RData",
- package = "sigminer", mustWork = TRUE
-))
-
-p <- show_sig_feature_corrplot(
- tidy_data.seqz.feature,
- p_val = 0.05,
- breaks_count = c(0L,200L, 400L, 600L, 800L, 1020L))
-p
-# }
See sig_fit for examples.
-show_sig_fit(
- fit_result,
- samples = NULL,
- signatures = NULL,
- plot_fun = c("boxplot", "violin", "scatter"),
- palette = "aaas",
- title = NULL,
- xlab = FALSE,
- ylab = "Signature exposure",
- legend = "none",
- width = 0.3,
- outlier.shape = NA,
- add = "jitter",
- add.params = list(alpha = 0.3),
- ...
-)
result object from sig_fit.
samples to show, if NULL
, all samples are used.
signatures to show.
set the plot function.
the color palette to be used for coloring or filling by groups. -Allowed values include "grey" for grey color palettes; brewer palettes e.g. -"RdBu", "Blues", ...; or custom color palette e.g. c("blue", "red"); and -scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", -"lancet", "jco", "ucscgb", "uchicago", "simpsons" and "rickandmorty".
plot main title.
character vector specifying x axis labels. Use xlab = FALSE to -hide xlab.
character vector specifying y axis labels. Use ylab = FALSE to -hide ylab.
character specifying legend position. Allowed values are one of -c("top", "bottom", "left", "right", "none"). To remove the legend use -legend = "none". Legend position can be also specified using a numeric -vector c(x, y); see details section.
numeric value between 0 and 1 specifying box width.
point shape of outlier. Default is 19. To hide outlier,
-specify outlier.shape = NA
. When jitter is added, then outliers will
-be automatically hidden.
character vector for adding another plot element (e.g.: dot plot or -error bars). Allowed values are one or the combination of: "none", -"dotplot", "jitter", "boxplot", "point", "mean", "mean_se", "mean_sd", -"mean_ci", "mean_range", "median", "median_iqr", "median_hilow", -"median_q1q3", "median_mad", "median_range"; see ?desc_statby for more -details.
parameters (color, shape, size, fill, linetype) for the -argument 'add'; e.g.: add.params = list(color = "red").
other arguments to be passed to
-geom_boxplot
, ggpar
and
-facet
.
a ggplot
object.
Who don't like to show a barplot for signature profile? This is for it.
-show_sig_profile(
- Signature,
- mode = c("SBS", "copynumber", "DBS", "ID", "RS"),
- method = "Wang",
- by_context = FALSE,
- normalize = c("row", "column", "raw", "feature"),
- y_tr = NULL,
- filters = NULL,
- feature_setting = sigminer::CN.features,
- style = c("default", "cosmic"),
- palette = use_color_style(style, ifelse(by_context, "SBS", mode), method),
- set_gradient_color = FALSE,
- free_space = "free_x",
- rm_panel_border = style == "cosmic",
- rm_grid_line = style == "cosmic",
- rm_axis_text = FALSE,
- bar_border_color = ifelse(style == "default", "grey50", "white"),
- bar_width = 0.7,
- paint_axis_text = TRUE,
- x_label_angle = ifelse(mode == "copynumber" & !(startsWith(method, "T") | method ==
- "X"), 60, 90),
- x_label_vjust = ifelse(mode == "copynumber" & !(startsWith(method, "T") | method ==
- "X"), 1, 0.5),
- x_label_hjust = 1,
- x_lab = "Components",
- y_lab = "auto",
- y_limits = NULL,
- params = NULL,
- show_cv = FALSE,
- params_label_size = 3,
- params_label_angle = 60,
- y_expand = 1,
- digits = 2,
- base_size = 12,
- font_scale = 1,
- sig_names = NULL,
- sig_orders = NULL,
- check_sig_names = TRUE
-)
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix with row representing components (motifs) and column
-representing signatures (column names must start with 'Sig').
signature type for plotting, now supports 'copynumber', 'SBS', -'DBS', 'ID' and 'RS' (genome rearrangement signature).
method for copy number feature classification in sig_tally, -can be one of "Wang" ("W"), "S".
for specific use.
one of 'row', 'column', 'raw' and "feature", for row normalization (signature), -column normalization (component), raw data, row normalization by feature, respectively. -Of note, 'feature' only works when the mode is 'copynumber'.
a function (e.g. log10
) to transform y axis before plotting.
a pattern used to select components to plot.
a data.frame
used for classification.
-Only used when method is "Wang" ("W").
-Default is CN.features. Users can also set custom input with "feature",
-"min" and "max" columns available. Valid features can be printed by
-unique(CN.features$feature)
.
plot style, one of 'default' and 'cosmic', works when
-parameter set_gradient_color
is FALSE
.
palette used to plot when set_gradient_color
is FALSE
,
-default use a built-in palette according to parameter style
.
default is FALSE
, if TRUE
, use gradient colors
-to fill bars.
default is 'free_x'. If "fixed", all panels have the same size. -If "free_y" their height will be proportional to the length of the y scale; -if "free_x" their width will be proportional to the length of the x scale; -or if "free" both height and width will vary. -This setting has no effect unless the appropriate scales also vary.
default is TRUE
for style 'cosmic',
-remove panel border to keep plot tight.
default is FALSE
, if TRUE
, remove grid lines of plot.
default is FALSE
, if TRUE
, remove component texts.
-This is useful when multiple signature profiles are plotted together.
the color of bar border.
bar width. By default, set to 70% of the resolution of the -data.
if TRUE
, color on text of x axis.
font angle for x label.
font vjust for x label.
font hjust for x label.
x axis lab.
y axis lab.
limits to expand in y axis. e.g., 0.2
, c(0, 0.3)
.
params data.frame
of components, obtained from sig_tally.
default is FALSE
, if TRUE
, show coefficient of variation when
-params
is not NULL
.
font size for params label.
font angle for params label.
y expand height for plotting params of copy number signatures.
digits for plotting params of copy number signatures.
overall font size.
a number used to set font scale.
subset signatures or set name of signatures, can be a character vector.
-Default is NULL
, prefix 'Sig' plus number is used.
set order of signatures, can be a character vector.
-Default is NULL
, the signatures are ordered by alphabetical order.
-If an integer vector set, only specified signatures are plotted.
if TRUE
, check signature names when input is
-a matrix, i.e., all signatures (colnames) must start with 'Sig'.
a ggplot
object
# \donttest{
-# Load SBS signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature profile
-p1 <- show_sig_profile(sig2, mode = "SBS")
-p1
-
-# Use 'y_tr' option to transform values in y axis
-p11 <- show_sig_profile(sig2, mode = "SBS", y_tr = function(x) x * 100)
-p11
-
-# Load copy number signature from method "W"
-load(system.file("extdata", "toy_copynumber_signature_by_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature profile
-p2 <- show_sig_profile(sig,
- style = "cosmic",
- mode = "copynumber",
- method = "W",
- normalize = "feature"
-)
-p2
-
-# Visualize rearrangement signatures
-s <- get_sig_db("RS_Nik_lab")
-ss <- s$db[, 1:3]
-colnames(ss) <- c("Sig1", "Sig2", "Sig3")
-p3 <- show_sig_profile(ss, mode = "RS", style = "cosmic")
-p3
-# }
R/show_sig_profile_heatmap.R
- show_sig_profile_heatmap.Rd
This is a complementary function to show_sig_profile()
, it is used for visualizing
-some big signatures, i.e. SBS-1536, not all signatures are supported. See details for
-current supported signatures.
show_sig_profile_heatmap(
- Signature,
- mode = c("SBS", "DBS"),
- normalize = c("row", "column", "raw"),
- filters = NULL,
- x_lab = NULL,
- y_lab = NULL,
- legend_name = "auto",
- palette = "red",
- x_label_angle = 90,
- x_label_vjust = 1,
- x_label_hjust = 0.5,
- y_label_angle = 0,
- y_label_vjust = 0.5,
- y_label_hjust = 1,
- flip_xy = FALSE,
- sig_names = NULL,
- sig_orders = NULL,
- check_sig_names = TRUE
-)
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix with row representing components (motifs) and column
-representing signatures (column names must start with 'Sig').
one of "SBS" and "DBS".
one of 'row', 'column', 'raw' and "feature", for row normalization (signature), -column normalization (component), raw data, row normalization by feature, respectively. -Of note, 'feature' only works when the mode is 'copynumber'.
a pattern used to select components to plot.
x label.
y label.
name of figure legend.
color for value.
angle for x axis text.
vjust for x axis text.
hjust for x axis text.
angle for y axis text.
vjust for y axis text.
hjust for y axis text.
if TRUE
, flip x axis and y axis.
subset signatures or set name of signatures, can be a character vector.
-Default is NULL
, prefix 'Sig' plus number is used.
set order of signatures, can be a character vector.
-Default is NULL
, the signatures are ordered by alphabetical order.
-If an integer vector set, only specified signatures are plotted.
if TRUE
, check signature names when input is
-a matrix, i.e., all signatures (colnames) must start with 'Sig'.
a ggplot
object.
Support:
SBS-24
SBS-96
SBS-384
SBS-1536
SBS-6144
DBS-78
DBS-186
# \donttest{
-# Load SBS signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature profile
-p1 <- show_sig_profile_heatmap(sig2, mode = "SBS")
-p1
-# }
R/show_sig_profile_loop.R
- show_sig_profile_loop.Rd
Show Signature Profile with Loop Way
-show_sig_profile_loop(
- Signature,
- sig_names = NULL,
- ncol = 1,
- nrow = NULL,
- x_lab = "Components",
- ...
-)
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix with row representing components (motifs) and column
-representing signatures (column names must start with 'Sig').
subset signatures or set name of signatures, can be a character vector.
-Default is NULL
, prefix 'Sig' plus number is used.
(optional) Number of columns in the plot grid.
(optional) Number of rows in the plot grid.
x axis lab.
other parameters but sig_order
passing to show_sig_profile.
a ggplot
result from cowplot::plot_grid()
.
# \donttest{
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Show signature profile
-p1 <- show_sig_profile_loop(sig2, mode = "SBS")
-p1
-p2 <- show_sig_profile_loop(sig2, mode = "SBS", style = "cosmic", sig_names = c("A", "B", "C"))
-p2
-# }
R/sig_auto_extract.R
- sig_auto_extract.Rd
A bayesian variant of NMF algorithm to enable optimal inferences for the -number of signatures through the automatic relevance determination technique. -This functions delevers highly interpretable and sparse representations for -both signature profiles and attributions at a balance between data fitting and -model complexity (this method may introduce more signatures than expected, -especially for copy number signatures (thus I don't recommend you to use this feature -to extract copy number signatures)). See detail part and references for more.
-sig_auto_extract(
- nmf_matrix = NULL,
- result_prefix = "BayesNMF",
- destdir = tempdir(),
- method = c("L1W.L2H", "L1KL", "L2KL"),
- strategy = c("stable", "optimal", "ms"),
- ref_sigs = NULL,
- K0 = 25,
- nrun = 10,
- niter = 200000,
- tol = 0.0000001,
- cores = 1,
- optimize = FALSE,
- skip = FALSE,
- recover = FALSE
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
prefix for result data files.
path to save data runs, default is tempdir()
.
default is "L1W.L2H", which uses an exponential prior for W and -a half-normal prior for H (This method is used by PCAWG project, see reference #3). -You can also use "L1KL" to set expoential priors for both W and H, and "L2KL" to -set half-normal priors for both W and H. The latter two methods are originally -implemented by SignatureAnalyzer software.
the selection strategy for returned data. Set 'stable' for getting optimal
-result from the most frequent K. Set 'optimal' for getting optimal result from all Ks.
-Set 'ms' for getting result with maximum mean cosine similarity with provided reference
-signatures. See ref_sigs
option for details.
-If you want select other solution, please check get_bayesian_result.
A Signature object or matrix or string for specifying
-reference signatures, only used when strategy = 'ms'
.
-See Signature
and sig_db
options in get_sig_similarity for details.
number of initial signatures.
number of independent simulations.
the maximum number of iterations.
tolerance for convergence.
number of cpu cores to run NMF.
if TRUE
, then refit the denovo signatures with QP method, see sig_fit.
if TRUE
, it will skip running a previous stored result. This can be used to
-extend run times, e.g. you try running 10 times firstly and then you want to extend it to
-20 times.
if TRUE
, try to recover result from previous runs based on input result_prefix
,
-destdir
and nrun
. This is pretty useful for reproducing result. Please use skip
if you want
-to recover an unfinished job.
a list
with Signature
class.
There are three methods available in this function: "L1W.L2H", "L1KL" and "L2KL".
-They use different priors for the bayesian variant of NMF algorithm
-(see method
parameter) written by reference #1 and implemented in
-SignatureAnalyzer software
-(reference #2).
I copied source code for the three methods from Broad Institute and supplementary
-files of reference #3, and wrote this higher function. It is more friendly for users
-to extract, visualize and analyze signatures by combining with other powerful functions
-in sigminer package. Besides, I implemented parallel computation to speed up
-the calculation process and a similar input and output structure like sig_extract()
.
Tan, Vincent YF, and Cédric Févotte. "Automatic relevance determination in nonnegative matrix factorization with the/spl beta/-divergence." -IEEE Transactions on Pattern Analysis and Machine Intelligence 35.7 (2012): 1592-1605.
-Kim, Jaegil, et al. "Somatic ERCC2 mutations are associated with a distinct genomic signature in urothelial tumors." -Nature genetics 48.6 (2016): 600.
-Alexandrov, Ludmil, et al. "The repertoire of mutational signatures in human cancer." BioRxiv (2018): 322859.
-sig_tally for getting variation matrix, -sig_extract for extracting signatures using NMF package, sig_estimate for -estimating signature number for sig_extract.
# \donttest{
-load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-res <- sig_auto_extract(cn_tally_W$nmf_matrix, result_prefix = "Test_copynumber", nrun = 1)
-# At default, all run files are stored in tempdir()
-dir(tempdir(), pattern = "Test_copynumber")
-
-laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
-laml <- read_maf(maf = laml.maf)
-mt_tally <- sig_tally(
- laml,
- ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
- use_syn = TRUE
-)
-
-x <- sig_auto_extract(mt_tally$nmf_matrix,
- strategy = "ms", nrun = 3, ref_sigs = "legacy"
-)
-x
-# }
R/sig_convert.R
- sig_convert.Rd
Converts signatures between two representations relative to different sets of mutational opportunities. -Currently, only SBS signature is supported.
-sig_convert(sig, from = "human-genome", to = "human-exome")
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix/data.frame
with row representing components (motifs) and
-column representing signatures.
either one of "human-genome" and "human-exome" or an opportunity matrix
-(repeated n
columns with each row represents the total number of mutations for
-a component, n
is the number of signature).
same as from
.
a matrix
.
The default opportunity matrix for "human-genome" and "human-exome" comes from COSMIC -signature database v2 and v3.
-convert_signatures
function from sigfit package.
# Load SBS signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Exome-relative to Genome-relative
-sig_converted <- sig_convert(sig2,
- from = "human-exome",
- to = "human-genome"
-)
-sig_converted
-
-# \donttest{
-show_sig_profile(sig2, style = "cosmic")
-show_sig_profile(sig_converted, style = "cosmic")
-# }
Use NMF package to evaluate the optimal number of signatures.
-This is used along with sig_extract.
-Users should library(NMF)
firstly. If NMF objects are returned,
-the result can be further visualized by NMF plot methods like
-NMF::consensusmap()
and NMF::basismap()
.
sig_estimate()
shows comprehensive rank survey generated by
-NMF package, sometimes
-it is hard to consider all measures. show_sig_number_survey()
provides a
-one or two y-axis visualization method to help users determine
-the optimal signature number (showing both
-stability ("cophenetic") and error (RSS) at default).
-Users can also set custom measures to show.
show_sig_number_survey2()
is modified from NMF package to
-better help users to explore survey of signature number.
sig_estimate(
- nmf_matrix,
- range = 2:5,
- nrun = 10,
- use_random = FALSE,
- method = "brunet",
- seed = 123456,
- cores = 1,
- keep_nmfObj = FALSE,
- save_plots = FALSE,
- plot_basename = file.path(tempdir(), "nmf"),
- what = "all",
- verbose = FALSE
-)
-
-show_sig_number_survey(
- object,
- x = "rank",
- left_y = "cophenetic",
- right_y = "rss",
- left_name = left_y,
- right_name = toupper(right_y),
- left_color = "black",
- right_color = "red",
- left_shape = 16,
- right_shape = 18,
- shape_size = 4,
- highlight = NULL
-)
-
-show_sig_number_survey2(
- x,
- y = NULL,
- what = c("all", "cophenetic", "rss", "residuals", "dispersion", "evar", "sparseness",
- "sparseness.basis", "sparseness.coef", "silhouette", "silhouette.coef",
- "silhouette.basis", "silhouette.consensus"),
- na.rm = FALSE,
- xlab = "Total signatures",
- ylab = "",
- main = "Signature number survey using NMF package"
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
a numeric
vector containing the ranks of factorization to try. Note that duplicates are removed
-and values are sorted in increasing order. The results are notably returned in this order.
a numeric
giving the number of run to perform for each value in range
, nrun
set to 30~50 is
-enough to achieve robust result.
Should generate random data from input to test measurements. Default is TRUE
.
specification of the NMF algorithm. Use 'brunet' as default. -Available methods for NMF decompositions are 'brunet', 'lee', 'ls-nmf', 'nsNMF', 'offset'.
specification of the starting point or seeding method, which will compute a starting point, -usually using data from the target matrix in order to provide a good guess.
number of cpu cores to run NMF.
default is FALSE
, if TRUE
, keep NMF objects from runs, and the result may be huge.
if TRUE
, save signature number survey plot to local machine.
when save plots, set custom basename for file path.
a character vector whose elements partially match one of the following item,
-which correspond to the measures computed by summary()
on each – multi-run – NMF result:
-'all', 'cophenetic', 'rss', 'residuals', 'dispersion', 'evar', 'silhouette'
-(and more specific *.coef
, *.basis
, *.consensus
), 'sparseness'
-(and more specific *.coef
, *.basis
).
-It specifies which measure must be plotted (what='all' plots all the measures).
if TRUE
, print extra message.
a Survey
object generated from sig_estimate, or
-a data.frame
contains at least rank columns and columns for
-one measure.
a data.frame
or NMF.rank
object obtained from sig_estimate()
.
column name for left y axis.
column name for right y axis.
label name for left y axis.
label name for right y axis.
color for left axis.
color for right axis.
shape setting.
a integer
to highlight a x
.
for random simulation,
-a data.frame
or NMF.rank
object obtained from sig_estimate()
.
single logical that specifies if the rank
- for which the measures are NA values should be removed
- from the graph or not (default to FALSE
). This is
- useful when plotting results which include NAs due to
- error during the estimation process. See argument
- stop
for nmfEstimateRank
.
x-axis label
y-axis label
main title
sig_estimate: a list
contains information of NMF run and rank survey.
show_sig_number_survey: a ggplot
object
show_sig_number_survey2: a ggplot
object
The most common approach is to choose the smallest rank for which cophenetic correlation coefficient -starts decreasing (Used by this function). Another approach is to choose the rank for which the plot -of the residual sum of squares (RSS) between the input matrix and its estimate shows an inflection point. -More custom features please directly use NMF::nmfEstimateRank.
-Gaujoux, Renaud, and Cathal Seoighe. "A flexible R package for nonnegative matrix factorization." BMC bioinformatics 11.1 (2010): 367.
-sig_extract for extracting signatures using NMF package, sig_auto_extract for -extracting signatures using automatic relevance determination technique.
-sig_estimate for estimating signature number for sig_extract, -show_sig_number_survey2 for more visualization method.
# \donttest{
-load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-library(NMF)
-cn_estimate <- sig_estimate(cn_tally_W$nmf_matrix,
- cores = 1, nrun = 5,
- verbose = TRUE
-)
-
-p <- show_sig_number_survey2(cn_estimate$survey)
-p
-
-# Show two measures
-show_sig_number_survey(cn_estimate)
-# Show one measure
-p1 <- show_sig_number_survey(cn_estimate, right_y = NULL)
-p1
-p2 <- add_h_arrow(p, x = 4.1, y = 0.953, label = "selected number")
-p2
-
-# Show data from a data.frame
-p3 <- show_sig_number_survey(cn_estimate$survey)
-p3
-# Show other measures
-head(cn_estimate$survey)
-p4 <- show_sig_number_survey(cn_estimate$survey,
- right_y = "dispersion",
- right_name = "dispersion"
-)
-p4
-p5 <- show_sig_number_survey(cn_estimate$survey,
- right_y = "evar",
- right_name = "evar"
-)
-p5
-# }
Do NMF de-composition and then extract signatures.
-sig_extract(
- nmf_matrix,
- n_sig,
- nrun = 10,
- cores = 1,
- method = "brunet",
- optimize = FALSE,
- pynmf = FALSE,
- use_conda = TRUE,
- py_path = "/Users/wsx/anaconda3/bin/python",
- seed = 123456,
- ...
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
number of signature. Please run sig_estimate to select a suitable value.
a numeric
giving the number of run to perform for each value in range
, nrun
set to 30~50 is
-enough to achieve robust result.
number of cpu cores to run NMF.
specification of the NMF algorithm. Use 'brunet' as default. -Available methods for NMF decompositions are 'brunet', 'lee', 'ls-nmf', 'nsNMF', 'offset'.
if TRUE
, then refit the denovo signatures with QP method, see sig_fit.
if TRUE
, use Python NMF driver Nimfa.
-The seed currently is not used by this implementation.
if TRUE
, create an independent conda environment to run NMF.
path to Python executable file, e.g. '/Users/wsx/anaconda3/bin/python'. In my
-test, it is more stable than use_conda=TRUE
. You can install the Nimfa package by yourself
-or set use_conda
to TRUE
to install required Python environment, and then set this option.
specification of the starting point or seeding method, which will compute a starting point, -usually using data from the target matrix in order to provide a good guess.
other arguments passed to NMF::nmf()
.
a list
with Signature
class.
Gaujoux, Renaud, and Cathal Seoighe. "A flexible R package for nonnegative matrix factorization." BMC bioinformatics 11.1 (2010): 367.
-Mayakonda, Anand, et al. "Maftools: efficient and comprehensive analysis of somatic variants in cancer." Genome research 28.11 (2018): 1747-1756.
-sig_tally for getting variation matrix, -sig_estimate for estimating signature number for sig_extract, sig_auto_extract for -extracting signatures using automatic relevance determination technique.
# \donttest{
-load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Extract copy number signatures
-res <- sig_extract(cn_tally_W$nmf_matrix, 2, nrun = 1)
-# }
R/sig_fit.R
- sig_fit.Rd
The function performs a signatures decomposition of a given mutational
-catalogue V
with known signatures W
by solving the minimization problem
-min(||W*H - V||)
where W and V are known.
sig_fit(
- catalogue_matrix,
- sig,
- sig_index = NULL,
- sig_db = c("legacy", "SBS", "DBS", "ID", "TSB", "SBS_Nik_lab", "RS_Nik_lab",
- "RS_BRCA560", "RS_USARC", "CNS_USARC", "CNS_TCGA", "CNS_TCGA176", "CNS_PCAWG176",
- "SBS_hg19", "SBS_hg38", "SBS_mm9", "SBS_mm10", "DBS_hg19", "DBS_hg38", "DBS_mm9",
- "DBS_mm10", "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ", "latest_SBS_GRCh37",
- "latest_DBS_GRCh37", "latest_ID_GRCh37", "latest_SBS_GRCh38", "latest_DBS_GRCh38",
- "latest_SBS_mm9", "latest_DBS_mm9", "latest_SBS_mm10", "latest_DBS_mm10",
- "latest_SBS_rn6", "latest_DBS_rn6", "latest_CN_GRCh37",
-
- "latest_RNA-SBS_GRCh37", "latest_SV_GRCh38"),
- db_type = c("", "human-exome", "human-genome"),
- show_index = TRUE,
- method = c("QP", "NNLS", "SA"),
- auto_reduce = FALSE,
- type = c("absolute", "relative"),
- return_class = c("matrix", "data.table"),
- return_error = FALSE,
- rel_threshold = 0,
- mode = c("SBS", "DBS", "ID", "copynumber"),
- true_catalog = NULL,
- ...
-)
a numeric matrix V
with row representing components and
-columns representing samples, typically you can get nmf_matrix
from sig_tally()
and
-transpose it by t()
.
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix/data.frame
with row representing components (motifs) and
-column representing signatures.
a vector for signature index. "ALL" for all signatures.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
only used when sig_db
is enabled.
-"" for keeping default, "human-exome" for transforming to exome frequency of component,
-and "human-genome" for transforming to whole genome frequency of component.
-Currently only works for 'SBS'.
if TRUE
, show valid indices.
method to solve the minimazation problem. -'NNLS' for non-negative least square; 'QP' for quadratic programming; 'SA' for simulated annealing.
if TRUE
, try reducing the input reference signatures to increase
-the cosine similarity of reconstructed profile to observed profile.
'absolute' for signature exposure and 'relative' for signature relative exposure.
string, 'matrix' or 'data.table'.
if TRUE
, also return sample error (Frobenius norm) and cosine
-similarity between observed sample profile (asa. spectrum) and reconstructed profile. NOTE:
-it is better to obtain the error when the type is 'absolute', because the error is
-affected by relative exposure accuracy.
numeric vector, a signature with relative exposure
-lower than (equal is included, i.e. <=
) this value will be set to 0
-(both absolute exposure and relative exposure).
-In this case, sum of signature contribution may not equal to 1.
signature type for plotting, now supports 'copynumber', 'SBS', -'DBS', 'ID' and 'RS' (genome rearrangement signature).
used by sig_fit_bootstrap, user never use it.
control parameters passing to argument control
in GenSA
function when use method 'SA'.
The exposure result either in matrix
or data.table
format.
-If return_error
set TRUE
, a list
is returned.
The method 'NNLS' solves the minimization problem with nonnegative least-squares constraints. -The method 'QP' and 'SA' are modified from SignatureEstimation package. -See references for details. -Of note, when fitting exposures for copy number signatures, only components of -feature CN is used.
-Daniel Huebschmann, Zuguang Gu and Matthias Schlesner (2019). YAPSA: Yet Another Package for Signature Analysis. R package version 1.12.0.
-Huang X, Wojtowicz D, Przytycka TM. Detecting presence of mutational signatures in cancer with confidence. Bioinformatics. 2018;34(2):330–337. doi:10.1093/bioinformatics/btx604
-Kim, Jaegil, et al. "Somatic ERCC2 mutations are associated with a distinct genomic signature in urothelial tumors." -Nature genetics 48.6 (2016): 600.
-# \donttest{
-W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
-colnames(W) <- c("sig1", "sig2")
-W <- apply(W, 2, function(x) x / sum(x))
-
-H <- matrix(c(2, 5, 3, 6, 1, 9, 1, 2), ncol = 4)
-colnames(H) <- paste0("samp", 1:4)
-
-V <- W %*% H
-V
-
-if (requireNamespace("quadprog", quietly = TRUE)) {
- H_infer <- sig_fit(V, W, method = "QP")
- H_infer
- H
-
- H_dt <- sig_fit(V, W, method = "QP", auto_reduce = TRUE, return_class = "data.table")
- H_dt
-
- ## Show results
- show_sig_fit(H_infer)
- show_sig_fit(H_dt)
-
- ## Get clusters/groups
- H_dt_rel <- sig_fit(V, W, return_class = "data.table", type = "relative")
- z <- get_groups(H_dt_rel, method = "k-means")
- show_groups(z)
-}
-
-# if (requireNamespace("GenSA", quietly = TRUE)) {
-# H_infer <- sig_fit(V, W, method = "SA")
-# H_infer
-# H
-#
-# H_dt <- sig_fit(V, W, method = "SA", return_class = "data.table")
-# H_dt
-#
-# ## Modify arguments to method
-# sig_fit(V, W, method = "SA", maxit = 10, temperature = 100)
-#
-# ## Show results
-# show_sig_fit(H_infer)
-# show_sig_fit(H_dt)
-# }
-# }
R/sig_fit_bootstrap.R
- sig_fit_bootstrap.Rd
This can be used to obtain the confidence of signature exposures or search -the suboptimal decomposition solution.
-sig_fit_bootstrap(
- catalog,
- sig,
- n = 100L,
- sig_index = NULL,
- sig_db = "legacy",
- db_type = c("", "human-exome", "human-genome"),
- show_index = TRUE,
- method = c("QP", "NNLS", "SA"),
- auto_reduce = FALSE,
- SA_not_bootstrap = FALSE,
- type = c("absolute", "relative"),
- rel_threshold = 0,
- mode = c("SBS", "DBS", "ID", "copynumber"),
- find_suboptimal = FALSE,
- suboptimal_ref_error = NULL,
- suboptimal_factor = 1.05,
- ...
-)
a named numeric vector or a numeric matrix with dimension Nx1. -N is the number of component, 1 is the sample.
a Signature
object obtained either from sig_extract or sig_auto_extract,
-or just a raw signature matrix/data.frame
with row representing components (motifs) and
-column representing signatures.
the number of bootstrap replicates.
a vector for signature index. "ALL" for all signatures.
default 'legacy', it can be 'legacy' (for COSMIC v2 'SBS'),
-'SBS', 'DBS', 'ID' and 'TSB' (for COSMIV v3.1 signatures)
-for small scale mutations.
-For more specific details, it can also be 'SBS_hg19', 'SBS_hg38',
-'SBS_mm9', 'SBS_mm10', 'DBS_hg19', 'DBS_hg38', 'DBS_mm9', 'DBS_mm10' to use
-COSMIC v3 reference signatures from Alexandrov, Ludmil B., et al. (2020) (reference #1).
-In addition, it can be one of "SBS_Nik_lab_Organ", "RS_Nik_lab_Organ",
-"SBS_Nik_lab", "RS_Nik_lab" to refer reference signatures from
-Degasperi, Andrea, et al. (2020) (reference #2);
-"RS_BRCA560", "RS_USARC" to reference signatures from BRCA560 and USARC cohorts;
-"CNS_USARC" (40 categories), "CNS_TCGA" (48 categories) to reference copy number signatures from USARC cohort and TCGA;
-"CNS_TCGA176" (176 categories) and "CNS_PCAWG176" (176 categories) to reference copy number signatures from PCAWG and TCGA separately.
-UPDATE, the latest version of reference version can be automatically
-downloaded and loaded from https://cancer.sanger.ac.uk/signatures/downloads/
-when a option with latest_
prefix is specified (e.g. "latest_SBS_GRCh37").
-Note: the signature profile for different genome builds are basically same.
-And specific database (e.g. 'SBS_mm10') contains less signatures than all COSMIC
-signatures (because some signatures are not detected from Alexandrov, Ludmil B., et al. (2020)).
-For all available options, check the parameter setting.
only used when sig_db
is enabled.
-"" for keeping default, "human-exome" for transforming to exome frequency of component,
-and "human-genome" for transforming to whole genome frequency of component.
-Currently only works for 'SBS'.
if TRUE
, show valid indices.
method to solve the minimazation problem. -'NNLS' for non-negative least square; 'QP' for quadratic programming; 'SA' for simulated annealing.
if TRUE
, try reducing the input reference signatures to increase
-the cosine similarity of reconstructed profile to observed profile.
if TRUE
, directly run 'SA' multiple times with original input instead of
-bootstrap samples.
'absolute' for signature exposure and 'relative' for signature relative exposure.
numeric vector, a signature with relative exposure
-lower than (equal is included, i.e. <=
) this value will be set to 0
-(both absolute exposure and relative exposure).
-In this case, sum of signature contribution may not equal to 1.
signature type for plotting, now supports 'copynumber', 'SBS', -'DBS', 'ID' and 'RS' (genome rearrangement signature).
logical, if TRUE
, find suboptimal decomposition with
-slightly higher error than the optimal solution by method 'SA'. This is useful
-to explore hidden dependencies between signatures. More see reference.
baseline error used for finding suboptimal solution.
-if it is NULL
, then use 'SA' method to obtain the optimal error.
suboptimal factor to get suboptimal error, default is 1.05
,
-i.e., suboptimal error is 1.05
times baseline error.
control parameters passing to argument control
in GenSA
function when use method 'SA'.
a list
Huang X, Wojtowicz D, Przytycka TM. Detecting presence of mutational signatures in cancer with confidence. Bioinformatics. 2018;34(2):330–337. doi:10.1093/bioinformatics/btx604
-W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
-colnames(W) <- c("sig1", "sig2")
-W <- apply(W, 2, function(x) x / sum(x))
-
-H <- matrix(c(2, 5, 3, 6, 1, 9, 1, 2), ncol = 4)
-colnames(H) <- paste0("samp", 1:4)
-
-V <- W %*% H
-V
-
-if (requireNamespace("quadprog", quietly = TRUE)) {
- H_bootstrap <- sig_fit_bootstrap(V[, 1], W, n = 10, type = "absolute")
- ## Typically, you have to run many times to get close to the answer
- boxplot(t(H_bootstrap$expo))
- H[, 1]
-
- ## Return P values
- ## In practice, run times >= 100
- ## is recommended
- report_bootstrap_p_value(H_bootstrap)
- ## For multiple samples
- ## Input a list
- report_bootstrap_p_value(list(samp1 = H_bootstrap, samp2 = H_bootstrap))
-
- # ## Find suboptimal decomposition
- # H_suboptimal <- sig_fit_bootstrap(V[, 1], W,
- # n = 10,
- # type = "absolute",
- # method = "SA",
- # find_suboptimal = TRUE
- # )
-}
R/sig_fit_bootstrap_batch.R
- sig_fit_bootstrap_batch.Rd
Read sig_fit_bootstrap for more option setting.
-a numeric matrix V
with row representing components and
-columns representing samples, typically you can get nmf_matrix
from sig_tally()
and
-transpose it by t()
.
a subset of c("NNLS", "QP", "SA")
.
the number of bootstrap replicates.
minimal exposure in a sample, default is 1. Any patient has total exposure less -than this value will be filtered out.
a vector of relative exposure threshold for calculating p values.
if TRUE
, use parallel computation based on furrr package.
-It can also be an integer for specifying cores.
random seed to reproduce the result.
a job ID, default is NULL
, can be a string. When not NULL
, all bootstrapped results
-will be saved to local machine location defined by result_dir
. This is very useful for running
-more than 10 times for more than 100 samples.
see above, default is temp directory defined by R.
other common parameters passing to sig_fit_bootstrap, including
-sig
, sig_index
, sig_db
, db_type
, mode
, auto_reduce
etc.
a list
of data.table
.
W <- matrix(c(1, 2, 3, 4, 5, 6), ncol = 2)
-colnames(W) <- c("sig1", "sig2")
-W <- apply(W, 2, function(x) x / sum(x))
-
-H <- matrix(c(2, 5, 3, 6, 1, 9, 1, 2), ncol = 4)
-colnames(H) <- paste0("samp", 1:4)
-
-V <- W %*% H
-V
-
-if (requireNamespace("quadprog")) {
- z10 <- sig_fit_bootstrap_batch(V, sig = W, n = 10)
- z10
-}
Obtain or Modify Signature Information
-a Signature
object obtained either from sig_extract or sig_auto_extract.
new signature names.
one of 'row', 'column', 'raw' and "feature", for row normalization (signature), -column normalization (component), raw data, row normalization by feature, respectively.
one of 'absolute' and 'relative'.
a Signature
object or data.
## Operate signature names
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-sig_names(sig2)
-cc <- sig_modify_names(sig2, new_names = c("Sig2", "Sig1", "Sig3"))
-sig_names(cc)
-
-# The older names are stored in tags.
-print(attr(cc, "tag"))
-## Get signature number
-sig_number(sig2)
-## Get signature attributes
-sig_number(sig2)
-## Get signature matrix
-z <- sig_signature(sig2)
-z <- sig_signature(sig2, normalize = "raw")
-## Get exposure matrix
-## Of note, this is different from get_sig_exposure()
-## it returns a matrix instead of data table.
-z <- sig_exposure(sig2) # it is same as sig$Exposure
-z <- sig_exposure(sig2, type = "relative") # it is same as sig2$Exposure.norm
Tally a variation object like MAF, CopyNumber and return a matrix for NMF de-composition and more. -This is a generic function, -so it can be further extended to other mutation cases. -Please read details about how to set sex for identifying copy number signatures. -Please read https://osf.io/s93d5/ for the generation of SBS, DBS and ID (INDEL) -components.
-sig_tally(object, ...)
-
-# S3 method for CopyNumber
-sig_tally(
- object,
- method = "Wang",
- ignore_chrs = NULL,
- indices = NULL,
- add_loh = FALSE,
- feature_setting = sigminer::CN.features,
- cores = 1,
- keep_only_matrix = FALSE,
- ...
-)
-
-# S3 method for RS
-sig_tally(object, keep_only_matrix = FALSE, ...)
-
-# S3 method for MAF
-sig_tally(
- object,
- mode = c("SBS", "DBS", "ID", "ALL"),
- ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
- genome_build = NULL,
- add_trans_bias = FALSE,
- ignore_chrs = NULL,
- use_syn = TRUE,
- keep_only_matrix = FALSE,
- ...
-)
a CopyNumber object or MAF object or SV object (from read_sv_as_rs).
custom setting for operating object. Detail see S3 method for
-corresponding class (e.g. CopyNumber
).
method for feature classification, can be one of -"Wang" ("W"), "S" (for method described in Steele et al. 2019), -"X" (for method described in Tao et al. 2023).
Chromsomes to ignore from analysis. e.g. chrX and chrY.
integer vector indicating segments to keep.
flag to add LOH classifications.
a data.frame
used for classification.
-Only used when method is "Wang" ("W").
-Default is CN.features. Users can also set custom input with "feature",
-"min" and "max" columns available. Valid features can be printed by
-unique(CN.features$feature)
.
number of computer cores to run this task.
-You can use future::availableCores()
function to check how
-many cores you can use.
if TRUE
, keep only matrix for signature extraction.
-For a MAF
object, this will just return the most useful matrix.
type of mutation matrix to extract, can be one of 'SBS', 'DBS' and 'ID'.
'BSgenome.Hsapiens.UCSC.hg19', 'BSgenome.Hsapiens.UCSC.hg38', -'BSgenome.Mmusculus.UCSC.mm10', 'BSgenome.Mmusculus.UCSC.mm9', etc.
genome build 'hg19', 'hg38', 'mm9' or "mm10", if not set, guess it by ref_genome
.
if TRUE
, consider transcriptional bias categories.
-'T:' for Transcribed (the variant is on the transcribed strand);
-'U:' for Un-transcribed (the variant is on the untranscribed strand);
-'B:' for Bi-directional (the variant is on both strand and is transcribed either way);
-'N:' for Non-transcribed (the variant is in a non-coding region and is untranslated);
-'Q:' for Questionable.
-NOTE: the result counts of 'B' and 'N' labels are a little different from
-SigProfilerMatrixGenerator, the reason is unknown (may be caused by annotation file).
Logical. If TRUE
, include synonymous variants in analysis.
a list
contains a matrix
used for NMF de-composition.
For identifying copy number signatures, we have to derive copy number -features firstly. Due to the difference of copy number values in sex chromosomes -between male and female, we have to do an extra step if we don't want to -ignore them.
-I create two options to control this, the default values are shown as -the following, you can use the same way to set (per R session).
-options(sigminer.sex = "female", sigminer.copynumber.max = NA_integer_)
If your cohort are all females, you can totally ignore this.
If your cohort are all males, set sigminer.sex
to 'male' and
-sigminer.copynumber.max
to a proper value (the best is consistent
-with read_copynumber).
If your cohort contains both males and females, set sigminer.sex
-as a data.frame
with two columns "sample" and "sex". And
-set sigminer.copynumber.max
to a proper value (the best is consistent
-with read_copynumber).
sig_tally(CopyNumber)
: Returns copy number features, components and component-by-sample matrix
sig_tally(RS)
: Returns genome rearrangement sample-by-component matrix
sig_tally(MAF)
: Returns SBS mutation sample-by-component matrix and APOBEC enrichment
Wang, Shixiang, et al. "Copy number signature analyses in prostate cancer reveal -distinct etiologies and clinical outcomes." medRxiv (2020).
-Steele, Christopher D., et al. "Undifferentiated sarcomas develop through -distinct evolutionary pathways." Cancer Cell 35.3 (2019): 441-456.
-Mayakonda, Anand, et al. "Maftools: efficient and comprehensive analysis of somatic variants in cancer." Genome research 28.11 (2018): 1747-1756.
-Roberts SA, Lawrence MS, Klimczak LJ, et al. An APOBEC Cytidine Deaminase Mutagenesis Pattern is Widespread in Human Cancers. Nature genetics. 2013;45(9):970-976. doi:10.1038/ng.2702.
-Bergstrom EN, Huang MN, Mahto U, Barnes M, Stratton MR, Rozen SG, Alexandrov LB: SigProfilerMatrixGenerator: a tool for visualizing and exploring patterns of small mutational events. BMC Genomics 2019, 20:685 https://bmcgenomics.biomedcentral.com/articles/10.1186/s12864-019-6041-2
-sig_estimate for estimating signature number for sig_extract, -sig_auto_extract for extracting signatures using automatic relevance determination technique.
# Load copy number object
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-# \donttest{
-# Use method designed by Wang, Shixiang et al.
-cn_tally_W <- sig_tally(cn, method = "W")
-# }
-# Use method designed by Steele et al.
-# See example in read_copynumber
-# \donttest{
-# Prepare SBS signature analysis
-laml.maf <- system.file("extdata", "tcga_laml.maf.gz", package = "maftools")
-laml <- read_maf(maf = laml.maf)
-if (require("BSgenome.Hsapiens.UCSC.hg19")) {
- mt_tally <- sig_tally(
- laml,
- ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
- use_syn = TRUE
- )
- mt_tally$nmf_matrix[1:5, 1:5]
-
- ## Use strand bias categories
- mt_tally <- sig_tally(
- laml,
- ref_genome = "BSgenome.Hsapiens.UCSC.hg19",
- use_syn = TRUE, add_trans_bias = TRUE
- )
- ## Test it by enrichment analysis
- enrich_component_strand_bias(mt_tally$nmf_matrix)
- enrich_component_strand_bias(mt_tally$all_matrices$SBS_24)
-} else {
- message("Please install package 'BSgenome.Hsapiens.UCSC.hg19' firstly!")
-}
-# }
R/sig_unify_extract.R
- sig_unify_extract.Rd
This function provides an unified interface to signature extractor
-implemented in sigminer. If you determine a specific approach
,
-please also read the documentation of corresponding extractor.
-See "Arguments" part.
sig_unify_extract(
- nmf_matrix,
- range = 2:5,
- nrun = 10,
- approach = c("bayes_nmf", "repeated_nmf", "bootstrap_nmf", "sigprofiler"),
- cores = 1L,
- ...
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
signature number range, i.e. 2:5
.
the number of iteration to be performed to extract each signature number.
approach name.
"repeated_nmf" - sig_extract
"bayes_nmf" - sig_auto_extract
"bootstrap_nmf" - bp_extract_signatures
"sigprofiler" - sigprofiler
number of cores used for computation.
other parameters passing to signature extractor based
-on the approach
setting.
Result dependent on the approach
setting.
# \donttest{
-load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Extract signatures
-# It is same as sig_extract(cn_tally_W$nmf_matrix, 2, nrun = 1)
-res <- sig_unify_extract(cn_tally_W$nmf_matrix, 2,
- nrun = 1,
- approach = "repeated_nmf"
-)
-# Auto-extract signatures based on bayesian NMF
-res2 <- sig_unify_extract(cn_tally_W$nmf_matrix,
- nrun = 1,
- approach = "bayes_nmf"
-)
-# }
R/sigminer.R
- sigminer-package.Rd
Author: Shixiang Wang (w_shixiang@163.com)
Please go to https://shixiangwang.github.io/sigminer-doc/ for full vignette.
Please go to https://shixiangwang.github.io/sigminer/reference/index.html -for organized documentation of functions and datasets.
Result visualization for MAF is provide by maftools package, -please read its vignette.
Useful links:
R/sigminer.R
- sigminer.Rd
Author: Shixiang Wang (w_shixiang@163.com)
Please go to https://shixiangwang.github.io/sigminer-doc/ for full vignette.
Please go to https://shixiangwang.github.io/sigminer/reference/index.html -for organized documentation of functions and datasets.
Result visualization for MAF is provide by maftools package, -please read its vignette.
This function provides an interface to software SigProfiler.
-More please see https://github.com/AlexandrovLab/SigProfilerExtractor.
-Typically, a reference genome is not required because the input is a matrix (my understanding).
-If you are using refitting result by SigProfiler, please make sure you have input the matrix same order as examples at https://github.com/AlexandrovLab/SigProfilerMatrixGenerator/tree/master/SigProfilerMatrixGenerator/references/matrix/BRCA_example. If not, use sigprofiler_reorder()
firstly.
sigprofiler_extract(
- nmf_matrix,
- output,
- output_matrix_only = FALSE,
- range = 2:5,
- nrun = 10L,
- refit = FALSE,
- refit_plot = FALSE,
- is_exome = FALSE,
- init_method = c("random", "nndsvd_min", "nndsvd", "nndsvda", "nndsvdar"),
- cores = -1L,
- genome_build = c("hg19", "hg38", "T2T", "mm10", "mm9", "ce11"),
- use_conda = FALSE,
- py_path = NULL,
- sigprofiler_version = "1.1.3"
-)
-
-sigprofiler_import(
- output,
- order_by_expo = FALSE,
- type = c("suggest", "refit", "all")
-)
-
-sigprofiler_reorder(
- nmf_matrix,
- type = c("SBS96", "SBS6", "SBS12", "SBS192", "SBS1536", "SBS3072", "DBS78", "DBS312",
- "DBS1248", "DBS4992")
-)
a matrix
used for NMF decomposition with rows indicate samples and columns indicate components.
output directory.
if TRUE
, only generate matrix file for SigProfiler
-so user can call SigProfiler with the input by himself.
signature number range, i.e. 2:5
.
the number of iteration to be performed to extract each signature number.
if TRUE
, then refit the denovo signatures with nnls. Same
-meaning as optimize
option in sig_extract or sig_auto_extract.
if TRUE
, SigProfiler will make
-denovo to COSMIC sigantures decompostion plots. However, this may fail due
-to some matrix cannot be identified by SigProfiler plot program.
if TRUE
, the exomes will be extracted.
the initialization algorithm for W and H matrix of NMF. -Options are 'random', 'nndsvd', 'nndsvda', 'nndsvdar', 'alexandrov-lab-custom' -and 'nndsvd_min'.
number of cores used for computation.
I think this option is useless when input is matrix
, keep it
-in case it is useful.
if TRUE
, create an independent conda environment to run SigProfiler.
path to Python executable file, e.g. '/Users/wsx/anaconda3/bin/python'.
version of SigProfilerExtractor
. If this
-package is not installed, the specified package will be installed.
-If this package is installed, this option is useless.
if TRUE
, order the import signatures by their exposures, e.g. the signature
-contributed the most exposure in all samples will be named as Sig1
.
mutational signature type.
For sigprofiler_extract()
, returns nothing. See output
directory.
For sigprofiler_import()
, a list
containing Signature
object.
A NMF matrix for input of sigprofiler_extract()
.
if (FALSE) {
- load(system.file("extdata", "toy_copynumber_tally_W.RData",
- package = "sigminer", mustWork = TRUE
- ))
-
- reticulate::conda_list()
-
- sigprofiler_extract(cn_tally_W$nmf_matrix, "~/test/test_sigminer",
- use_conda = TRUE
- )
-
- sigprofiler_extract(cn_tally_W$nmf_matrix, "~/test/test_sigminer",
- use_conda = FALSE, py_path = "/Users/wsx/anaconda3/bin/python"
- )
-}
-
-data("simulated_catalogs")
-sigprofiler_reorder(t(simulated_catalogs$set1))
Data from doi:10.1038/s43018-020-0027-5 -. -5 simulated mutation catalogs are used by the paper but only 4 are available. -The data are simulated from COSMIC mutational signatures 1, 2, 3, 5, 6, 8, -12, 13, 17 and 18. Each sample is a linear combination of 5 randomly selected -signatures with the addiction of Poisson noise. The number of mutation in -each sample is randomly selected between 1,000 and 50,000 mutations, in log -scale so that a lower number of mutations is more likely to be selected. -The proportion of each signature in each sample is also random.
-A list of matrix
-Generate from code under data_raw/
-data(simulated_catalogs)
simulate_signature()
- Simulate signatures from signature pool.
simulate_catalogue()
- Simulate catalogs from signature/catalog pool.
simulate_catalogue_matrix()
- Simulate a bootstrapped catalog matrix.
simulate_signature(x, weights = NULL)
-
-simulate_catalogue(x, n, weights = NULL)
-
-simulate_catalogue_matrix(x)
a numeric vector representing a signature/catalog or matrix with rows representing -signatures/samples and columns representing components.
a numeric vector for weights.
an integer indicating mutation number to be generated in a catalog.
a matrix
.
# Generate a catalog
-set.seed(1234)
-catalog <- as.integer(table(sample(1:96, 1000, replace = TRUE)))
-names(catalog) <- paste0("comp", 1:96)
-# Generate a signature
-sig <- catalog / sum(catalog)
-
-# Simulate catalogs
-x1 <- simulate_catalogue(catalog, 10) # 10 mutations
-x1
-x2 <- simulate_catalogue(catalog, 100) # 100 mutations
-x2
-x3 <- simulate_catalogue(catalog, 1000) # 1000 mutations
-x3
-# Similar with a signature
-x4 <- simulate_catalogue(sig, 10) # 10 mutations
-x4
-
-# Load SBS signature
-load(system.file("extdata", "toy_mutational_signature.RData",
- package = "sigminer", mustWork = TRUE
-))
-s <- t(sig2$Signature.norm)
-# Generate a signature from multiple signatures/catalogs
-s1 <- simulate_signature(s)
-s1
-s2 <- simulate_signature(s, weights = 1:3)
-s2
-# Generate a catalog from multiple signatures/catalogs
-c1 <- simulate_catalogue(s, 100, weights = 1:3)
-c1
Subset data
slot of CopyNumber object, un-selected rows will move to
-dropoff.segs slot, annotation slot will update in the same way.
# S3 method for CopyNumber
-subset(x, subset = TRUE, ...)
a CopyNumber object to be subsetted.
logical expression indicating rows to keep.
further arguments to be passed to or from other methods. -Useless here.
a CopyNumber object
-sym()
creates a symbol from a string and
-syms()
creates a list of symbols from a
-character vector.
enquo()
and
-enquos()
delay the execution of one or
-several function arguments. enquo()
returns a single quoted
-expression, which is like a blueprint for the delayed computation.
-enquos()
returns a list of such quoted expressions.
expr()
quotes a new expression locally. It
-is mostly useful to build new expressions around arguments
-captured with enquo()
or enquos()
:
-expr(mean(!!enquo(arg), na.rm = TRUE))
.
as_name()
transforms a quoted variable name
-into a string. Supplying something else than a quoted variable
-name is an error.
That's unlike as_label()
which also returns
-a single string but supports any kind of R object as input,
-including quoted function calls and vectors. Its purpose is to
-summarise that object into a single label. That label is often
-suitable as a default name.
If you don't know what a quoted expression contains (for instance
-expressions captured with enquo()
could be a variable
-name, a call to a function, or an unquoted constant), then use
-as_label()
. If you know you have quoted a simple variable
-name, or would like to enforce this, use as_name()
.
To learn more about tidy eval and how to use these tools, visit -https://dplyr.tidyverse.org/articles/programming.html and the -Metaprogramming -section of Advanced R.
-Merged Transcript Location at Genome Build mm9
-A data.table
from UCSC http://hgdownload.cse.ucsc.edu/goldenPath/mm9/database/transcriptome.txt.gz
-data(transcript.mm9)
Transform Copy Number Table
-a CopyNumber
object or a data.frame containing
-at least 'chromosome', 'start', 'end', 'segVal', 'sample' these columns.
genome build version, used when data
is a data.frame
, should be 'hg19' or 'hg38'.
annotation data type used for constructing matrix.
Optionally, a (scalar) value that specifies what each
-value
should be filled in with when missing.
This can be a named list if you want to apply different fill values to -different value columns.
Optionally, a function applied to the value in each cell
-in the output. You will typically use this when the combination of
-id_cols
and names_from
columns does not uniquely identify an
-observation.
This can be a named list if you want to apply different aggregations
-to different values_from
columns.
an integer to control the resolution.
-When it is 1
(default), compute frequency in each cytoband.
-When it is 2
, use compute frequency in each half cytoband.
a data.table
.
# \donttest{
-load(system.file("extdata", "toy_copynumber.RData",
- package = "sigminer", mustWork = TRUE
-))
-# Compute the mean segVal in each cytoband
-x <- transform_seg_table(cn, resolution_factor = 1)
-x
-# Compute the mean segVal in each half-cytoband
-x2 <- transform_seg_table(cn, resolution_factor = 2)
-x2
-# }
Set Color Style for Plotting
-use_color_style(
- style,
- mode = c("SBS", "copynumber", "DBS", "ID", "RS"),
- method = "Wang"
-)
one of 'default' and 'cosmic'.
only used when the style
is 'cosmic', can be one of
-"SBS", "copynumber", "DBS", "ID".
used to set a more custom palette for different methods.
color values.
-use_color_style("default")
-use_color_style("cosmic")