### Example Usage of plot_segment_size_distribution Source: https://caravagnalab.github.io/CNAqc/reference/plot_segment_size_distribution.html Demonstrates how to initialize a CNAqc object with example data and then plot the segment size distribution. 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_segment_size_distribution(x) ``` -------------------------------- ### Example usage of print.m_cnaqc Source: https://caravagnalab.github.io/CNAqc/reference/print.m_cnaqc.html Demonstrates how to print an object of class 'm_cnaqc'. This example requires loading sample data. ```r if (FALSE) { # \dontrun{ data('example_multisample', package = 'CNAqc') print(example_multisample) } # } ``` -------------------------------- ### Example usage of print.cnaqc Source: https://caravagnalab.github.io/CNAqc/reference/print.cnaqc.html Demonstrates how to print an object of class 'cnaqc'. Load the example data first. ```R if (FALSE) { # \dontrun{ data('example_PCAWG', package = 'CNAqc') print(example_PCAWG) } # } ``` -------------------------------- ### Install CNAqc Package Source: https://caravagnalab.github.io/CNAqc/index.html Install the CNAqc package from GitHub using the devtools package. Ensure devtools is installed first. ```r # install.packages("devtools") devtools::install_github("caravagnalab/CNAqc") ``` -------------------------------- ### Example: Initialize CNAqc and Detect Overfragmentation Source: https://caravagnalab.github.io/CNAqc/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 to analyze arm-level fragmentation. The output indicates significantly overfragmented chromosome arms. ```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.627389952e-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). # Report to console print(x) #> ── [ CNAqc ] MySample 12963 mutations in 267 segments (267 clonal, 0 subclonal). #> #> ── Clonal CNAs #> #> 2:2 [n = 7478, L = 1483 Mb] ■■■■■■■■■■■■■■■■■■■■■■■■■■■ { CTCF } #> 4:2 [n = 1893, L = 331 Mb] ■■■■■■■ #> 3:2 [n = 1625, L = 357 Mb] ■■■■■■ #> 2:1 [n = 1563, L = 420 Mb] ■■■■■■ { TTN } #> 3:0 [n = 312, L = 137 Mb] ■ #> 2:0 [n = 81, L = 39 Mb] { TP53 } #> 16:2 [n = 4, L = 0 Mb] #> 25:2 [n = 2, L = 1 Mb] #> 3:1 [n = 2, L = 1 Mb] #> 106:1 [n = 1, L = 0 Mb] #> #> ℹ Sample Purity: 89% ~ Ploidy: 4. #> #> ℹ There are 3 annotated driver(s) mapped to clonal CNAs. #> chr from to ref alt DP NV VAF driver_label is_driver #> chr2 179431633 179431634 C T 117 77 0.6581197 TTN TRUE #> chr16 67646006 67646007 C T 120 54 0.4500000 CTCF TRUE #> chr17 7577106 7577107 G C 84 78 0.9285714 TP53 TRUE #> ✔ Arm-level fragmentation analysis: 8 segments overfragmented. ``` -------------------------------- ### Example Usage of get_sample_name Source: https://caravagnalab.github.io/CNAqc/reference/get_sample_name.html Demonstrates how to call the get_sample_name function with a CNAqc or mCNAqc object. This example is typically run interactively and is marked as dontrun. ```R if (FALSE) get_sample_name(x) # \dontrun{} ``` -------------------------------- ### Example Usage of as_maftools_obj Source: https://caravagnalab.github.io/CNAqc/reference/as_maftools_obj.html Demonstrates the workflow of creating a CNAqc object, augmenting it with MAF annotations, and then converting it to a maftools object. This example is conditional and will only run if FALSE is set to TRUE. ```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 } ``` -------------------------------- ### Initialize CNAqc Object and Plot Smoothed Segments Source: https://caravagnalab.github.io/CNAqc/reference/plot_smoothing.html Initializes a CNAqc object with example data and then plots the segments before and after smoothing. 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) # Smooth x = smooth_segments(x) # View differences plot_smoothing(x) ``` -------------------------------- ### Example Usage of get_PASS_percentage Source: https://caravagnalab.github.io/CNAqc/reference/get_PASS_percentage.html Demonstrates how to use the get_PASS_percentage function with example data. It returns a tibble indicating the proportion of segments that passed QC. ```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 ``` -------------------------------- ### Load and Print Example Dataset Source: https://caravagnalab.github.io/CNAqc/reference/init.html Loads the example dataset 'example_dataset_CNAqc' from the CNAqc package and prints its contents to the console. This dataset includes mutation data, CNA information, sample purity, and the reference genome. ```r data('example_dataset_CNAqc', package = 'CNAqc') print(example_dataset_CNAqc) ``` -------------------------------- ### Initialize CNAqc Object and Plot VAFs Source: https://caravagnalab.github.io/CNAqc/reference/plot_gw_vaf.html Initializes a CNAqc object with example data and then plots the genome-wide VAFs. Requires the 'CNAqc' package and its 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_vaf(x) ``` -------------------------------- ### Example Usage of get_mCNAqc_stats Source: https://caravagnalab.github.io/CNAqc/reference/get_mCNAqc_stats.html An example demonstrating how to use the get_mCNAqc_stats function. This code is intended for interactive use and is wrapped in a conditional to prevent execution during package checks. ```r if (FALSE) get_mCNAqc_stats(x) # \dontrun{} ``` -------------------------------- ### Load Example Dataset and Initialize CNAqc Object Source: https://caravagnalab.github.io/CNAqc/reference/CNA_gene.html Loads the example dataset provided with the CNAqc package and initializes a CNAqc object. This is a prerequisite for running other functions like CNA_gene. ```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) ``` -------------------------------- ### Annotate Variants Example Source: https://caravagnalab.github.io/CNAqc/reference/annotate_variants.html Example of how to use the annotate_variants function with a sample dataset. Ensure the CNAqc library is loaded and example data is available. ```R if (FALSE) { # \dontrun{ library(CNAqc) data('example_dataset_CNAqc', package = 'CNAqc') mutations <- example_dataset_CNAqc$mutations mutations_annotated <- annotate_variants(mutations) } # } ``` -------------------------------- ### Example: wt_mutant_alleles with MAF annotations Source: https://caravagnalab.github.io/CNAqc/reference/wt_mutant_alleles.html This example demonstrates how to use wt_mutant_alleles with a CNAqc object that has MAF annotations. It includes steps for initializing the object, augmenting with MAF, and then calling the function. ```r # Example with a CNAqc input object, and MAF annotations 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') } ``` -------------------------------- ### Example Usage of multisample_init Source: https://caravagnalab.github.io/CNAqc/reference/multisample_init.html Demonstrates how to call the multisample_init function with sample data and specific filtering options. After initialization, the resulting multisamples object can be inspected. ```R if (FALSE) { # \dontrun{ multisamples = CNAqc::multisample_init(cnaqc_objs = CNAqc_samples, QC_filter = TRUE, keep_original = FALSE, discard_private = FALSE) multisamples } # } ``` -------------------------------- ### Initialize CNAqc Object and Detect Overfragmentation Source: https://caravagnalab.github.io/CNAqc/reference/plot_arm_fragmentation.html This example demonstrates how to initialize a CNAqc object with example data and then detect significantly overfragmented chromosome arms using a specified genome percentage cutoff. It requires the 'CNAqc' package and its 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) #> #> ── 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, genome_percentage_cutoff = .2) #> ℹ 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.627389952e-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). ``` -------------------------------- ### Loading PCAWG Example Data Source: https://caravagnalab.github.io/CNAqc/articles/a2_Plots.html Loads the example PCAWG dataset provided by the CNAqc package. This data can be used for testing or demonstrating cohort-level analyses. ```R z = CNAqc::example_PCAWG ``` -------------------------------- ### Initialize CNAqc Object and Plot All Chromosomes Source: https://caravagnalab.github.io/CNAqc/reference/plot_karyotypes.html Demonstrates initializing a CNAqc object with example data and then plotting karyotypes for all chromosomes using the default settings. ```R data('example_dataset_CNAqc', package = '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. # All chromosomes (default) plot_karyotypes(x) #> Warning: Ignoring unknown parameters: `size` ``` -------------------------------- ### Initialize CNAqc Object with Example Data Source: https://caravagnalab.github.io/CNAqc/articles/a2_Plots.html Initializes the CNAqc object using an example dataset included with the package. This prepares the data for quality checks and plotting. The reference genome is set to 'hg19'. ```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(x) #> ── [ CNAqc ] MySample 12963 mutations in 267 segments (267 clonal, 0 subclonal). #> #> ── Clonal CNAs #> #> 2:2 [n = 7478, L = 1483 Mb] ■■■■■■■■■■■■■■■■■■■■■■■■■■■ { CTCF } #> 4:2 [n = 1893, L = 331 Mb] ■■■■■■■ #> 3:2 [n = 1625, L = 357 Mb] ■■■■■■ #> 2:1 [n = 1563, L = 420 Mb] ■■■■■■ { TTN } #> 3:0 [n = 312, L = 137 Mb] ■ #> 2:0 [n = 81, L = 39 Mb] { TP53 } #> 16:2 [n = 4, L = 0 Mb] #> 25:2 [n = 2, L = 1 Mb] #> 3:1 [n = 2, L = 1 Mb] #> 106:1 [n = 1, L = 0 Mb] #> ℹ Sample Purity: 89% ~ Ploidy: 4. #> ℹ There are 3 annotated driver(s) mapped to clonal CNAs. #> chr from to ref alt DP NV VAF driver_label is_driver #> chr2 179431633 179431634 C T 117 77 0.6581197 TTN TRUE #> chr16 67646006 67646007 C T 120 54 0.4500000 CTCF TRUE #> chr17 7577106 7577107 G C 84 78 0.9285714 TP53 TRUE ``` -------------------------------- ### Initialize CNAqc Object and Plot Source: https://caravagnalab.github.io/CNAqc/reference/plot_gw_counts.html Initializes a CNAqc object using example data and then plots the genome-wide mutation counts. 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) #> #> ── 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. plot_gw_counts(x) ``` -------------------------------- ### Initialize CNAqc with Example Data Source: https://caravagnalab.github.io/CNAqc/reference/init.html Initializes the CNAqc object using the loaded example dataset. This function processes mutations, CNAs, and purity to perform quality checks and prepare the data for further analysis. The output is stored in the 'x' variable. ```r x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) ``` -------------------------------- ### Load Example PCAWG Data Source: https://caravagnalab.github.io/CNAqc/reference/example_PCAWG.html Loads the example PCAWG dataset into the R environment. This dataset contains subclonal CNAs called by Battenberg for a PCAWG sample. ```r data(example_PCAWG) ``` -------------------------------- ### Load Example CNAqc Dataset Source: https://caravagnalab.github.io/CNAqc/reference/example_dataset_CNAqc.html Loads the `example_dataset_CNAqc` dataset into the R environment. This dataset is used for demonstrating CNAqc functionalities. ```r data(example_dataset_CNAqc) ``` -------------------------------- ### Initialize CNAqc Object with Example Data Source: https://caravagnalab.github.io/CNAqc/articles/a8_annotate_variants.html Initializes a CNAqc object using example mutation, CNA, and purity data. It specifies the reference genome as 'hg19' and reports on the number of mutations and CNAs found. ```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. # What we annotate x %>% Mutations #> # A tibble: 12,963 × 17 #> chr from to ref alt NV DP VAF FILTER ANNOVAR_FUNCTION #> #> 1 chr1 1027104 1027105 T G 6 60 0.1 PASS UTR5 #> 2 chr1 2248588 2248589 A C 9 127 0.0709 PASS intergenic #> 3 chr1 2461999 2462000 G A 65 156 0.417 PASS upstream #> 4 chr1 2727935 2727936 T C 90 180 0.5 PASS downstream #> 5 chr1 2763397 2763398 C T 61 183 0.333 PASS intergenic #> 6 chr1 2768208 2768209 C T 130 203 0.640 PASS intergenic #> 7 chr1 2935590 2935591 C T 132 228 0.579 PASS intergenic #> 8 chr1 2980032 2980033 C T 85 196 0.434 PASS ncRNA_exonic #> 9 chr1 3387161 3387162 T G 6 124 0.0484 PASS intronic #> 10 chr1 3502517 3502518 G A 10 88 0.114 PASS intronic #> # ℹ 12,953 more rows #> # ℹ 7 more variables: GENE , is_driver , driver_label , #> # type , karyotype , segment_id , cna ``` -------------------------------- ### Extracting Mutations from Example Data Source: https://caravagnalab.github.io/CNAqc/reference/Mutations.html Example of loading sample PCAWG data and extracting all mutations using the Mutations function. This demonstrates the basic usage and the structure of the returned tibble. ```r data("example_PCAWG", package = 'CNAqc') Mutations(example_PCAWG) ``` -------------------------------- ### Initialize CNAqc Object and Plot Default Histogram Source: https://caravagnalab.github.io/CNAqc/reference/plot_data_histogram.html Initializes a CNAqc object using example data and then plots the default histogram, which is the Variant Allele Frequency (VAF). 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) #> #> ── 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. # Default plot plot_data_histogram(x) #> Warning: Removed 8 rows containing missing values or values outside the scale range #> (`geom_bar()`). ``` -------------------------------- ### Example Usage of plot.cnaqc Source: https://caravagnalab.github.io/CNAqc/reference/plot.cnaqc.html Demonstrates how to plot CNA segments in wide format using the 'plot.cnaqc' function with sample data. Ensure the 'CNAqc' package is loaded and example data is available. ```R if (FALSE) { # \dontrun{ data('example_PCAWG', package = 'CNAqc') plot(example_PCAWG) } # } ``` -------------------------------- ### Example Usage of plot_SBS Source: https://caravagnalab.github.io/CNAqc/reference/plot_SBS.html Demonstrates how to initialize a CNAqc object, assign SBS contexts, and then plot the SBS counts using `plot_SBS`. Requires the 'example_dataset_CNAqc' dataset. ```R data('example_dataset_CNAqc') x = init(mutations = example_dataset_CNAqc$mutations, cna = example_dataset_CNAqc$cna, purity = example_dataset_CNAqc$purity) x = SBS(x) # SBS plot plot_SBS(x) ``` -------------------------------- ### GNU GPL Interactive Mode Notice Source: https://caravagnalab.github.io/CNAqc/LICENSE.html A short 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. ``` -------------------------------- ### Example Usage of plot.m_cnaqc Source: https://caravagnalab.github.io/CNAqc/reference/plot.m_cnaqc.html This example demonstrates the usage of the plot function for 'm_cnaqc' objects. The code is wrapped in a conditional `if (FALSE)` to prevent execution during standard package checks, indicating it's intended for manual testing or specific scenarios. ```R if (FALSE) { # \dontrun{ } # } ``` -------------------------------- ### Load CNAqc and Supporting Packages Source: https://caravagnalab.github.io/CNAqc/articles/a7_example_MSeq.html Loads the CNAqc package and essential supporting packages like dplyr and vcfR. Ensure these packages are installed before running. ```r library(CNAqc) #> ✔ Loading CNAqc, 'Copy Number Alteration quality check'. Support : # Extra packages 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 require(vcfR) #> Loading required package: vcfR #> #> ***** *** vcfR *** ***** #> This is vcfR 1.15.0 #> browseVignettes('vcfR') # Documentation #> citation('vcfR') # Citation #> ***** ***** ***** ***** ``` -------------------------------- ### Load CNAqc Package Source: https://caravagnalab.github.io/CNAqc/articles/a5_smoothing.html Loads the CNAqc R package. Ensure the package is installed before running. ```r library(CNAqc) #> ✔ Loading CNAqc, 'Copy Number Alteration quality check'. Support : ``` -------------------------------- ### Get Drivers with Default Parameters Source: https://caravagnalab.github.io/CNAqc/reference/get_drivers.html Extracts driver mutations with default parameters (all chromosomes, VAF values). Requires initialization of a CNAqc object. ```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) ``` -------------------------------- ### Initialize CNAqc object and run QC analysis Source: https://caravagnalab.github.io/CNAqc/reference/plot_qc.html This example demonstrates the complete workflow for preparing data and running quality control analysis using CNAqc. It includes initializing the object with mutation, CNA, and purity data, followed by peak analysis and CCF computation, before finally plotting the QC summary. ```r data('example_dataset_CNAqc', package = '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 = analyze_peaks(x) #> #> ── Peak analysis: simple CNAs ────────────────────────────────────────────────── #> #> ℹ Analysing 9041 mutations mapping to karyotype(s) 2:1 and 2:2. #> ℹ Mixed type peak detection for karyotype 2:1 (1563 mutations) #> ℹ Mixed type peak detection for karyotype 2:2 (7478 mutations) #> # A tibble: 4 × 16 #> # Rowwise: #> mutation_multiplicity karyotype peak delta_vaf x y counts_per_bin #> #> 1 1 2:1 0.308 0.0120 0.306 3.60 59 #> 2 2 2:1 0.616 0.0239 0.600 2.93 60 #> 3 1 2:2 0.235 0.00700 0.24 0.85 65 #> 4 2 2:2 0.471 0.0140 0.461 8.13 625 #> # ℹ 9 more variables: discarded , from , offset_VAF , #> # offset , weight , epsilon , VAF_tolerance , #> # matched , QC #> ✔ Peak detection PASS with r = 0.00838466599059723 - maximum purity error ε = 0.05. #> Joining with `by = join_by(Major, minor)` #> Joining with `by = join_by(karyotype)` #> #> ── Peak analysis: complex CNAs ───────────────────────────────────────────────── #> #> ℹ Karyotypes 3:0, 3:2, and 4:2 with >100 mutation(s). Using epsilon = 0.05. #> # A tibble: 3 × 5 #> # Groups: karyotype, matched [3] #> karyotype n matched mismatched prop #> #> 1 3:0 312 3 0 1 #> 2 3:2 1625 3 0 1 #> 3 4:2 1893 4 0 1 #> Adding missing grouping variables: `matched` #> Joining with `by = join_by(Major, minor, QC_PASS)` #> Adding missing grouping variables: `matched` #> Joining with `by = join_by(karyotype, QC_PASS)` #> #> ── Peak analysis: subclonal CNAs ─────────────────────────────────────────────── #> #> ℹ No subclonal CNAs in this sample. x = compute_CCF(x) #> Warning: Some karyotypes have fewer than25and will not be analysed. #> ── Computing mutation multiplicity for karyotype 2:0 using the entropy method. ─ #> ℹ Expected Binomial peak(s) for these calls (1 and 2 copies): 0.445 and 0.89 #> ℹ Mixing pre/ post aneuploidy: 0.09 and 0.91 #> ℹ Not assignamble area: [0.631578947368421; 0.723684210526316] #> ── Computing mutation multiplicity for karyotype 2:1 using the entropy method. ─ #> ℹ Expected Binomial peak(s) for these calls (1 and 2 copies): 0.307958477508651 and 0.615916955017301 #> ℹ Mixing pre/ post aneuploidy: 0.55 and 0.45 #> ℹ Not assignamble area: [0.423423423423423; 0.504504504504504] #> ── Computing mutation multiplicity for karyotype 2:2 using the entropy method. ─ #> ℹ Expected Binomial peak(s) for these calls (1 and 2 copies): 0.235449735449735 and 0.470899470899471 #> ℹ Mixing pre/ post aneuploidy: 0.09 and 0.91 #> ℹ Not assignamble area: [0.290780141843972; 0.368794326241135] plot_qc(x) ``` -------------------------------- ### Install Bioconductor Annotation Packages Source: https://caravagnalab.github.io/CNAqc/articles/a8_annotate_variants.html Installs necessary Bioconductor packages for variant annotation, including transcript databases and genome sequences. This is a one-time installation that may take time due to data size. ```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") #> #> The downloaded binary packages are in #> /var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T//RtmpO1cbTI/downloaded_packages # 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() "org.Hs.eg.db" %>% BiocManager::install() ``` -------------------------------- ### Initialize CNAqc object and augment with SBS data Source: https://caravagnalab.github.io/CNAqc/reference/SBS.html This example demonstrates initializing a CNAqc object with mutation, CNA, and purity data, and then augmenting it with SBS data. It shows how to access the generated SBS data after the operation. ```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) } # } ``` -------------------------------- ### Example: Plotting Shared CNA Segments Source: https://caravagnalab.github.io/CNAqc/reference/plot_segments_multisample.html Demonstrates how to plot the shared CNA segments using the plot_segments_multisample function. This example is typically run interactively and is guarded by a \dontrun{} block. ```r if (FALSE) { # \dontrun{ plot_segments_multisample(x, which = "shared") } # } ``` -------------------------------- ### Loading Sequenza output for alternative solutions Source: https://caravagnalab.github.io/CNAqc/articles/a7_example_MSeq.html Loads output from Sequenza for a specific sample and run to analyze alternative ploidy solutions. This is useful for identifying incorrect ploidy assignments. ```r Sequenza_bad_calls = load_SQ_output(Sequenza_URL, sample = 'Set6_42', run = 'tetra') ``` -------------------------------- ### Display Example PCAWG Data Source: https://caravagnalab.github.io/CNAqc/articles/a2_Plots.html Prints the example PCAWG object to display a summary of clonal and subclonal copy number aberrations. This includes counts, lengths, and associated genes for each CNA state. ```r CNAqc::example_PCAWG %>% print() ``` -------------------------------- ### Initialize Multi-Sample CNAqc Object Source: https://caravagnalab.github.io/CNAqc/articles/b10_MultiCNAqc.html Use `multisample_init` to create a `mCNAqc` object from multiple `CNAqc` objects. Set `QC_filter = TRUE` to use only segments passing quality control, `keep_original = TRUE` to retain the original `CNAqc` objects, and `discard_private = FALSE` to include mutations not private to 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 ``` -------------------------------- ### View Example CNAqc Dataset Structure Source: https://caravagnalab.github.io/CNAqc/reference/example_dataset_CNAqc.html Displays the loaded `example_dataset_CNAqc`. This dataset includes mutations, copy number alterations (CNAs), purity, and reference genome information. ```r data(example_dataset_CNAqc) example_dataset_CNAqc ``` -------------------------------- ### Initialize CNAqc and Subset Segments with Zero Minimum Mutations Source: https://caravagnalab.github.io/CNAqc/reference/subset_by_segment_minmutations.html Demonstrates initializing a CNAqc object and then applying the subset_by_segment_minmutations function with a minimum mutation count of 0. A minimum of 0 mutations has no effect on the data. ```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_by_segment_minmutations(x, 0) ``` -------------------------------- ### Example: Augmenting a CNAqc Object with MAF Annotations Source: https://caravagnalab.github.io/CNAqc/reference/augment_with_maf.html This example demonstrates how to augment an existing CNAqc object with MAF annotations. Ensure your MAF file is generated using vcf2maf. The function will add MAF-related columns to the mutations data within the CNAqc object. ```R # Example with a CNAqc input object 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 } ``` -------------------------------- ### Get PASS Percentage Function Signature Source: https://caravagnalab.github.io/CNAqc/reference/get_PASS_percentage.html This shows the basic function signature for get_PASS_percentage. ```R get_PASS_percentage(x) ```