Last data update: 2014.03.03

R: Segments of identical copy count from exomeCopy
copyCountSegmentsR Documentation

Segments of identical copy count from exomeCopy

Description

Unpacks an ExomeCopy object and returns a RangedData object with segments of identical predicted copy count in genomic coordinates.

Usage

  copyCountSegments(object)

Arguments

object

ExomeCopy object

Details

The log odds column is calculated by summing the log ratios over the contained ranges. The log ratios at each range is the log of the emission probability for the given read count for the predicted state divided by the emission probability for the normal state. The higher the value, the more likely that the read counts in this range could not have been generated from the normal state.

Value

Returns a RangedData object with the predicted copy count, the log odds of predicted copy count over normal copy count, a combined p-value, the number of genomic ranges spanned by the segment, the number of targeted basepairs in the segment, and the sample name.

See Also

exomeCopy ExomeCopy-class

Examples


example(exomeCopy)
copyCountSegments(fit)

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/copyCountSegments.Rd_%03d_medium.png", width=480, height=480)
> ### Name: copyCountSegments
> ### Title: Segments of identical copy count from exomeCopy
> ### Aliases: copyCountSegments
> 
> ### ** 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> 
> copyCountSegments(fit)
RangedData with 3 rows and 5 value columns across 1 space
     space           ranges | copy.count  log.odds   nranges targeted.bp
  <factor>        <IRanges> |  <integer> <numeric> <numeric>   <integer>
1     chr1 [     1, 250000] |          2      0.00      2500      250000
2     chr1 [250001, 270000] |          3    301.98       200       20000
3     chr1 [270001, 500000] |          2      0.00      2300      230000
  sample.name
  <character>
1     sample1
2     sample1
3     sample1
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>