## Load derfinder
library('derfinder')
## The output will be saved in the 'derfinderReport-example' directory
dir.create('derfinderReport-example', showWarnings = FALSE, recursive = TRUE)
## For convenience, the derfinder output has been pre-computed
file.copy(system.file(file.path('extdata', 'chr21'), package='derfinder',
mustWork=TRUE), 'derfinderReport-example', recursive = TRUE)
## If you prefer, you can generate the output from derfinder
initialPath <- getwd()
setwd(file.path(initialPath, 'derfinderReport-example'))
## Collapse the coverage information
collapsedFull <- collapseFullCoverage(list(genomeData$coverage),
verbose=TRUE)
## Calculate library size adjustments
sampleDepths <- sampleDepth(collapsedFull, probs=c(0.5), nonzero=TRUE,
verbose=TRUE)
## Build the models
group <- genomeInfo$pop
adjustvars <- data.frame(genomeInfo$gender)
models <- makeModels(sampleDepths, testvars=group, adjustvars=adjustvars)
## Analyze chromosome 21
analyzeChr(chr='21', coverageInfo=genomeData, models=models,
cutoffFstat=1, cutoffType='manual', seeds=20140330, groupInfo=group,
mc.cores=1, writeOutput=TRUE, returnOutput=FALSE)
## Change the directory back to the original one
setwd(initialPath)
## Merge the results from the different chromosomes. In this case, there's
## only one: chr21
mergeResults(chrs = '21', prefix = 'derfinderReport-example',
genomicState = genomicState$fullGenome)
## Load the options used for calculating the statistics
load(file.path('derfinderReport-example', 'chr21', 'optionsStats.Rdata'))
## Generate the HTML report
report <- derfinderReport(prefix='derfinderReport-example', browse=FALSE,
nBestRegions=1, makeBestClusters=FALSE,
fullCov=list('21'=genomeDataRaw$coverage), optionsStats=optionsStats)
if(interactive()) {
## Browse the report
browseURL(report)
}
## Note that you can run the example using:
example('derfinderReport', 'regionReport', ask=FALSE)
Run the code above in your browser using DataLab