## The following is an example of running exomeCopy on simulated
## read counts using the model parameters defined above. For an example
## using real exome sequencing read counts (with simulated CNV) please
## see the vignette.
## create RangedData for storing genomic ranges and covariate data
## (background, background stdev, GC-content)
m <- 5000
rdata <- RangedData(IRanges(start=0:(m-1)*100+1,width=100),
space=rep("chr1",m), universe="hg19", log.bg=rnorm(m), log.bg.var=rnorm(m),
gc=runif(m,30,50))
## create read depth distributional parameters mu and phi
rdata$gc.sq <- rdata$gc^2
X <- cbind(bg=rdata$log.bg,gc=rdata$gc,gc.sq=rdata$gc.sq)
Y <- cbind(bg.sd=rdata$log.bg.var)
beta <- c(5,1,.01,-.01)
gamma <- c(-3,.1)
rdata$mu <- exp(beta[1] + scale(X) %*% beta[2:4])
rdata$phi <- exp(gamma[1] + scale(Y) %*% gamma[2])
## create observed counts with simulated heterozygous duplication
cnv.nranges <- 200
bounds <- (round(m/2)+1):(round(m/2)+cnv.nranges)
O <- rnbinom(nrow(rdata),mu=rdata$mu,size=1/rdata$phi)
O[bounds] <- O[bounds] + rbinom(cnv.nranges,prob=0.5,size=O[bounds])
rdata[["sample1"]] <- O
## run exomeCopy() and list segments
fit <- exomeCopy(rdata,"sample1",X.names=c("log.bg","gc","gc.sq"))
# an example call with variance fitting.
# see paper: this does not necessarily improve the fit
fit <- exomeCopy(rdata,"sample1",X.names=c("log.bg","gc","gc.sq"),
Y.names="log.bg",fit.var=TRUE)
## see man page for copyCountSegments() for summary of
## the predicted segments of constant copy count, and
## for plot.ExomeCopy() for plotting fitted objects
Run the code above in your browser using DataLab