R: Plot compiled CNV segments for one sequence/chromosome
plotCompiledCNV
R Documentation
Plot compiled CNV segments for one sequence/chromosome
Description
This function takes a RangedData object as produced by
compileCopyCountSegments and plots the CNV segments for
one sequence/chromosomes across the samples with CNV segments.
The segments in the normal state should be removed as shown below in
the example to produce a cleaned RangedData object. See the vignette
for a more complete example.
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/plotCompiledCNV.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plotCompiledCNV
> ### Title: Plot compiled CNV segments for one sequence/chromosome
> ### Aliases: plotCompiledCNV
>
> ### ** Examples
>
> example(compileCopyCountSegments)
cmpCCS> 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>
cmpCCS> # this function requires a named list of named lists
cmpCCS> # as constructed in the vignette
cmpCCS> fit.list <- list(sample1 = list(chr1 = fit))
cmpCCS> CNV.segments <- compileCopyCountSegments(fit.list)
> CNV.clean <- CNV.segments[CNV.segments$copy.count != 2,]
> chr.start <- start(range(fit@ranges)[["chr1"]])
> chr.end <- end(range(fit@ranges)[["chr1"]])
> plotCompiledCNV(CNV.clean, "chr1", xlim=c(chr.start,chr.end))
>
>
>
>
>
> dev.off()
null device
1
>