-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassembleMetaResultsCNV.R
48 lines (26 loc) · 1.43 KB
/
assembleMetaResultsCNV.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
library(data.table)
corP <- 60671
## First we load in the fixed effect permutation test results:
myPvalDir <- "cnvRes/cnv/perm_meta_perm_sig"
hetTestRes <- fread("cnvRes/cnv/runlist_files/metaHetTestRes.txt", header=T)
permRes <- hetTestRes[hetTestRes==0]
bootSigDir <- "cnvRes/cnv/perm_meta_boot_sig"
toRunBoot <- hetTestRes[hetTestRes==1]
toRunBoot[,BootSigPath := file.path(bootSigDir, make.names(paste0("bootSig_", Gene, "_", Drug, "_", Tissue, "_out.rds")))]
toRunBoot[,BootSigExists := sapply(BootSigPath, file.exists)]
toRunBoot[BootSigExists == FALSE]
toRunBoot <- toRunBoot[BootSigExists == TRUE]
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"]]$percent[4]))]
toRunBoot[, upper := sapply(BootRes, function(x) return(x[["ci"]]$percent[5]))]
toRunBoot[order(pvalue)]
toRunBootOut <- toRunBoot
toRunBootOut <- toRunBootOut[,BootRes:=NULL]
toRunBootOut <- toRunBootOut[,BootSigExists:=NULL]
toRunBootOut <- toRunBootOut[,BootSigPath:=NULL]
toRunBootOut <- toRunBootOut[,hetFilePath:=NULL]
toRunBoot[, FWER_genes := pmin(pvalue * corP,1)]
fwrite(toRunBootOut,"cnvRes/cnv/biomarker_res/allRes.csv")
fwrite(toRunBootOut, file="cnvRes/cnv/biomarker_res/cnv_gene_drug_tissue_res_pharmacodb.csv")