-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeTableLocalMax.R
106 lines (73 loc) · 2.28 KB
/
makeTableLocalMax.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
##### As it says, this obtains a table for genotypes' frequency as local max
## Launch as
## nohup R --vanilla --slave -f input.R &> input.Rout &
rm(list = ls())
source("oncoFunctions.R")
library(codetools)
checkUsageEnv(env = .GlobalEnv)
## Change paths as needed
dirsSims <- c("/Disk2/ramon/No-Backuppc/selected-simulations-A",
"/Disk2/ramon/No-Backuppc/selected-simulations-B")
## ## For playing
## dirsSampled <- "~/tmp"
## dirsSims <- "~/tmp"
## filesSim give the "true probabilities" of genotypes
## filesSample4000 are used to obtain the probabilities of genotypes under
## the sampling regime (4000 * 5 = 20000, and that is where we get
## the probabilities from)
filesSim <- list.files(dirsSims, pattern = "simobj",
full.names = TRUE)
stopifnot(length(filesSim) == 1260)
date()
## Warm up compiler and check
## system.time(
## null <- dplyr::bind_rows(
## lapply(filesSim[c(1, 15, 2, 3)],
## local_max)
## )
## )
## system.time(
## null <- dplyr::bind_rows(
## mclapply(filesSim[c(1, 15, 2, 3)],
## local_max,
## mc.cores = 4)
## )
## )
system.time(
null <- dplyr::bind_rows(
lapply(filesSim[c(1, 15)],
local_max_np)
)
)
## check compiled
local_max_np
## system.time(
## null <- dplyr::bind_rows(
## mclapply(filesSim[c(1, 15, 2, 3)],
## local_max_np,
## mc.cores = 4)
## )
## )
null
rm(null)
gc()
pboptions(type = "txt")
outLocalMax <- pbmclapply(filesSim,
local_max_np,
mc.cores = 10) ## detectCores())
cat("\n Save before bind_rows \n")
save(file = "outLocalMax.RData", outLocalMax,
compress = FALSE)
date()
stopifnot(length(outLocalMax) == 1260)
## I was getting out of RAM errors
any_error <- unlist(lapply(outLocalMax, function(x) inherits(x, "try-error")))
if(sum(any_error)) {
print(outLocalMax[any_error])
sum(any_error)
}
outLocalMax <- dplyr::bind_rows(outLocalMax)
cat("\n Save after bind_rows \n")
save(file = "outLocalMax.RData", outLocalMax,
compress = FALSE)
date()