forked from rossinerbe/MOMSCellSimulations
-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialSimulationTesting.jl
206 lines (160 loc) · 10 KB
/
initialSimulationTesting.jl
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
include("simulateCells.jl");
testGS = generateGeneSet(10, allowFeedbackLoops = true)
testIC = generateInitialConditions(testGS)
testSim = cellSimulation(testGS, testIC, 1000)
using Plots
x= collect(1:1000)
plot(x, transpose(testSim.EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState.pdf")
plot(x, log1p.(transpose(testSim.SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts.pdf")
plot(x, log1p.(transpose(testSim.UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts.pdf")
plot(x, log1p.(transpose(testSim.ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression.pdf")
#what does it look like with a different random seed?
testSim2 = cellSimulation(testGS, testIC, 1000, seed = 42)
x= collect(1:1000)
plot(x, transpose(testSim2.EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_seed2.pdf")
plot(x, log1p.(transpose(testSim2.SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_seed2.pdf")
plot(x, log1p.(transpose(testSim2.UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_seed2.pdf")
plot(x, log1p.(transpose(testSim2.ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_seed2.pdf")
#how much effect does simulation seed have?
#how much effect does changing ICS have?
#how different is another random gene set with only seed changed in generation?
#how about if you change different parameters?
#how to determine size of effect?
#create the data
simSeedData = Vector{Any}(undef, 100)
for i=1:100
simSeedData[i] = cellSimulation(testGS, testIC, 1000, seed = i)
end
simICSData = Vector{Any}(undef, 100)
for i=1:100
tmpIC = generateInitialConditions(testGS, seed = i)
simICSData[i] = cellSimulation(testGS, tmpIC, 1000)
end
simGSData = Vector{Any}(undef, 100)
for i=1:100
tmpGS = generateGeneSet(10, seed = i)
tmpIC = generateInitialConditions(tmpGS)
simGSData[i] = cellSimulation(tmpGS, tmpIC, 1000)
end
using JLD2
save_object("D:/FertigLabLargeData/CellSimulations/Results/simulatedSeedData.jld2", simSeedData)
save_object("D:/FertigLabLargeData/CellSimulations/Results/simulatedICSData.jld2", simICSData)
save_object("D:/FertigLabLargeData/CellSimulations/Results/simulatedGSData.jld2", simGSData)
#find the correlation for each modality
using Statistics, LinearAlgebra
simSeedCorrs = Vector{Any}(undef, length(simSeedData))
for i=1:length(simSeedData)
tmpSplicedCor = diag(cor(simSeedData[i].SplicedRNA, testSim.SplicedRNA, dims = 2))
tmpUnsplicedCor = diag(cor(simSeedData[i].UnsplicedRNA, testSim.UnsplicedRNA, dims = 2))
tmpProteinCor = diag(cor(simSeedData[i].ProteinExpression, testSim.ProteinExpression, dims = 2))
tmpEpigeneticCor = diag(cor(simSeedData[i].EpigeneticState, testSim.EpigeneticState, dims = 2))
simSeedCorrs[i] = (SplicedRNA = tmpSplicedCor, UnsplicedRNA = tmpUnsplicedCor,
Protein = tmpProteinCor, Epigenetic = tmpEpigeneticCor)
end
#changing the random seed can lead to different trajectories for some genes. Most genes follow
#similar trajectories, but usually 1-2 diverge noticeably
icsCorrs = Vector{Any}(undef, length(simICSData))
for i=1:length(simICSData)
tmpSplicedCor = diag(cor(simICSData[i].SplicedRNA, testSim.SplicedRNA, dims = 2))
tmpUnsplicedCor = diag(cor(simICSData[i].UnsplicedRNA, testSim.UnsplicedRNA, dims = 2))
tmpProteinCor = diag(cor(simICSData[i].ProteinExpression, testSim.ProteinExpression, dims = 2))
tmpEpigeneticCor = diag(cor(simICSData[i].EpigeneticState, testSim.EpigeneticState, dims = 2))
icsCorrs[i] = (SplicedRNA = tmpSplicedCor, UnsplicedRNA = tmpUnsplicedCor,
Protein = tmpProteinCor, Epigenetic = tmpEpigeneticCor)
end
#plot an example
plot(x, transpose(simICSData[1].EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_diffICS.pdf")
plot(x, log1p.(transpose(simICSData[1].SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_diffICS.pdf")
plot(x, log1p.(transpose(simICSData[1].UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_diffICS.pdf")
plot(x, log1p.(transpose(simICSData[1].ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_diffICS.pdf")
#second example
plot(x, transpose(simICSData[22].EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_diffICS2.pdf")
plot(x, log1p.(transpose(simICSData[22].SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_diffICS2.pdf")
plot(x, log1p.(transpose(simICSData[22].UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_diffICS2.pdf")
plot(x, log1p.(transpose(simICSData[22].ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_diffICS2.pdf")
#correlations is much less for different ICS, but the shape of the overall progression through
#time is still consistent for most genes, though it depends on the example
#gene set
gsCorrs = Vector{Any}(undef, length(simGSData))
for i=1:length(simGSData)
tmpSplicedCor = diag(cor(simGSData[i].SplicedRNA, testSim.SplicedRNA, dims = 2))
tmpUnsplicedCor = diag(cor(simGSData[i].UnsplicedRNA, testSim.UnsplicedRNA, dims = 2))
tmpProteinCor = diag(cor(simGSData[i].ProteinExpression, testSim.ProteinExpression, dims = 2))
tmpEpigeneticCor = diag(cor(simGSData[i].EpigeneticState, testSim.EpigeneticState, dims = 2))
gsCorrs[i] = (SplicedRNA = tmpSplicedCor, UnsplicedRNA = tmpUnsplicedCor,
Protein = tmpProteinCor, Epigenetic = tmpEpigeneticCor)
end
#plot example
plot(x, transpose(simGSData[1].EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_diffGS.pdf")
plot(x, log1p.(transpose(simGSData[1].SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_diffGS.pdf")
plot(x, log1p.(transpose(simGSData[1].UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_diffGS.pdf")
plot(x, log1p.(transpose(simGSData[1].ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_diffGS.pdf")
#second example
plot(x, transpose(simGSData[99].EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_diffGS2.pdf")
plot(x, log1p.(transpose(simGSData[99].SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_diffGS2.pdf")
plot(x, log1p.(transpose(simGSData[99].UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_diffGS2.pdf")
plot(x, log1p.(transpose(simGSData[99].ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_diffGS2.pdf")
##100 genes
testGS = generateGeneSet(100, allowFeedbackLoops = true)
testIC = generateInitialConditions(testGS)
testSim = cellSimulation(testGS, testIC, 1000)
plot(x, transpose(testSim.EpigeneticState), title = "Epigenetic State",
legend = false, xlabel = "Time (minutes)", ylabel = "Accessibile Loci")
savefig("C:/Users/rossi/Pictures/CellSimulations/testEpigeneticState_100Genes.pdf")
plot(x, log1p.(transpose(testSim.SplicedRNA)), title = "Spliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testSplicedCounts_100Genes.pdf")
plot(x, log1p.(transpose(testSim.UnsplicedRNA)), title = "Unspliced Counts",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Counts")
savefig("C:/Users/rossi/Pictures/CellSimulations/testUnsplicedCounts_100Genes.pdf")
plot(x, log1p.(transpose(testSim.ProteinExpression)), title = "Protein",
legend = false, xlabel = "Time (minutes)", ylabel = "log1p Molecules")
savefig("C:/Users/rossi/Pictures/CellSimulations/testProteinExpression_100Genes.pdf")