-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassembleMetaResults.R
108 lines (56 loc) · 3.33 KB
/
assembleMetaResults.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
101
102
103
104
105
106
107
library(data.table)
method <- "perm"
home <- Sys.getenv("HOME")
scratch <- Sys.getenv("SCRATCH")
myDataDir <- file.path(home, "Data", "smallPSets")
mySigDir <- file.path(scratch, paste0("pearson_",method,"_res"))
myPvalDir <- file.path(scratch, paste0(method, "_meta_perm_sig"))
myPvalDir <- file.path(".", paste0(method, "_meta_perm_sig"))
## First we load in the fixed effect permutation test results:
toRunPerm <- fread("toRunFiles/toRunMetaByGenePerm.txt", header=FALSE)
colnames(toRunPerm) <- c("Drug", 'Tissue', "Gene")
# toRunPerm[,hetFilePath := file.path(scratch, "perm_meta_hetPermTest",
# paste0(make.names(Drug), "_", make.names(Tissue), "_", Gene, "_hetPerm_10000_out.rds"))]
# toRunPerm[,hetTestExists := file.exists(hetFilePath)]
# toRunPerm[hetTestExists == TRUE]
# toRunPerm[,PermFilePattern := paste0(make.names(Drug), "_", make.names(Tissue), "_", Gene, "_perm*")]
# toRunPerm[,PermFilePath := sapply(PermFilePattern, function(x) list.files(path=file.path(scratch, "perm_meta_bootstrap"), pattern=x, full.names=TRUE))]
# toRunPerm[,PermTestExists := sapply(PermFilePath, file.exists)]
# toRunPerm[!sapply(PermTestExists, any)]
toRunPerm[,PermResFile := file.path(myPvalDir, paste0("permSig_", make.names(Drug), "_", make.names(Tissue), "_", Gene,"_out.rds"))]
toRunPerm[,all(sapply(PermResFile, file.exists))]
system.time(toRunPerm[,PermRes := sapply(PermResFile, function(x) list(readRDS(x)))])
toRunPerm[,pvalue := sapply(PermRes, function(x) return(x[[1]]))]
toRunPerm[,estimate := sapply(PermRes, function(x) return(x[[2]]$t0))]
toRunPerm[, lower := sapply(PermRes, function(x) return(x[["ci"]]$bca[4]))]
toRunPerm[, upper := sapply(PermRes, function(x) return(x[["ci"]]$bca[5]))]
toRunPerm[order(pvalue)]
toRunPermOut <- toRunPerm
toRunPermOut <- toRunPermOut[,PermRes:=NULL]
toRunPermOut <- toRunPermOut[,PermResFile:=NULL]
write.csv(toRunPermOut, file="rnaResults/biomarker_res/BiomarkerPermRes.csv")
### Now lets do the bootstrap results
home <- Sys.getenv("HOME")
scratch <- Sys.getenv("SCRATCH")
myDataDir <- file.path(home, "Data", "smallPSets")
mySigDir <- file.path(scratch, paste0("pearson_",method,"_res"))
bootSigDir <- file.path(scratch, "perm_meta_boot_sig")
bootSigDir <- file.path(".", paste0(method, "_meta_boot_sig"))
toRunBoot <- fread("toRunFiles/toRunMetaByGeneBoot.txt", header=FALSE)
colnames(toRunBoot) <- c("Drug", 'Tissue', "Gene")
toRunBoot[,BootSigPath := file.path(bootSigDir, paste0("bootSig_", make.names(Drug), "_", make.names(Tissue), "_", Gene, "_out.rds"))]
toRunBoot[,BootSigExists := sapply(BootSigPath, file.exists)]
toRunBoot[BootSigExists == FALSE]
toRunBoot <- toRunBoot[BootSigExists == TRUE]
## Job 1318428 is checking what is going on with these
toRunBoot <- toRunBoot[,BootRes := sapply(BootSigPath, function(x) return(list(readRDS(x))))]
toRunBoot[,pvalue := sapply(BootRes, function(x) return(x[[1]]))]
toRunBoot[,estimate := sapply(BootRes, function(x) return(x[[2]]))]
toRunBoot[, lower := sapply(BootRes, function(x) return(x[["ci"]]$bca[4]))]
toRunBoot[, upper := sapply(BootRes, function(x) return(x[["ci"]]$bca[5]))]
toRunBoot[order(pvalue)]
toRunBootOut <- toRunBoot
toRunBootOut <- toRunBootOut[,BootRes:=NULL]
toRunBootOut <- toRunBootOut[,BootSigExists:=NULL]
toRunBootOut <- toRunBootOut[,BootSigPath:=NULL]
write.csv(toRunBootOut, file="biomarker_res/BiomarkerBootRes.csv")