### Install CNAqc Package Source: https://github.com/caravagnalab/cnaqc/blob/master/README.md Install the CNAqc package from GitHub using the devtools package. Ensure devtools is installed first if you haven't already. ```r # install.packages("devtools") devtools::install_github("caravagnalab/CNAqc") ``` -------------------------------- ### Get mCNAqc Statistics Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/get_mCNAqc_stats.html Example of how to call the get_mCNAqc_stats function. This example is conditional and will not run by default. ```r if (FALSE) get_mCNAqc_stats(x) # \dontrun{} ``` -------------------------------- ### Initialize CNAqc Object and Plot Segment Size Distribution Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/plot_segment_size_distribution.html This example demonstrates how to initialize a CNAqc object using example data and then plot the distribution of segment sizes. Ensure the 'CNAqc' package is loaded and example data is available. ```r data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) plot_segment_size_distribution(x) ``` -------------------------------- ### GNU GPL Notice for Interactive Program Start Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/LICENSE.html This is a template notice to be displayed when a program starts in interactive mode, informing users about its free software status and warranty. ```text Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details. ``` -------------------------------- ### Initialize CNAqc object and extract drivers Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/get_drivers.html This example demonstrates how to initialize a CNAqc object with example data and then use the `get_drivers` function to extract driver mutation information. It shows the expected output format. ```r data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) get_drivers(x) ``` -------------------------------- ### Load Example Data and Initialize CNAqc Object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/CNA_gene.html Loads the example dataset and initializes a CNAqc object. This is a prerequisite for using the CNA_gene function with sample data. ```R data('example_dataset_CNAqc', package = 'CNAqc') print(example_dataset_CNAqc) x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) ``` -------------------------------- ### Load and Print Example Dataset Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/init.html Loads the example dataset 'example_dataset_CNAqc' provided with the CNAqc package and prints its contents. This dataset includes mutations, copy number alterations, purity, and reference genome information. ```R data('example_dataset_CNAqc', package = 'CNAqc') print(example_dataset_CNAqc) ``` -------------------------------- ### Initialize CNAqc Object and Detect Overfragmentation Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/detect_arm_overfragmentation.html This example demonstrates how to initialize a CNAqc object with example data and then apply the detect_arm_overfragmentation function. It also shows the expected output messages during the process. ```R data('example_dataset_CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) #> #> ── CNAqc - CNA Quality Check ─────────────────────────────────────────────────── #> #> ℹ Using reference genome coordinates for: GRCh38. #> ✔ Found annotated driver mutations: TTN, CTCF, and TP53. #> ✔ Fortified calls for 12963 somatic mutations: 12963 SNVs (100%) and 0 indels. #> ! CNAs have no CCF, assuming clonal CNAs (CCF = 1). #> ✔ Fortified CNAs for 267 segments: 267 clonal and 0 subclonal. #> ✔ 12963 mutations mapped to clonal CNAs. x = detect_arm_overfragmentation(x) #> ℹ One-tailed Binomial test: 8 tests, alpha 0.01. Short segments: 0.2% of the reference arm. #> ✔ chr7p, p = 1.7179869184e-24 ~ 34 segments, 34 short. #> ✔ chr1p, p = 1.62738995200002e-15 ~ 24 segments, 23 short. #> ✔ chr11q, p = 2.4788992e-07 ~ 14 segments, 12 short. #> ✔ chr1q, p = 4.34176000000001e-08 ~ 13 segments, 12 short. #> ✔ chr12q, p = 4.34176000000001e-08 ~ 13 segments, 12 short. #> ✔ chr3q, p = 4.52608e-06 ~ 12 segments, 10 short. #> ✔ chr7q, p = 4.52608e-06 ~ 12 segments, 10 short. #> ✔ chr8p, p = 9.21599999999998e-07 ~ 11 segments, 10 short. #> ℹ 8 significantly overfragmented chromosome arms (alpha level 0.01). ``` -------------------------------- ### Example: Convert CNAqc objects to maftools object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/as_maftools_cohort.html This example demonstrates the typical workflow for converting CNAqc objects to a maftools object. It involves initializing a CNAqc object, augmenting it with MAF annotations from a VCF file, and then extracting the maftools object. ```R if(FALSE) { # Create your CNAqc object (omissis here) from an original "file.vcf" x = init(mutations = ..., cna = ..., purity = ...) # Offline, create your MAF annotations as file "file_vcf.maf" from "file.vcf" # vcf2maf file.vcf .... file_vcf.maf # Import into R/CNAqc x = augment_with_maf(x, maf = "file_vcf.maf") # Extraction x %>% as_maftools_obj } ``` -------------------------------- ### Load Example Dataset Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a1_Introduction.html Loads a template dataset provided by the CNAqc package for demonstration purposes. ```r # Load template data data('example_dataset_CNAqc', package = 'CNAqc') ``` -------------------------------- ### Example Usage of annotate_variants Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/annotate_variants.html Demonstrates how to use the annotate_variants function with example data. Load the CNAqc library, load an example dataset, extract mutations, and then annotate them. ```R library(CNAqc) data('example_dataset_CNAqc', package = 'CNAqc') mutations <- example_dataset_CNAqc$mutations mutations_annotated <- annotate_variants(mutations) ``` -------------------------------- ### Get Sample Names from CNAqc/mCNAqc Object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/get_sample_name.html Use this function to retrieve a vector of sample names from a CNAqc or mCNAqc object. The example provided is a non-runnable placeholder. ```R if (FALSE) get_sample_name(x) # \dontrun{} ``` -------------------------------- ### Load and Display Example PCAWG Data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a3_peaks_detection.html Loads the example PCAWG object from the CNAqc package and prints a summary of its contents, including clonal and subclonal copy number alterations, driver mutations, and peak QC results. This is the initial step for performing QC analysis. ```R library(CNAqc) # We work with the PCAWG object x = CNAqc::example_PCAWG print(x) ``` -------------------------------- ### Initialize CNAqc Object and Plot Genome-Wide Counts Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/plot_gw_counts.html This snippet demonstrates how to initialize a CNAqc object with example data and then plot the genome-wide mutation counts. It requires the 'CNAqc' package and example dataset. ```R data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) plot_gw_counts(x) ``` -------------------------------- ### Initialize CNAqc Object and Smooth Segments Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/smooth_segments.html This example demonstrates how to initialize a CNAqc object with example data and then apply the smooth_segments function to merge adjacent clonal copy number segments. It shows the state of the CNAqc object before and after smoothing, including plotting the smoothing results. ```r data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) # Before smoothing print(x) x = smooth_segments(x) # After smoothing plot_smoothing(x) ``` -------------------------------- ### Print PCAWG Example Data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a2_Plots.html This snippet prints the example PCAWG object from the CNAqc package, showing a summary of clonal and subclonal CNAs. ```r CNAqc::example_PCAWG %>% print() ``` -------------------------------- ### Print 'cnaqc' object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/print.cnaqc.html Demonstrates how to print an object of class 'cnaqc'. This example requires loading the 'example_PCAWG' dataset from the CNAqc package. ```R if (FALSE) { # # data('example_PCAWG', package = 'CNAqc') # # print(example_PCAWG) # } ``` -------------------------------- ### Initialize CNAqc object with example data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a8_annotate_variants.html Initializes a CNAqc object using example mutation, CNA, and purity data. It specifies the reference genome as 'hg19' and provides feedback on the data processing, including identified driver mutations and fortified calls. ```r # Dataset available with the package data('example_dataset_CNAqc', package = 'CNAqc') x = CNAqc::init( mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity, ref = 'hg19') #> #> ── CNAqc - CNA Quality Check ─────────────────────────────────────────────────── #> ℹ Using reference genome coordinates for: hg19. #> ✔ Found annotated driver mutations: TTN, CTCF, and TP53. #> ✔ Fortified calls for 12963 somatic mutations: 12963 SNVs (100%) and 0 indels. #> ! CNAs have no CCF, assuming clonal CNAs (CCF = 1). #> ✔ Fortified CNAs for 267 segments: 267 clonal and 0 subclonal. #> ✔ 12963 mutations mapped to clonal CNAs. ``` -------------------------------- ### Print m_cnaqc object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/print.m_cnaqc.html This snippet demonstrates how to print an object of class 'm_cnaqc'. It requires loading example data and then calling the print function on it. This example is wrapped in a \dontrun{} block, indicating it's for demonstration and might not be run by default. ```R data('example_multisample', package = 'CNAqc') print(example_multisample) ``` -------------------------------- ### Load and Inspect Example PCAWG Tumour Data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/example_PCAWG.html Loads the example PCAWG tumour data into an R session and prints a summary of the CNAqc object. This is useful for exploring subclonal CNAs and associated QC metrics. ```r data(example_PCAWG) example_PCAWG ``` -------------------------------- ### Load Example CNAqc Dataset Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/example_dataset_CNAqc.html Loads the example_dataset_CNAqc into the R environment. This dataset contains SNVs, CNAs, and purity information. ```R data(example_dataset_CNAqc) ``` -------------------------------- ### Initialize CNAqc Object and Subset SNVs Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/subset_snvs.html Demonstrates how to initialize a CNAqc object with example data and then use subset_snvs to filter for SNVs. This is useful for preparing data for SNV-focused analysis. ```r data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) subset_snvs(x) ``` -------------------------------- ### Inspect Example CNAqc Dataset Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/example_dataset_CNAqc.html Displays the contents of the loaded example_dataset_CNAqc. The dataset is a list containing mutations, copy number alterations (cna), purity, and reference genome information. ```R example_dataset_CNAqc ``` -------------------------------- ### Get PASS percentage from CNAqc object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/get_PASS_percentage.html This snippet demonstrates how to use the get_PASS_PASS_percentage function with a CNAqc object. It requires loading example data and shows the expected tibble output. ```R data("example_PCAWG", package = 'CNAqc') get_PASS_percentage(example_PCAWG) #> Joining with `by = join_by(QC_PASS)` #> # A tibble: 2 × 4 #> QC_PASS Length N_segments N_mutations #> #> 1 TRUE 0.437 0.164 0.437 #> 2 NA 0.563 0.836 0.563 ``` -------------------------------- ### Initialize CNAqc Object and Plot Icon CNA Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/plot_icon_CNA.html This snippet demonstrates how to initialize a CNAqc object using example data and then generate a circular plot of clonal CNAs using the plot_icon_CNA function. Ensure the CNAqc package is installed and loaded. ```r data('example_dataset_CNAqc', package = 'CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) plot_icon_CNA(x) ``` -------------------------------- ### Install Bioconductor Packages for Variant Annotation Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a8_annotate_variants.html Installs required Bioconductor packages for variant annotation, including transcript databases, genome sequences, and utility packages. Ensure BiocManager is installed first. ```R # Reference against which we mapped the reads reference_genome <- example_dataset_CNAqc$reference # All those packages are distributed in Bioconductor if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager", repos="http://cran.us.r-project.org") # We have to install the corresponding txdb package for transcript annotations paste0("TxDb.Hsapiens.UCSC.",reference_genome,".knownGene") %>% BiocManager::install() # We have to install also the BS database for the sequences (it may take some time) paste0("BSgenome.Hsapiens.UCSC.",reference_genome) %>% BiocManager::install() # Then these two packages provide useful utilities to deal with biological databases "Organism.dplyr" %>% BiocManager::install() #> #> The downloaded binary packages are in #> /var/folders/d_/4f5j5g5d48xbfygg74bn6wyh0000gn/T//RtmpCn5CLa/downloaded_packages "org.Hs.eg.db" %>% BiocManager::install() ``` -------------------------------- ### Initializing CNAqc with Sequenza Output Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a7_example_MSeq.html Loads Sequenza output for a low-cellularity sample and initializes the CNAqc object. This involves loading segments and purity information from Sequenza and then using CNAqc::init to prepare the data for analysis. ```r # Low cellularity solution sequenza (bad calls) Sequenza_bad_calls = load_SQ_output(Sequenza_URL, sample = 'Set6_42', run = 'lowcell') # CNA segments and purity cna = Sequenza_bad_calls$segments purity = Sequenza_bad_calls$purity # CNAqc data object x = CNAqc::init( mutations = snvs, cna = cna, purity = purity, ref = "GRCh38") %>% CNAqc::analyze_peaks(matching_strategy = 'closest') ``` -------------------------------- ### Example Tumor Purity Value Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a1_Introduction.html Shows an example of a single numeric value representing tumor purity, which is the percentage of reads from tumor cells, ranging from 0 to 1. ```r print(example_dataset_CNAqc$purity) #> [1] 0.89 ``` -------------------------------- ### Post-process seqz File by Binning with Sequenza Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a9_automatic.html This command takes the generated 'seqz' file and bins it, preparing it for normalization and segmentation. Specify the input 'seqz' file and desired output file name. ```bash sequenza-utils seqz_binning --seqz out.seqz.gz -w 50 -o out small.seqz.gz ``` -------------------------------- ### Convert CNAqc object to maftools object Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/as_maftools_obj.html This example demonstrates the process of converting a CNAqc object to a maftools object. It includes steps for initializing the CNAqc object, augmenting it with MAF annotations (assuming an external vcf2maf conversion), and finally performing the conversion using as_maftools_obj. ```R if(FALSE) { # Create your CNAqc object (omissis here) from an original "file.vcf" x = init(mutations = ..., cna = ..., purity = ...) # Offline, create your MAF annotations as file "file_vcf.maf" from "file.vcf" # vcf2maf file.vcf .... file_vcf.maf # Import into R/CNAqc x = augment_with_maf(x, maf = "file_vcf.maf") # Extraction x %>% as_maftools_obj } ``` -------------------------------- ### Load and Print Sequenza Data for a Sample Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a7_example_MSeq.html Loads Sequenza copy number data for a specific sample and run, then prints the loaded segments, purity, and ploidy. ```R Sequenza_URL = "https://raw.githubusercontent.com/caravagnalab/CNAqc_datasets/main/MSeq_Set06/Copy%20Number/" # Final sequenza run (good calls) Sequenza_good_calls = load_SQ_output(Sequenza_URL, sample = 'Set6_42', run = 'final') print(Sequenza_good_calls) ``` -------------------------------- ### Standard GNU GPL Notice for Source Files Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/LICENSE.html This is a template notice to be included at the beginning of each source file of a program to ensure it is free software and to state the exclusion of warranty. ```text Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Initialize mCNAqc Object with Multiple Samples Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/b10_MultiCNAqc.html Use `multisample_init` to create a multi-sample CNAqc object. Set `QC_filter` to TRUE to use only segments passing quality control across samples. `keep_original` preserves the initial CNAqc objects, and `discard_private` controls whether to retain mutations present in all samples. ```R example_multisample = CNAqc::multisample_init(cnaqc_objs = CNAqc_samples, QC_filter = TRUE, # use only segments passing QC keep_original = TRUE, # keep the original CNAqc objects too discard_private = FALSE) # keep also not private mutations among the samples ``` -------------------------------- ### Compute WT and mutant alleles per gene Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/wt_mutant_alleles.html This example demonstrates how to use the wt_mutant_alleles function with a CNAqc object that has MAF annotations. It includes steps for initializing the CNAqc object, augmenting it with MAF data, and then calling the wt_mutant_alleles function. ```R if(FALSE) { # Create your CNAqc object (omissis here) from an original "file.vcf" x = init(mutations = ..., cna = ..., purity = ...) # Offline, create your MAF annotations as file "file_vcf.maf" from "file.vcf" # vcf2maf file.vcf .... file_vcf.maf # Import into R/CNAqc x = augment_with_maf(x, maf = "file_vcf.maf") # check they are in (there should be many columns with "MAF." prefix) x %>% Mutations %>% colnames # With MAF-imported that is the target column wt_mutant_alleles(x, gene_column = 'MAF.Hugo_Symbol') } ``` -------------------------------- ### Load CNAqc Package Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a6_fragmentation.html Loads the CNAqc package in R. Ensure the package is installed before running. ```R library(CNAqc) #> ✔ Loading CNAqc, 'Copy Number Alteration quality check'. Support : ``` -------------------------------- ### Initialize Multiple CNAqc Objects Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/b10_MultiCNAqc.html Create a list of CNAqc objects, one for each sample, by providing mutations, CNA data, purity, and sample name. Ensure the reference genome is specified. List names must match sample names. ```R CNAqc_samples = lapply(names(sample_mutations), function(x) { CNAqc::init(mutations = sample_mutations[[x]], cna = cna[[x]], purity = purity[[x]], sample = x, ref = "GRCh38") }) names(CNAqc_samples) = sapply(CNAqc_samples, function(x) {x$sample}) ``` -------------------------------- ### Available Data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/index.html Lists and describes the datasets included within the CNAqc package, such as chromosome coordinates and example datasets. ```APIDOC ## Available Data This section lists and describes the datasets included within the CNAqc package. * `chr_coordinates_hg19`: Coordinates for hg19 chromosomes. * `chr_coordinates_GRCh38`: Coordinates for GRCh38 chromosomes. * `chr_coordinates_GRCm38`: Coordinates for GRCm38 chromosomes. * `example_dataset_CNAqc`: Example CNAqc dataset. * `fpr_test`: Data (simulation performance) from the training set to auto-tune epsilon. * `example_PCAWG`: Example PCAWG tumour. * `intogen_drivers`: List of Intogen driver genes per tumour type. * `gene_coordinates_hg19`: Coordinates for hg19 genes. * `gene_coordinates_GRCh38`: Coordinates for GRCh38 genes. ``` -------------------------------- ### Generate GC Wiggle Track File with Sequenza Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a9_automatic.html This command processes a FASTA file to create a GC Wiggle track file, a prerequisite for Sequenza's BAM processing. Ensure the FASTA file path and output file name are correctly specified. ```bash sequenza-utils gc_wiggle --fasta hg19.fa -o hg19.gc50Base.wig.gz ``` -------------------------------- ### Load CNAqc Package and Dependencies Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/articles/a1_Introduction.html Loads the CNAqc package and the dplyr package for data manipulation. Ensure these packages are installed before running. ```r library(CNAqc) #> ✔ Loading CNAqc, 'Copy Number Alteration quality check'. Support : require(dplyr) #> Loading required package: dplyr #> #> Attaching package: 'dplyr' #> The following objects are masked from 'package:stats': #> #> filter, lag #> The following objects are masked from 'package:base': #> #> intersect, setdiff, setequal, union ``` -------------------------------- ### Initialize CNAqc object and augment with SBS data Source: https://github.com/caravagnalab/cnaqc/blob/master/docs/reference/SBS.html Initializes a CNAqc object with mutation and CNA data, then augments it with SBS data for mutational signature deconvolution. This example demonstrates the typical workflow for preparing SBS data. ```R if (FALSE) { # \dontrun{ data('example_dataset_CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna =example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) x = SBS(x) # All SBS data print(x$SBS) } # } ```