forked from decarlin/prophetic-granger-causality
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdream8-nsmbl.R
More file actions
62 lines (51 loc) · 1.47 KB
/
dream8-nsmbl.R
File metadata and controls
62 lines (51 loc) · 1.47 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
## dream8-nsmbl.R - ensemble generation for the DREAM8 challenge
##
## by Artem Sokolov
loadRes <- function( fn )
{
load( fn )
res
}
make.ensemble <- function( fns, fcomb=mean, bInS=FALSE )
{
## Load all the results files
X <- list()
for( fn in fns )
X[[fn]] <- loadRes( fn )
stopifnot( length(X) > 0 )
## The set of names to traverse
nms <- exp.names()
if( bInS == TRUE )
nms <- c( nms, "Insilico" )
## Traverse experimental data
res <- list()
for( nm in nms )
{
## Extract an normalize the entries
X1 <- lapply( X, "[[", nm )
X1 <- lapply( X1, abs )
X1 <- lapply( X1, function(z) {z / max(z)} )
## Verify consistency
nn <- unique(unlist(lapply( X1, length )))
stopifnot( length(nn) == 1 )
rn <- unique(unlist(lapply( X1, rownames )))
rndiff <- unlist(lapply( X1, function(x1) {setdiff( rn, rownames(x1) )} ))
stopifnot( length(rndiff) == 0 )
## Combine the entries
n <- nrow(X1[[1]])
A1 <- array( data=unlist(X1), dim = c(n,n,length(X1)) )
A <- apply( A1, c(1,2), fcomb )
## Fix the row-/colnames
rownames(A) <- rownames(X1[[1]])
colnames(A) <- colnames(X1[[1]])
res[[nm]] <- A
}
res
}
main.ensemble <- function()
{
fns <- c( "pred/prior.RData",
"pred/granger.RData" )
res <- make.ensemble( fns )
save( res, file="pred/final.RData" )
}