direct_gene_cna: Load the existed CNA gain/loss based on gene location.

Description Usage Arguments Value Custom reader function See Also Examples

View source: R/direct_gene_cna.R

Description

This function aims to complement create_gene_cna. Instead of mapping CNA records onto genes by genome reference, it reads the existed column containing the gene each CNA lies on. Two functions share the same interface but they have different requirement for the read_fun implementation.

Usage

1
2
3
direct_gene_cna(sample_desc, gain_threshold = log2(2.5) - 1,
  loss_threshold = log2(1.5) - 1, read_fun = NULL, progress = TRUE,
  progress_width = 48, parallel = FALSE, ...)

Arguments

sample_desc

data.table object created by create_sample_desc.

gain_threshold

CNA expression above this will be considered as gain region. By default \log_2{2.5} - 1

loss_threshold

CNA expression below this will be considered as loss region. By default \log_2{1.5} - 1

read_fun

Custom reader function, see its own section for more detail.

progress

Whether to display a progress bar. By default TRUE.

progress_width

The text width of the shown progress bar. By default is 48 chars wide.

parallel

Enable parallelism by plyr. One has to specify a parallel engine beforehand. See example for more information.

...

Arguments passed to the custom reader function specified in read_fun.

Value

data.table of CNA gain/loss on each gene region for all samples, whose rows represent regions of genes and columns are sample names. First column GENE contains the corresponding gene names.

Custom reader function

Similar to that of create_gene_cna, the reader function takes the filepath as the first argument. It will return a data.table with at least two columns: GENE and Segment_Mean of type character and numeric respectively.

See Also

create_gene_cna

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require(data.table)

## Create a CNA dataset that has been already mapped onto gene regions

cna_geo_list = list(
    sample_A = data.table(
        GENE = c("TP53", "BRCA2"),
        Segment_Mean = c(1.05, -2.03)
    ),
    sample_B = data.table(
        GENE = c("TP53", "BRCA2", "NDPH1"),
        Segment_Mean = c(0.38, -1.71, 2.6)
    )
)
sample_desc <- data.table(
    Sample = paste("sample", c("A", "B"), sep = "_")
)
sample_desc$CNA_filepath <- sample_desc$Sample


## Example code for reading

read_cna_geo <- function(pth) {
    # For demonstration, file reading silently redirects
    # to list lookup
    cna_geo_list[[pth]]
}
gene_cna <- direct_gene_cna(
    sample_desc,
    read_fun = read_cna_geo, progress = FALSE
)
gene_cna

iGC documentation built on Nov. 8, 2020, 6:49 p.m.