-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrow_test.R
More file actions
40 lines (25 loc) · 1.25 KB
/
grow_test.R
File metadata and controls
40 lines (25 loc) · 1.25 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
require(Rcpp)
setwd('~/RcppNested')
sourceCpp("nestedness.cpp")
d <- read.csv('~/Desktop/200up_events.csv')
d <- subset(d, rep==2 & update < 100000)
summary(d)
original_mat <- as.matrix(read.csv('interaction_matrix.csv', head=F))
calculateNODF(sortMatrix(original_mat))
t <- getRandomMatrix_GrowEvents(d$host_event, d$parasite_event, d$edge_event)
t_time_event <- replicate(20, getEventTimeseries(d$host_event, d$parasite_event, d$edge_event, 5, T))
matplot(t_time_event, type="l")
t_time_rand <- replicate(20, getMonotonicTimeseries(t, 500, 5, T))
rand_min <- min(sapply(t_time_rand, FUN=function(d) {length(d)}))
matplot(sapply(t_time_rand, FUN=function(d) {d[1:rand_min]}), type="l")
calculateNODF(sortMatrix(getRandomMatrix_GrowEvents(d$host_event, d$parasite_event, d$edge_event)))$NODF
calculateNODF(sortMatrix(getRandomMatrix_GrowMonotonic(original_mat, length(d$host_event))))$NODF
image(sortMatrix(t))
#different null model generators
nodf_null_col <- replicate(1000, calculateNODF(getRandomMatrix_ColShuffle(t))$NODF)
nodf_null_row <- replicate(1000, calculateNODF(getRandomMatrix_RowShuffle(t))$NODF)
nodf_null_fill <- replicate(1000, calculateNODF(getRandomMatrix_Fill(t))$NODF)
par(mfcol=c(3,1))
hist(nodf_null_col)
hist(nodf_null_row)
hist(nodf_null_fill)