-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsergio_steady_gen.R
108 lines (97 loc) · 4.47 KB
/
sergio_steady_gen.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# generate two files for SERGIO: one for master regulator expression for n.cell types;
# one for regulator relationships
library(qpcR)
library(formattable)
library(pheatmap)
# set parameters
n.celltypes <- 3
n.genes <- 5000
n.master.regulators <- n.genes * 0.005
n.tight.strong.targets <- n.genes * 0.1
n.tight.medium.targets <- n.genes * 0.1
n.tight.weak.targets <- n.genes * 0.1
n.multi.targets <- n.genes * 0.3
n.rest <- n.genes * 0.395
# n.tight.strong.targets
tight.strong.targets.info <- list()
for (i in 1:n.tight.strong.targets){
cell <- i + n.master.regulators - 1
# n.regs <- sample(1:3, 1, replace = FALSE)
n.regs <- 1
regs <- sample(0:(n.master.regulators-1), n.regs, replace = FALSE)
strengths <- sample(c(-1, 1, 1, 1), size=length(regs), replace=TRUE) * runif(n = length(regs), min = 2, max = 5)
hills <- rep(2.0, length(regs))
target.info <- format(c(cell, n.regs, regs, strengths, hills), digits = 4, format = "f")
# print(target.info)
tight.strong.targets.info[[i]] <- target.info
}
tight.strong.targets.info.df <- do.call(qpcR:::rbind.na, tight.strong.targets.info)
#
# n.tight.medium.targets
tight.medium.targets.info <- list()
for (i in 1:n.tight.medium.targets){
cell <- i + n.master.regulators + n.tight.strong.targets - 1
# n.regs <- sample(1:3, 1, replace = FALSE)
n.regs <- 1
regs <- sample(0:(n.master.regulators-1), n.regs, replace = FALSE)
strengths <- sample(c(-1,1,1,1), size=length(regs), replace=TRUE) * runif(n = length(regs), min = 1, max = 2)
hills <- rep(2.0, length(regs))
target.info <- format(c(cell, n.regs, regs, strengths, hills), digits = 4, format = "f")
# print(target.info)
tight.medium.targets.info[[i]] <- target.info
}
tight.medium.targets.info.df <- do.call(qpcR:::rbind.na, tight.medium.targets.info)
# n.tight.weak.targets
tight.weak.targets.info <- list()
for (i in 1:n.tight.weak.targets){
cell <- i + n.master.regulators + n.tight.strong.targets + n.tight.medium.targets - 1
# n.regs <- sample(1:3, 1, replace = FALSE)
n.regs <- 1
regs <- sample(0:(n.master.regulators-1), n.regs, replace = FALSE)
strengths <- sample(c(-1,1,1,1), size=length(regs), replace=TRUE) * runif(n = length(regs), min = 0.5, max = 1)
hills <- rep(2.0, length(regs))
target.info <- format(c(cell, n.regs, regs, strengths, hills), digits = 4, format = "f")
# print(target.info)
tight.weak.targets.info[[i]] <- target.info
}
tight.weak.targets.info.df <- do.call(qpcR:::rbind.na, tight.weak.targets.info)
# n.multi.targets
multi.targets.info <- list()
for (i in 1:n.multi.targets){
cell <- i + n.master.regulators + n.tight.strong.targets + n.tight.medium.targets + n.tight.weak.targets - 1
n.regs <- sample(2:4, 1, replace = FALSE)
# n.regs <- 1
regs <- sample(0:(n.master.regulators-1), n.regs, replace = FALSE)
strengths <- sample(c(-1,1,1,1), size=length(regs), replace=TRUE) * runif(n = length(regs), min = 0.5, max = 5)
hills <- rep(2.0, length(regs))
target.info <- format(c(cell, n.regs, regs, strengths, hills), digits = 4, format = "f")
# print(target.info)
multi.targets.info[[i]] <- target.info
}
multi.targets.info.df <- do.call(qpcR:::rbind.na, multi.targets.info)
# n.rest
rest.info <- list()
for (i in 1:n.rest){
cell <- i + n.master.regulators + n.tight.strong.targets + n.tight.medium.targets + n.tight.weak.targets + n.multi.targets- 1
n.regs <- sample(5:10, 1, replace = FALSE)
regs <- sample(0:(n.master.regulators-1), n.regs, replace = FALSE)
strengths <- sample(c(-1, 1, 1, 1), size=length(regs), replace=TRUE) * runif(n = length(regs), min = 0.001, max = 1)
hills <- rep(2.0, length(regs))
target.info <- format(c(cell, n.regs, regs, strengths, hills), digits = 4, format = "f")
# print(target.info)
rest.info[[i]] <- target.info
}
rest.info.df <- do.call(qpcR:::rbind.na, rest.info)
#
reg.output <- qpcR:::rbind.na(tight.strong.targets.info.df,
tight.medium.targets.info.df,
tight.weak.targets.info.df,
multi.targets.info.df,
rest.info.df)
write.table(reg.output, "5000.gene.3ct.reg.3.txt", quote = F, col.names = F, row.names = F, sep = ",", na = "")
# master regulator expressions
M <- matrix(runif(n.celltypes * n.master.regulators, min = 0.1, max = 5), nrow = n.master.regulators)
m.reg <- as.data.frame(M)
pheatmap(m.reg)
rownames(m.reg) <- formattable(0:(n.master.regulators-1), digits = 4, format = "f")
write.table(m.reg, "5000.gene.3ct.m.reg.3.txt", quote = F, col.names = F, sep = ",")