plotCompiledCNV: Plot compiled CNV segments for one sequence/chromosome

Description Usage Arguments Value Examples

View source: R/helper_functions.R

Description

This function takes a GRanges 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 GRanges object. See the vignette for a more complete example.

Usage

1
2
  plotCompiledCNV(CNV.segments, seq.name, xlim=NULL, col=NULL,
  copy.counts=0:6, normal.state = 2)

Arguments

CNV.segments

A GRanges object as produced by compileCopyCountSegments and with normal state removed.

seq.name

The name of the sequence to plot

xlim

The genomic coordinates for the x axis. If not included, the plotting window will cover the range of the CNVs in CNV.segments

col

The colors to use for the different copy count states

copy.counts

The corresponding copy counts for the colors

normal.state

The copy count of the normal state

Value

Produces a plot.

Examples

1
2
3
4
5
  example(compileCopyCountSegments)
  CNV.clean <- CNV.segments[CNV.segments$copy.count != 2]
  chr.start <- start(range(fit@ranges))
  chr.end <- end(range(fit@ranges))
  plotCompiledCNV(CNV.clean, "chr1", xlim=c(chr.start,chr.end))

Example output

Loading required package: IRanges
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package:BiocGenericsThe following objects are masked frompackage:parallel:

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

The following objects are masked frompackage:stats:

    IQR, mad, sd, var, xtabs

The following objects are masked frompackage:base:

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

Loading required package: S4Vectors
Loading required package: stats4

Attaching package:S4VectorsThe following object is masked frompackage:base:

    expand.grid

Loading required package: GenomicRanges
Loading required package: GenomeInfoDb
Loading required package: Rsamtools
Loading required package: Biostrings
Loading required package: XVector

Attaching package:BiostringsThe following object is masked frompackage:base:

    strsplit


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 GRanges for storing genomic ranges and covariate data
exmCpy> ## (background, background stdev, GC-content)
exmCpy> 
exmCpy> m <- 5000

exmCpy> gr <- GRanges("chr1", IRanges(start=0:(m-1)*100+1,width=100),
exmCpy+               log.bg=rnorm(m), log.bg.var=rnorm(m), gc=runif(m,30,50))

exmCpy> genome(gr) <- "hg19"

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

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

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

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

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

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

exmCpy> gr$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(length(gr),mu=gr$mu,size=1/gr$phi)

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

exmCpy> gr$sample1 <- O

exmCpy> ## run exomeCopy() and list segments
exmCpy> fit <- exomeCopy(gr,"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(gr,"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)

exomeCopy documentation built on Nov. 8, 2020, 7:45 p.m.