-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessParquetResults_diff_rand.R
More file actions
executable file
·71 lines (67 loc) · 2.17 KB
/
Copy pathprocessParquetResults_diff_rand.R
File metadata and controls
executable file
·71 lines (67 loc) · 2.17 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
69
70
71
if(!require("arrow")){
install.packages("arrow")
}
library("arrow")
# Read files.
eQTLDir <- NULL
cutoff <- 0.05
readAllCis <- function(fpath){
chroms <- c(as.character(1:22), "X", "Y")
allRes <- do.call(rbind, lapply(chroms, function(chrom){
parquet <- arrow::read_parquet(paste0(fpath, ".", chrom, ".parquet"))
return(parquet)
}))
padj <- p.adjust(allRes$pval_nominal, method = "fdr")
parquetSig <- allRes[which(padj < cutoff),]
cat(".")
return(parquetSig)
}
cisResults <- lapply(1:10, function(i){
cisResultsSplit <- lapply(1:2, function(j){
return(readAllCis(paste0(eQTLDir, "/profoundAutismBoth_rand_", i, "_", j, "_diff.cis_qtl_pairs")))
})
names(cisResultsSplit) <- 1:2
return(cisResultsSplit)
})
names(cisResults) <- 1:10
# We use the number of phenotypes x number of variants as the upper bound for M (the number of tests).
# Technically it is this number - the number of cis pairs filtered out, but that number
# is negligible in comparison to the number of tests.
M <- 34070 * 2440283
getAboveCutoff <- function(file){
ranks <- rank(file$pval, ties.method = "first")
padj <- file$pval * (M / ranks)
sig <- file[which(padj < cutoff),]
return(sig)
}
transResults <- lapply(1:10, function(i){
transResultsSplit <- lapply(1:2, function(j){
cat("*")
return(getAboveCutoff(file = arrow::read_parquet(paste0(eQTLDir, "/profoundAutismBoth_rand_", i, "_", j, "_diff_trans.trans_qtl_pairs.parquet"))))
})
names(transResultsSplit) <- 1:2
return(transResultsSplit)
})
names(transResults) <- 1:10
# Look at overlap in pairs.
getPairs <- function(result){
return(paste(result$variant_id, result$phenotype_id, sep = "__"))
}
pairsCis <- lapply(1:10, function(i){
pairsSplit <- lapply(1:2, function(j){
return(getPairs(cisResults[[i]][[j]]))
})
names(pairsSplit) <- 1:2
return(pairsSplit)
})
names(pairsCis) <- 1:10
pairsTrans <- lapply(1:10, function(i){
pairsSplit <- lapply(1:2, function(j){
return(getPairs(transResults[[i]][[j]]))
})
names(pairsSplit) <- 1:2
return(pairsSplit)
})
names(pairsTrans) <- 1:10
saveRDS(list(pairsCis = pairsCis,
pairsTrans = pairsTrans), paste0(eQTLDir, "/alleQTLResultsRandDiff.RDS"))