-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstep6-regionMatrix.R
More file actions
68 lines (54 loc) · 1.98 KB
/
step6-regionMatrix.R
File metadata and controls
68 lines (54 loc) · 1.98 KB
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
library('derfinder')
library('getopt')
library('devtools')
## Specify parameters
spec <- matrix(c(
'maindir', 'm', 1, 'character', 'Main directory',
'cutoff', 't', 1, 'numeric', 'Cutoff to use',
'readLen', 'r', 1, 'integer', 'Read length',
'histone', 'i', 1, 'character', 'For epimap, the histone mark to use. Either H3K27ac or H3K4me3.',
'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)
}
## For testing
if(FALSE) opt <- list('maindir' = '/dcl01/lieber/ajaffe/derRuns/derChIP/epimap', cutoff = 10, readLen = 100, histone = 'H3K4me3')
## Input options used
maindir <- opt$maindir
cutoff <- opt$cutoff
readLen <- opt$readLen
chr <- paste0('chr', c('Y', 1:22, 'X'))[as.numeric(Sys.getenv("SGE_TASK_ID"))]
message(Sys.time())
timeinfo <- NULL
timeinfo <- c(timeinfo, list(Sys.time()));
## Load data
load(file.path(maindir, 'CoverageInfo', paste0(chr, 'CovInfo.Rdata')))
## Load colsubset
load(file.path('..', 'derAnalysis', paste0('run1-v1.5.38-', opt$histone), 'colsubset.Rdata'))
fullCov <- list(get(paste0(chr, 'CovInfo')))
names(fullCov) <- chr
## Apply subset
fullCov[[1]]$coverage <- fullCov[[1]]$coverage[, colsubset]
timeinfo <- c(timeinfo, list(Sys.time()))
proc.time()
message(Sys.time())
## run regionMatrix
regionMat <- regionMatrix(fullCov, maxClusterGap = 3000L, L = readLen,
cutoff = cutoff, returnBP = FALSE, smoothMean = TRUE,
smoothFun = bumphunter::runmedByCluster, k = 299)
timeinfo <- c(timeinfo, list(Sys.time()))
## Save results
save(regionMat, file=paste0('regionMat-', opt$histone, '-cut', cutoff, '-', chr, '.Rdata'))
timeinfo <- c(timeinfo, list(Sys.time()))
## Save time information
save(timeinfo, file=paste0('timeinfo-', opt$histone, '-cut', cutoff, '-', chr, '.Rdata'))
## Reproducibility info
proc.time()
message(Sys.time())
options(width = 120)
devtools::session_info()