-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigure4_julia_script.jl
More file actions
305 lines (243 loc) · 16.4 KB
/
figure4_julia_script.jl
File metadata and controls
305 lines (243 loc) · 16.4 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
include("iPredict.jl/src/iPredict.jl")
using .iPredict
using DataFrames
using Plots
using DelimitedFiles
using Plots.Measures
using StatsBase
#Initialise variables
GeneIsoformRelationships = "data/gencode_human_gene_isoform_relationships.txt"
NumSimulations = 100
NumIsoformsToSimulate = 4
filteringThreshold = 4
alpha = nothing
beta = nothing
scnorm_counts = ["H1_24_scnorm_counts.txt",
"H1_96_scnorm_counts.txt",
"H9_24_scnorm_counts.txt",
"H9_96_scnorm_counts.txt"]
pFP = 0.01
pFN = 0.04
isoChoiceModels = ["Weibull", "Random", "UniformObserved", "CellVariable"]
for countsMatrix in scnorm_counts
output = "figures/figure4/" * countsMatrix
for model in 1:length(isoChoiceModels)
output = "figures/figure4/" * isoChoiceModels[model] * "_" * countsMatrix
out = globalPredict("data/" * countsMatrix, GeneIsoformRelationships,
NumSimulations, output, NumIsoformsToSimulate, filteringThreshold,
false, alpha, beta, pFN, pFP, "none", isoChoiceModels[model],
"figures/figure5_data/" * isoChoiceModels[model] * "_" * countsMatrix)
end
end
################################################################################
# Make figure 4 + supplementary figs
################################################################################
function make_hist(path, titleArg)
Arr = readdlm(path)
if titleArg == "3 Isoforms" && path == "figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_3_isoforms_array.txt"
#Untransformed plot
p1 = histogram(Arr,
title = titleArg,
xlims = (0, 4),
ylims = (0, 5),
ylabel = "Probability Density",
normalize=:pdf,
bins = 100,
axis = (font(150)), titlefontsize=150, yticks = 0:5:5,
margin = 35mm,
left_margin = 50mm,
right_margin = 50mm)
elseif titleArg == "Real"
p1 = histogram(Arr,
title = titleArg,
xlims = (0, 4),
ylims = (0, 5),
normalize=:pdf,
xlabel = "Mean No. Isoforms\nper Gene per Cell",
bins = 100,
axis = (font(150)), titlefontsize=150, yticks = 0:5:5,
margin = 35mm,
left_margin = 50mm,
right_margin = 50mm)
else
#Untransformed plot
p1 = histogram(Arr,
title = titleArg,
xlims = (0, 4),
ylims = (0, 5),
normalize=:pdf,
bins = 100,
axis = (font(150)), titlefontsize=150, yticks = 0:5:5,
margin = 35mm,left_margin = 50mm,
right_margin = 50mm)
end
#vline!([mean(Arr)], color = :black, linewidth = 8)
return p1
end
#for countsMatrix in scnorm_counts
# "Weibull", "Random", "UniformObserved", "CellVariable"
Weibull_1 = make_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_1_isoforms_array.txt", "1 Isoform")
Weibull_2 = make_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_2_isoforms_array.txt", "2 Isoforms")
Weibull_3 = make_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_3_isoforms_array.txt", "3 Isoforms")
Weibull_4 = make_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_4_isoforms_array.txt", "4 Isoforms")
Weibull_real = make_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_real_isoforms_array.txt", "Real")
Random_1 = make_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_1_isoforms_array.txt", "1 Isoform")
Random_2 = make_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_2_isoforms_array.txt", "2 Isoforms")
Random_3 = make_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_3_isoforms_array.txt", "3 Isoforms")
Random_4 = make_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_4_isoforms_array.txt", "4 Isoforms")
Random_real = make_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_real_isoforms_array.txt", "Real")
UniformObserved_1 = make_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_1_isoforms_array.txt", "1 Isoform")
UniformObserved_2 = make_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_2_isoforms_array.txt", "2 Isoforms")
UniformObserved_3 = make_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_3_isoforms_array.txt", "3 Isoforms")
UniformObserved_4 = make_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_4_isoforms_array.txt", "4 Isoforms")
UniformObserved_real = make_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_real_isoforms_array.txt", "Real")
CellVariable_1 = make_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_1_isoforms_array.txt", "1 Isoform")
CellVariable_2 = make_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_2_isoforms_array.txt", "2 Isoforms")
CellVariable_3 = make_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_3_isoforms_array.txt", "3 Isoforms")
CellVariable_4 = make_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_4_isoforms_array.txt", "4 Isoforms")
CellVariable_real = make_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_real_isoforms_array.txt", "Real")
p3 = plot( Weibull_1, Random_1, UniformObserved_1, CellVariable_1,
Weibull_2, Random_2,UniformObserved_2, CellVariable_2,
Weibull_3, Random_3,UniformObserved_3, CellVariable_3,
Weibull_4, Random_4,UniformObserved_4, CellVariable_4,
Weibull_real, Random_real,UniformObserved_real, CellVariable_real,
layout = (5,4), legend = false, size = (750 *8, 900*8), axis = (font(90)), titlefontsize=90,)
savefig(p3, "figures/figure4/figure4.png")
###############################################################
using JLD2
using DelimitedFiles
using HypothesisTests
using DataFrames
Weibull_1 = readdlm("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_1_isoforms_array.txt")
Weibull_2 = readdlm("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_2_isoforms_array.txt")
Weibull_3 = readdlm("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_3_isoforms_array.txt")
Weibull_4 = readdlm("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_4_isoforms_array.txt")
Weibull_real = readdlm("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_real_isoforms_array.txt")
Random_1 = readdlm("figures/figure5_data/Random_H1_24_scnorm_counts.txt_1_isoforms_array.txt")
Random_2 = readdlm("figures/figure5_data/Random_H1_24_scnorm_counts.txt_2_isoforms_array.txt")
Random_3 = readdlm("figures/figure5_data/Random_H1_24_scnorm_counts.txt_3_isoforms_array.txt")
Random_4 = readdlm("figures/figure5_data/Random_H1_24_scnorm_counts.txt_4_isoforms_array.txt")
Random_real = readdlm("figures/figure5_data/Random_H1_24_scnorm_counts.txt_real_isoforms_array.txt")
UniformObserved_1 = readdlm("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_1_isoforms_array.txt")
UniformObserved_2 = readdlm("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_2_isoforms_array.txt")
UniformObserved_3 = readdlm("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_3_isoforms_array.txt")
UniformObserved_4 = readdlm("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_4_isoforms_array.txt")
UniformObserved_real = readdlm("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_real_isoforms_array.txt")
CellVariable_1 = readdlm("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_1_isoforms_array.txt")
CellVariable_2 = readdlm("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_2_isoforms_array.txt")
CellVariable_3 = readdlm("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_3_isoforms_array.txt")
CellVariable_4 = readdlm("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_4_isoforms_array.txt")
CellVariable_real = readdlm("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_real_isoforms_array.txt")
df = DataFrame(IsoformsSimulated=Int64[], Comparison = String[], pValue = Float64[])
append!(df, DataFrame(IsoformsSimulated = [1], Comparison = ["All"], pValue=[pvalue(KSampleADTest(vec(Weibull_1), vec(Random_1), vec(UniformObserved_1), vec(CellVariable_1)))]))
append!(df, DataFrame(IsoformsSimulated = [2], Comparison = "All", pValue=[pvalue(KSampleADTest(vec(Weibull_2), vec(Random_2), vec(UniformObserved_2), vec(CellVariable_2)))]))
append!(df, DataFrame(IsoformsSimulated = [3], Comparison = "All", pValue=[pvalue(KSampleADTest(vec(Weibull_3), vec(Random_3), vec(UniformObserved_3), vec(CellVariable_3)))]))
append!(df, DataFrame(IsoformsSimulated = [4], Comparison = "All", pValue=[pvalue(KSampleADTest(vec(Weibull_4), vec(Random_4), vec(UniformObserved_4), vec(CellVariable_4)))]))
append!(df, DataFrame(IsoformsSimulated = [1], Comparison = "CellVarUnif", pValue=[pvalue(KSampleADTest(vec(UniformObserved_1), vec(CellVariable_1)))]))
append!(df, DataFrame(IsoformsSimulated = [2], Comparison = "CellVarUnif", pValue=[pvalue(KSampleADTest( vec(UniformObserved_2), vec(CellVariable_2)))]))
append!(df, DataFrame(IsoformsSimulated = [3], Comparison = "CellVarUnif", pValue=[pvalue(KSampleADTest(vec(UniformObserved_3), vec(CellVariable_3)))]))
append!(df, DataFrame(IsoformsSimulated = [4], Comparison = "CellVarUnif", pValue=[pvalue(KSampleADTest(vec(UniformObserved_4), vec(CellVariable_4)))]))
jldopen("figures/figure4_data/AD_test_results.jld2", "w") do file
file["df"] = df
end
####################################################################
# Overlap plots
####################################################################
function make_overlap_hist(path, titleArg)
Arr = readdlm(path)
p1 = histogram(Arr, title = titleArg, normalize=:pdf, bins = 100,
ylims = (0,4), color = palette(:default)[2],
axis = (font(150)), titlefontsize=150, yticks = 0:2:4,
xticks = 0:0.5:1,
margin = 35mm,left_margin = 50mm,
right_margin = 50mm)
return p1
end
#For H1_24 dataset
#Weibull
Weibull_1 = make_overlap_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_1_isoforms_overlap_array.txt", "1 Isoform")
Weibull_2 = make_overlap_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_2_isoforms_overlap_array.txt", "2 Isoforms")
Weibull_3 = make_overlap_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_3_isoforms_overlap_array.txt", "3 Isoforms")
Weibull_4 = make_overlap_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_4_isoforms_overlap_array.txt", "4 Isoforms")
outplot = plot(Weibull_1, Weibull_2, Weibull_3, Weibull_4, legend = false)
savefig(outplot, "figures/figure4/Weibull_overlap_H1_24.png")
#Random
Random_1 = make_overlap_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_1_isoforms_overlap_array.txt", "1 Isoform")
Random_2 = make_overlap_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_2_isoforms_overlap_array.txt", "2 Isoforms")
Random_3 = make_overlap_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_3_isoforms_overlap_array.txt", "3 Isoforms")
Random_4 = make_overlap_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_4_isoforms_overlap_array.txt", "4 Isoforms")
outplot = plot(Random_1, Random_2, Random_3, Random_4, legend = false)
savefig(outplot, "figures/figure4/Random_overlap_H1_24.png")
UniformObserved_1 = make_overlap_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_1_isoforms_overlap_array.txt", "1 Isoform")
UniformObserved_2 = make_overlap_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_2_isoforms_overlap_array.txt", "2 Isoforms")
UniformObserved_3 = make_overlap_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_3_isoforms_overlap_array.txt", "3 Isoforms")
UniformObserved_4 = make_overlap_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_4_isoforms_overlap_array.txt", "4 Isoforms")
outplot = plot(UniformObserved_1, UniformObserved_2, UniformObserved_3, UniformObserved_4 , legend = false)
savefig(outplot, "figures/figure4/UniformObserved_overlap_H1_24.png")
CellVariable_1 = make_overlap_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_1_isoforms_overlap_array.txt", "1 Isoform")
CellVariable_2 = make_overlap_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_2_isoforms_overlap_array.txt", "2 Isoforms")
CellVariable_3 = make_overlap_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_3_isoforms_overlap_array.txt", "3 Isoforms")
CellVariable_4 = make_overlap_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_4_isoforms_overlap_array.txt", "4 Isoforms")
outplot = plot(CellVariable_1, CellVariable_2, CellVariable_3, CellVariable_4, legend = false)
savefig(outplot, "figures/figure4/CellVariable_overlap_H1_24.png")
p3 = plot( Weibull_1, Random_1, UniformObserved_1, CellVariable_1,
Weibull_2, Random_2,UniformObserved_2, CellVariable_2,
Weibull_3, Random_3,UniformObserved_3, CellVariable_3,
Weibull_4, Random_4,UniformObserved_4, CellVariable_4,
layout = (4,4), legend = false, size = (750 *8, 750*8), axis = (font(90)), titlefontsize=90,)
savefig(p3, "figures/figure4/figure4_overlap.png")
##############################################################################
# Dropouts
##############################################################################
function make_drop_hist(path, titleArg)
Arr = readdlm(path)
if titleArg=="1 Isoform"
p1 = histogram(rand(Arr, 100000) , title = titleArg, normalize=:pdf,
bins = 100, ylims = (0,10), ylabel="Probability Density",
margin = 5mm)
return p1
elseif titleArg == "3 Isoforms"
p1 =histogram(rand(Arr, 100000) , title = titleArg, normalize=:pdf,
bins = 100, ylims = (0,10), ylabel="Probability Density",
xlabel = "p(Dropout)",
margin = 5mm)
return p1
elseif titleArg == "4 Isoforms"
p1 = histogram(rand(Arr, 100000) , title = titleArg, normalize=:pdf,
bins = 100, xlabel="p(Dropout)", ylims = (0,10),
margin = 5mm)
return p1
else
p1 = histogram(rand(Arr, 100000) , title = titleArg, normalize=:pdf,
bins = 100, margin = 5mm, ylims = (0,10))
return p1
end
end
#For H1_24 dataset
#Weibull
Weibull_1 = make_drop_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_1_isoforms_pdrop_array.txt", "1 Isoform")
Weibull_2 = make_drop_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_2_isoforms_pdrop_array.txt", "2 Isoforms")
Weibull_3 = make_drop_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_3_isoforms_pdrop_array.txt", "3 Isoforms")
Weibull_4 = make_drop_hist("figures/figure5_data/Weibull_H1_24_scnorm_counts.txt_4_isoforms_pdrop_array.txt", "4 Isoforms")
outplot = plot(Weibull_1, Weibull_2, Weibull_3, Weibull_4, legend = false)
savefig(outplot, "figures/figure4/Weibull_pdrop_H1_24.png")
#Random
Random_1 = make_drop_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_1_isoforms_pdrop_array.txt", "1 Isoform")
Random_2 = make_drop_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_2_isoforms_pdrop_array.txt", "2 Isoforms")
Random_3 = make_drop_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_3_isoforms_pdrop_array.txt", "3 Isoforms")
Random_4 = make_drop_hist("figures/figure5_data/Random_H1_24_scnorm_counts.txt_4_isoforms_pdrop_array.txt", "4 Isoforms")
outplot = plot(Random_1, Random_2, Random_3, Random_4, legend = false)
savefig(outplot, "figures/figure4/Random_pdrop_H1_24.png")
UniformObserved_1 = make_drop_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_1_isoforms_pdrop_array.txt", "1 Isoform")
UniformObserved_2 = make_drop_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_2_isoforms_pdrop_array.txt", "2 Isoforms")
UniformObserved_3 = make_drop_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_3_isoforms_pdrop_array.txt", "3 Isoforms")
UniformObserved_4 = make_drop_hist("figures/figure5_data/UniformObserved_H1_24_scnorm_counts.txt_4_isoforms_pdrop_array.txt", "4 Isoforms")
outplot = plot(UniformObserved_1, UniformObserved_2, UniformObserved_3, UniformObserved_4, legend = false)
savefig(outplot, "figures/figure4/UniformObserved_pdrop_H1_24.png")
CellVariable_1 = make_drop_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_1_isoforms_pdrop_array.txt", "1 Isoform")
CellVariable_2 = make_drop_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_2_isoforms_pdrop_array.txt", "2 Isoforms")
CellVariable_3 = make_drop_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_3_isoforms_pdrop_array.txt", "3 Isoforms")
CellVariable_4 = make_drop_hist("figures/figure5_data/CellVariable_H1_24_scnorm_counts.txt_4_isoforms_pdrop_array.txt", "4 Isoforms")
outplot = plot(CellVariable_1, CellVariable_2, CellVariable_3, CellVariable_4, legend = false)
savefig(outplot, "figures/figure4/CellVariable_pdrop_H1_24.png")
#Weibull