read_copynumber: Read Absolute Copy Number Profile

View source: R/read_copynumber.R

read_copynumberR Documentation

Read Absolute Copy Number Profile

Description

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.

Usage

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,
  ...
)

Arguments

input

a data.frame or a file or a directory contains copy number profile.

pattern

an optional regular expression used to select part of files if input is a directory, more detail please see list.files() function.

ignore_case

logical. Should pattern-matching be case-insensitive?

seg_cols

four strings used to specify chromosome, start position, end position and copy number value in input, respectively. Default use names from ABSOLUTE calling result.

samp_col

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).

add_loh

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.

loh_min_len

The length cut-off for labeling a segment as 'LOH'. Default is ⁠10Kb⁠.

loh_min_frac

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%.

join_adj_seg

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.

skip_annotation

if TRUE, skip annotation step, it may affect some analysis and visualization functionality, but speed up reading data.

use_all

default is FALSE. If True, use all columns from raw input.

min_segnum

minimal number of copy number segments within a sample.

max_copynumber

bigger copy number within a sample will be reset to this value.

genome_build

genome build version, should be 'hg19', 'hg38', 'mm9' or 'mm10'.

genome_measure

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..

complement

if TRUE, complement chromosome (except 'Y') does not show in input data with normal copy 2.

...

other parameters pass to data.table::fread()

Value

a CopyNumber object.

Author(s)

Shixiang Wang w_shixiang@163.com

See Also

read_maf for reading mutation data to MAF object.

Examples

# Load toy dataset of absolute copynumber profile
load(system.file("extdata", "toy_segTab.RData",
  package = "sigminer", mustWork = TRUE
))


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


ShixiangWang/sigminer documentation built on March 16, 2024, 12:30 p.m.