-
Notifications
You must be signed in to change notification settings - Fork 1
/
step3-analyzeChr.R
executable file
·70 lines (53 loc) · 1.92 KB
/
step3-analyzeChr.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
## Run derfinder's analysis steps with timing info
## Load libraries
library('getopt')
## Available at http://www.bioconductor.org/packages/release/bioc/html/derfinder.html
library('derfinder')
library('devtools')
library('GenomeInfoDb')
## Specify parameters
spec <- matrix(c(
'experiment', 'e', 1, 'character', 'Experiment. Only brainspan',
'CovFile', 'd', 1, 'character', 'path to the .Rdata file with the results from loadCoverage() with cutoff >= 0',
'chr', 'c', 1, 'character', 'Chromosome under analysis',
'mcores', 'm', 1, 'integer', 'Number of cores',
'help' , 'h', 0, 'logical', 'Display help'
), byrow=TRUE, ncol=5)
opt <- getopt(spec)
## if help was asked for print a friendly message
## and exit with a non-zero error code
if (!is.null(opt$help)) {
cat(getopt(spec, usage=TRUE))
q(status=1)
}
## Check experiment input
stopifnot(opt$experiment %in% c('brainspan'))
## Format chromosome name appropriately
opt$chr <- mapSeqlevels(opt$chr, 'UCSC')
message('Loading Rdata file with the output from loadCoverage()')
load(opt$CovFile)
## Make it easy to use the name later. Here I'm assuming the names were generated using output='auto' in loadCoverage()
eval(parse(text=paste0('covData <- ', opt$chr, 'CovInfo')))
eval(parse(text=paste0('rm(', opt$chr, 'CovInfo)')))
## Load the models
load('models.Rdata')
## Load group information
load('groupInfo.Rdata')
if(file.exists('colsubset.Rdata')) {
load('colsubset.Rdata')
} else {
colsubset <- NULL
}
## Run the analysis
if (opt$experiment == 'brainspan') {
analyzeChr(chr = opt$chr, coverageInfo = covData, models = models,
cutoffFstat = 1e-06, colsubset = colsubset, nPermute = 1000,
seeds = seq_len(1000) + 20141008, maxClusterGap = 3000,
groupInfo = groupInfo, mc.cores = opt$mcores,
lowMemDir = file.path(tempdir(), opt$chr, 'chunksDir'), chunksize = 1e5,
scalefac = 1)
}
## Done
proc.time()
options(width = 120)
session_info()