forked from dxs435/COMPACT_enrichment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOMPACT_discretize.R
55 lines (51 loc) · 1.57 KB
/
COMPACT_discretize.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
#Taken from "MD_COMPACT_build_array.R"
#This is the sequence to restructure the gsets and create the discretized matrices
library(limma)
library(dplyr)
library(GEOquery)
#This will load all the functions
#load("pre_built.RData")
source("COMPACT_functions_v3.R")
i <- 1
Tlist = list()
#Genes are sparsely identified in GSE33785
for(f in list.files("Data/")){
load(paste("Data/",f,sep=""))
for(trmt in unique(gset$Treatment)){
#need to check if we need a 0 time or control ("ctrl") point
if(trmt == "ctrl"){
next()
}
else if(min(gset$Time[gset$Treatment == trmt]) == 0){
gse.tmp <- gset[,gset$Treatment == trmt]
Tlist[[i]] <- gse.tmp
#browser()
names(Tlist)[i] <- paste(gsub(".RData","",f),paste(trmt),sep="_")
i = i + 1
}
else if(any(gset$Time == 0)){
gse.tmp <- gset[,(gset$Treatment == trmt | gset$Treatment == "ctrl")]
gse.tmp$Treatment <- trmt
Tlist[[i]] <- gse.tmp
#browser()
names(Tlist)[i] <- paste(gsub(".RData","",f),paste(trmt),sep="_")
i = i + 1
}
#May need another 'else if' statement for experiments where the baseline is like 1 h...
else{
print("One or more GSEs are formatted incorrectly, or a baseline is needed")
break()
}
}
}
#Tlist <- Tlist[-c(10,11)]
print("Finished treatment list")
discreteList <- list()
for(i in 1:length(Tlist)){
disc.res <- eDcollapse(Tlist[[i]])
disc.res <- eDcontrast(disc.res)
disc.res <- eDdiscretize(disc.res)
discreteList[[i]] <- disc.res
}
names(discreteList) <- names(Tlist)
print("Finished making dicrete time")