as_maftools_cohort: Convert a list of CNAqc object to a maftools object.

View source: R/maf.R

as_maftools_cohortR Documentation

Convert a list of CNAqc object to a maftools object.

Description

Like as_maftools_obj but for multiple CNAqc objects, it creates a unique [maftools](https://bioconductor.org/packages/release/bioc/html/maftools.html) object with all the samples at once.

Parameters have the same meaning as for function as_maftools_obj.

Usage

as_maftools_cohort(
  x,
  only_drivers = TRUE,
  CNA_genes = NULL,
  clinicalData = NULL,
  CNA_map_function = function(cn) {
     if (is.na(cn)) 
         return(NA)
     A =
    strsplit(cn, ":")[[1]][1]
     B = strsplit(cn, ":")[[1]][2]
     if (A == "NA" |
    is.na(A)) 
         return(NA)
     if (B == "NA" | is.na(B)) 
         return(NA)
  
      if (cn == "1:1") 
         return(NA)
     if (cn == "1:0") 
        
    return("LOH")
     if (cn == "2:0") 
         return("CNLOH")
     if (cn == "2:1") 

            return("Amplification")
     if (cn == "2:2") 
        
    return("Amplification")
     if (B == "0") 
         return("LOH")
    
    return("Amplification")
 }
)

Arguments

x

A list of CNAqc objects with MAF annotations.

only_drivers

If 'TRUE', only driver mutations are used, otherwised all. When 'TRUE', if drivers are not annotated, an error is thrown.

CNA_genes

Gene names (from MAF.Hugo_Symbol) for which we want to report the copy number value.

clinicalData

Clinical data in the format of the maftools package, in the form of a dataframe with a column '"Tumor_Sample_Barcode"' reporting sample names and a column for every clinical annotation to include.

CNA_map_function

A function that returns, for a copy number value in CNAqc format (e.g., '"1:0"') a label that is used by the MAF cohort. By default, for instance, '"1:0"' is mapped to '"LOH"', '"2:0"' to '"CNLOH"', '"2:1"' and '"2:2"' to '"Amplification"', and '"1:1"' to 'NA'. Use 'NA' to avoid reporting the copy number in the MAF cohort.

See Also

function augment_with_maf to add MAF annotations to a CNAqc object, to be used before running 'as_maftools_obj'.

Examples

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
}

caravagnalab/CNAqc documentation built on Oct. 31, 2024, 3:54 a.m.