-
Notifications
You must be signed in to change notification settings - Fork 8
/
_model_old.r
56 lines (49 loc) · 1.38 KB
/
_model_old.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
# point of this file:
# - use the zscores to create a linear model
library(dplyr)
b = import('base')
io = import('io')
ar = import('array')
st = import('stats')
lm = import('./lm')
# load speed data, index
zscores = io$load('../../jsr-gdsc/SPEED-Data/SPEED2zmats.RData')$rma_none
index = io$read_table("../../jsr-gdsc/SPEED-Data/zval_meta_BTOmapped.txt", header=T) %>%
select(id, pathway, cells, GSE, GPL) %>%
dplyr::filter(id %in% colnames(zscores))
zscores = t(zscores[,index$id])
## adjust object for linear modelling
#inh = index$effect=="inhibiting"
#zscores[,inh] = -zscores[,inh]
#zscores = na.omit(zscores) #TODO: handle this better
#zscores = t(zscores)
###
### begin old code
###
mod = lm$fit(zscores~0+pathway, data=index)
zfit = mod$fit
pval = mod$pval
###
### end old code
###
## fit model to pathway perturbations
#mod = st$lm(zscores ~ 0 + pathway, data=index) %>%
# transmute(gene = response,
# pathway = sub("^pathway", "", term),
# zscore = estimate,
# p.value = p.value) %>%
# group_by(gene) %>%
# mutate(p.adj = p.adjust(p.value, method="fdr")) %>%
# ungroup()
#
#zfit = ar$construct(zscore ~ gene + pathway, data=mod)
#pval = ar$construct(p.adj ~ gene + pathway, data=mod)
###
### old code begin
###
zfit = lm$selectFeatures(zfit, min=pval, n=100)
###
### old code end
###
#zfit[pval>0.01] = 0
save(zfit, file="model_old.RData")