Last data update: 2014.03.03

R: Compile segments across samples
compileCopyCountSegmentsR Documentation

Compile segments across samples

Description

A short function which extracts the segments of constant copy count using the copyCountSegments function on a named list of named lists containing fitted ExomeCopy objects. See vignette for a full example of multiple samples and chromosomes.

Usage

  compileCopyCountSegments(fit.list)

Arguments

fit.list

A named list of named lists. The outer list indexes patients, while the inner list indexes sequences/chromosomes.

Value

A RangedData object of all segments across samples and chromosomes.

Examples

  example(exomeCopy)

  # this function requires a named list of named lists
  # as constructed in the vignette
  fit.list <- list(sample1 = list(chr1 = fit))
  CNV.segments <- compileCopyCountSegments(fit.list)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(exomeCopy)
Loading required package: IRanges
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: Rsamtools
Loading required package: Biostrings
Loading required package: XVector
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/exomeCopy/compileCopyCountSegments.Rd_%03d_medium.png", width=480, height=480)
> ### Name: compileCopyCountSegments
> ### Title: Compile segments across samples
> ### Aliases: compileCopyCountSegments
> 
> ### ** Examples
> 
>   example(exomeCopy)

exmCpy> ## The following is an example of running exomeCopy on simulated
exmCpy> ## read counts using the model parameters defined above.  For an example
exmCpy> ## using real exome sequencing read counts (with simulated CNV) please
exmCpy> ## see the vignette.
exmCpy> 
exmCpy> ## create RangedData for storing genomic ranges and covariate data
exmCpy> ## (background, background stdev, GC-content)
exmCpy> 
exmCpy> m <- 5000

exmCpy> rdata <- RangedData(IRanges(start=0:(m-1)*100+1,width=100),
exmCpy+ space=rep("chr1",m), universe="hg19", log.bg=rnorm(m), log.bg.var=rnorm(m),
exmCpy+ gc=runif(m,30,50))  

exmCpy> ## create read depth distributional parameters mu and phi
exmCpy> rdata$gc.sq <- rdata$gc^2

exmCpy> X <- cbind(bg=rdata$log.bg,gc=rdata$gc,gc.sq=rdata$gc.sq)

exmCpy> Y <- cbind(bg.sd=rdata$log.bg.var)

exmCpy> beta <- c(5,1,.01,-.01)

exmCpy> gamma <- c(-3,.1)

exmCpy> rdata$mu <- exp(beta[1] + scale(X) %*% beta[2:4])

exmCpy> rdata$phi <- exp(gamma[1] + scale(Y) %*% gamma[2])

exmCpy> ## create observed counts with simulated heterozygous duplication
exmCpy> cnv.nranges <- 200

exmCpy> bounds <- (round(m/2)+1):(round(m/2)+cnv.nranges)

exmCpy> O <- rnbinom(nrow(rdata),mu=rdata$mu,size=1/rdata$phi)

exmCpy> O[bounds] <- O[bounds] + rbinom(cnv.nranges,prob=0.5,size=O[bounds])

exmCpy> rdata[["sample1"]] <- O

exmCpy> ## run exomeCopy() and list segments
exmCpy> fit <- exomeCopy(rdata,"sample1",X.names=c("log.bg","gc","gc.sq"))

exmCpy> # an example call with variance fitting.
exmCpy> # see paper: this does not necessarily improve the fit
exmCpy> fit <- exomeCopy(rdata,"sample1",X.names=c("log.bg","gc","gc.sq"),
exmCpy+                  Y.names="log.bg",fit.var=TRUE)

exmCpy> ## see man page for copyCountSegments() for summary of
exmCpy> ## the predicted segments of constant copy count, and
exmCpy> ## for plot.ExomeCopy() for plotting fitted objects
exmCpy> 
exmCpy> 
exmCpy> 
exmCpy> 
> 
>   # this function requires a named list of named lists
>   # as constructed in the vignette
>   fit.list <- list(sample1 = list(chr1 = fit))
>   CNV.segments <- compileCopyCountSegments(fit.list)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>