Skip to contents

CalculateACNs() calculates absolute copy numbers (ACNs) from the relative copy number profiles of one or more samples. There are several included options by which to do this. Note: If not providing a table of variant allele frequencies (VAFs) then 'mad' is the only method available.

This function makes use of the rascal package in R and instructions can be found in the vignette:
https://github.com/crukci-bioinformatics/rascal/blob/master/vignettes/rascal.Rmd

Usage

CalculateACNs(
  cnobj,
  acnmethod,
  rascal_sols = NULL,
  variants = NULL,
  acn_save_path = FALSE,
  return_sols = FALSE,
  return_S4 = FALSE,
  distance_decimal_places = 7
)

Arguments

cnobj

An S4 object of type QDNAseqCopyNumbers. This object must contain a copynumber slot and a segmented slot.

acnmethod

The method by which to calculate ACNs. Can be one of:
"maxvaf" - Calculate ACNs assuming the maximum discovered VAF for the sample is an appropriate representation for the tumour fraction.
char vector - Same as above but rather than using the max vaf provide a character vector of the genes from which to pull VAFs. The genes are assumed to be in order of decreasing precedence. ex. c('TP53', 'KRAS', 'PTEN')
"mad" - Calculate ACNs using the mean absolute difference (MAD) column from the solutions table.
If using variant allele frequencies from targeted panel sequencing or some other technology:

  • The variants must must be in a datatable/dataframe.

  • Required columns: sample_id, chromosome, start, end, gene_name, ref, alt, vaf.

  • Each row of said table must correspond to a unique variant.

  • Each variant must have an associated variant allele frequency.

  • Each row must also be associated with a specific sample.
    A dataframe of known ploidies per sample - Calculate ACNs at each bin given we already know the ploidy of the samples.

rascal_sols

A tsv or dataframe of the calculated rascal solutions.

variants

(optional) Dataframe or string. A table of variants containing variant allele frequencies per gene and per sample.

acn_save_path

(optional) String. The output path (absolute path recommended) where to save the result.

return_sols

(optional) Logical. Return the selected rascal solution.

return_S4

(optional) Logical.

distance_decimal_places

number of decimal places to compare to when finding the minimum distance.

Value

A list containing:

  1. A list of dataframes (one for each sample) OR a QDNAseq S4 object.

  2. Optionally, a dataframe of the rascal solutions.
    This function returns ACNs when a rascal solution is found, if one isn't, the sample is skipped.

Details

solutions <- "~/Documents/.../rascal_solutions.csv"
rcn.obj <- "~/repos/utanosmodellingdata/sample_copy_number_data/sample_filtered_cn_data.rds"
variants <- "~/Documents/.../allvariants.clinvar.cosmic.exons.csv"
save_path <- "~/Documents/.../rascal_ACN_segments.rds"
variants <- data.table::fread(file = variants, sep = ',')
variants <- variants %>% dplyr::rename(chromosome = chr,
                                       gene_name = genecode_gene_name)
outputs <- CalculateACNs(rcn.obj,
                         acn.method = 'maxvaf',
                         rascal_sols = solutions,
                         variants = variants,
                         return_sols = TRUE,
                         return_S4 = TRUE)
output <- CalculateACNs(rcn.obj,
                        rascal_sols = solutions,
                        variants = variants,
                        acnmethod = c('TP53', 'KRAS', 'BRCA1',
                                      'BRCA2', 'PIK3CA', 'PTEN'),
                        acn_save_path = save_path)
output <- CalculateACNs(rcn.obj,
                        rascal_sols = solutions,
                        acnmethod = 'mad')