Mercurial > repos > padge > mcdoe
comparison main.jl @ 0:cc0957c46408 draft
"planemo upload for repository https://github.com/kirstvh/MultiplexCrisprDOE commit b6c1b1860eee82b06ed4a592d1f9eee6886be318-dirty"
author | padge |
---|---|
date | Thu, 12 May 2022 17:39:18 +0000 |
parents | |
children | 4a5c94d1d8bb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cc0957c46408 |
---|---|
1 using Pkg | |
2 Pkg.add("Plots"); | |
3 Pkg.add("Distributions"); | |
4 Pkg.add("LinearAlgebra"); | |
5 Pkg.add("Combinatorics"); | |
6 Pkg.add("BioCCP"); | |
7 Pkg.add("ArgParse"); | |
8 Pkg.add("XLSX"); | |
9 Pkg.add("DataFrames"); | |
10 Pkg.add("Weave"); | |
11 Pkg.add("DataStructures"); | |
12 Pkg.add("PrettyTables"); | |
13 | |
14 using Random | |
15 using Plots | |
16 using Distributions | |
17 using LinearAlgebra | |
18 using Combinatorics | |
19 using BioCCP | |
20 using ArgParse | |
21 using XLSX | |
22 using DataFrames | |
23 using Weave | |
24 using DataStructures | |
25 using PrettyTables | |
26 | |
27 global current_dir = pwd() | |
28 include("MultiplexCrisprDOE.jl"); | |
29 | |
30 function main(args) | |
31 | |
32 aps = ArgParseSettings("MultiplexCrisprDOE") | |
33 | |
34 @add_arg_table! aps begin | |
35 "gfd" #, "gRNA_freq_dist" | |
36 action = :command # adds a command which will be read from an argument | |
37 help = "gRNA/Cas9 frequencies" | |
38 "ged" #, "gRNA_edit_dist" | |
39 action = :command | |
40 help = "gRNA/Cas9 editing efficiencies" | |
41 "sim" # simulation | |
42 action = :command | |
43 help = "simulation-based approaches for computing the minimal plant library size that guarantees full combinatorial coverage (and other relevant statistics)" | |
44 "ccp" # bioccp | |
45 action = :command | |
46 help = "BioCCP-based approaches for computing the minimal plant library size that guarantees full combinatorial coverage (and other relevant statistics)" | |
47 end | |
48 | |
49 @add_arg_table! aps["gfd"] begin # add command arg_table: same as usual, but invoked on s["grna"] | |
50 "m" | |
51 arg_type = Int | |
52 help = "plant library size" | |
53 "sd" | |
54 arg_type = Int | |
55 help = "the standard deviation on the gRNA abundances (in terms of absolute or relative frequency)" | |
56 "l" | |
57 arg_type = Int | |
58 help = "minimal gRNA abundance (in terms of absolute or relative frequency)" | |
59 "u" | |
60 arg_type = Int | |
61 help = "maximal gRNA abundance (in terms of absolute or relative frequency)" | |
62 "n" #, "--n_gRNA_total" | |
63 arg_type = Int | |
64 help = "the total number of gRNAs in the experiment" | |
65 "--normalize" | |
66 action = :store_true | |
67 # arg_type = Bool | |
68 # default = true | |
69 help = "if provided, the gRNA abundances (absolute frequencies) are converted into relative frequencies" | |
70 "--visualize" | |
71 action = :store_true | |
72 # arg_type = Bool | |
73 # default = false | |
74 help = "if provided, a histogram of all gRNA abundances is plotted" | |
75 "--out_file" | |
76 arg_type = String | |
77 default = "gRNA_reads" | |
78 help = "Output excel file prefix" | |
79 end | |
80 | |
81 @add_arg_table! aps["ged"] begin # add command arg_table: same as usual, but invoked on s["grna"] | |
82 "f_act" | |
83 arg_type = Float16 | |
84 help = "fraction of all gRNAs that is active" | |
85 "eps_edit_act" | |
86 arg_type = Float16 | |
87 help = "Average genome editing efficiency for active gRNAs - mean of the genome editing efficiency distribution for active gRNAs" | |
88 "eps_edit_inact" | |
89 arg_type = Float16 | |
90 help = "Average genome editing efficiency for inactive gRNAs - mean of the genome editing efficiency distribution for inactive gRNAs" | |
91 "sd_act" | |
92 arg_type = Float16 | |
93 help = "standard deviation of the genome editing efficiency distributions for active and inactive gRNAs" | |
94 "n_gRNA_total" | |
95 arg_type = Int | |
96 help = "the total number of gRNAs in the experiment" | |
97 "--visualize" | |
98 action = :store_true | |
99 # arg_type = Bool | |
100 # default = false | |
101 help = "if provided a histogram of all genome editing efficiency is plotted" | |
102 "--out_file" | |
103 arg_type = String | |
104 default = "gRNA_edit" | |
105 help = "Output excel file prefix" | |
106 end | |
107 | |
108 @add_arg_table! aps["sim"] begin | |
109 "M" #, "--mode" | |
110 # action = :command | |
111 # dest_name = "M" | |
112 arg_type = Int | |
113 range_tester = x -> 1 <= x <= 4 | |
114 help = """Select simulation mode (1: simulate_Nₓ₁; 2: simulate_Nₓ₂; 3: simulate_Nₓ₃; 4: simulate_Nₓ₂_countKOs)""" | |
115 "x" | |
116 arg_type = Int | |
117 help = "number of target genes in the experiment" | |
118 "g" | |
119 arg_type = Int | |
120 help = "number of gRNAs designed per target gene" | |
121 "r" | |
122 arg_type = Int | |
123 help = "number of gRNA sequences per combinatorial gRNA/Cas construct" | |
124 "t"#, "--n_gRNA_total" | |
125 arg_type = Int | |
126 help = "total number of gRNAs in the experiment" | |
127 "f"#, "--p_gRNA_freq" | |
128 arg_type = String #Vector{Float64} | |
129 help = "vector with relative frequencies for all gRNAs in the construct library (normalized!)" | |
130 "e"#, "--p_gRNA_edit" | |
131 arg_type = String #Vector{Float64} | |
132 help = "vector with genome editing efficiencies for all gRNAs" | |
133 "E"#, "--ϵ_KO" | |
134 arg_type=Float16 | |
135 help = "global knockout efficiency; fraction of mutations leading to effective gene knockout" | |
136 "--i", "--iter" | |
137 arg_type = Int | |
138 default = 500 | |
139 help = "number of CRISPR/Cas experiments that are simulated" | |
140 end | |
141 | |
142 @add_arg_table! aps["ccp"] begin | |
143 "M"#, "--mode" | |
144 arg_type = Int | |
145 range_tester = x -> 1 <= x <= 9 | |
146 help = """Select BioCCP mode (1: BioCCP_Nₓ₁; 2: BioCCP_Nₓ₂; 3: BioCCP_Nₓ₃; 4: BioCCP_Pₓ₁; 5: BioCCP_Pₓ₂ ; | |
147 6: BioCCP_Pₓ₃; 7: BioCCP_γₓ₁; 8: BioCCP_γₓ₂; 9: BioCCP_γₓ₃)""" | |
148 "x" | |
149 arg_type = Int | |
150 help = "number of target genes in the experiment" | |
151 "N" | |
152 arg_type = Int | |
153 help = "(Minimum) plant library size" | |
154 "--s", "--step" | |
155 arg_type = Int | |
156 default = 5 | |
157 range_tester = x -> 1 <= x <= 10 | |
158 help = "Step size for plant library size (optional for calculating expected combinatorial coverage / plant library size)" | |
159 "--MN", "--max_pl_size" | |
160 arg_type = Int | |
161 default = 4000 | |
162 help = "Maximum plant library size (optional for calculating expected combinatorial coverage / plant library size)" | |
163 "g" | |
164 arg_type = Int | |
165 help = "number of gRNAs designed per target gene" | |
166 "r" | |
167 arg_type = Int | |
168 help = "number of gRNA sequences per combinatorial gRNA/Cas construct" | |
169 "t"#, "--n_gRNA_total" | |
170 arg_type = Int | |
171 help = "total number of gRNAs in the experiment" | |
172 "f"#, "--p_gRNA_freq" | |
173 arg_type = String #Vector{Float64} | |
174 help = "File containing vector with relative frequencies for all gRNAs in the construct library (normalized!)" | |
175 "e"#, "--p_gRNA_edit" | |
176 arg_type = String #Vector{Float64} | |
177 help = "File containing vector with genome editing efficiencies for all gRNAs" | |
178 "E"#, "--ϵ_KO" | |
179 arg_type=Float16 | |
180 help = "global knockout efficiency; fraction of mutations leading to effective gene knockout" | |
181 end | |
182 | |
183 parsed_args = parse_args(args, aps) | |
184 command_args = parsed_args[parsed_args["%COMMAND%"]] | |
185 println(command_args) | |
186 | |
187 tool_info = OrderedDict() | |
188 args_info = OrderedDict() | |
189 grna_dict = Dict() | |
190 out_dict = Dict() | |
191 if parsed_args["%COMMAND%"] == "gfd" | |
192 tool_info["method"] = "gRNA_ frequency _distribution" | |
193 tool_info["description"] = "Generates vector with frequencies in the combinatorial "* | |
194 "gRNA/Cas9 construct library for all gRNAs" | |
195 tool_info["mode"] = "" | |
196 tool_info["mode_description"] = "" | |
197 args_info["Plant library size"] = command_args["m"] | |
198 args_info["SD on the gRNA abundances"] = command_args["sd"] | |
199 args_info["Minimal gRNA abundance"] = command_args["l"] | |
200 args_info["Maximal gRNA abundance"] = command_args["u"] | |
201 args_info["Total number of gRNAs"] = command_args["n"] | |
202 args_info["Convert gRNA abundances to relative frequencies"] = string(command_args["normalize"]) | |
203 args_info["Plot gRNA abundances"] = string(command_args["visualize"]) | |
204 | |
205 m = command_args["m"] | |
206 sd = command_args["sd"] | |
207 l = command_args["l"] | |
208 u = command_args["u"] | |
209 n_gRNA_total = command_args["n"] | |
210 norm = command_args["normalize"] | |
211 viz = command_args["visualize"] | |
212 | |
213 println(string(norm)) | |
214 println(string(viz)) | |
215 | |
216 p_gRNA_reads = gRNA_frequency_distribution(m, sd, l, u, n_gRNA_total; normalize = norm, visualize = false) | |
217 grna_dict["p_gRNA_reads"] = p_gRNA_reads | |
218 | |
219 # println(p_gRNA_reads) | |
220 # write to excel file | |
221 fn = command_args["out_file"] * ".xlsx" | |
222 labels = ["gRNA_read"] | |
223 columns = Vector() | |
224 push!(columns, p_gRNA_reads) | |
225 XLSX.openxlsx(fn, mode="w") do xf | |
226 sheet = xf[1] | |
227 XLSX.writetable!(sheet, columns, labels) | |
228 end | |
229 | |
230 out_dict["output file"] = fn | |
231 | |
232 elseif parsed_args["%COMMAND%"] == "ged" | |
233 tool_info["method"] = "gRNA_ edit _distribution" | |
234 tool_info["description"] = "Generates vector with genome editing efficiencies "* | |
235 "for all the gRNAs in the experiment" | |
236 tool_info["mode"] = "" | |
237 tool_info["mode_description"] = "" | |
238 args_info["Fraction of active gRNAs"] = command_args["f_act"] | |
239 args_info["Average genome editing efficiency of active gRNAs"] = command_args["eps_edit_act"] | |
240 args_info["Average genome editing efficiency of inactive gRNAs"] = command_args["eps_edit_inact"] | |
241 args_info["Standard deviation"] = command_args["sd_act"] | |
242 args_info["Total number of gRNAs"] = command_args["n_gRNA_total"] | |
243 args_info["Plot genome editing efficiency"] = string(command_args["visualize"]) | |
244 | |
245 f_act = command_args["f_act"] | |
246 eps_edit_act = command_args["eps_edit_act"] | |
247 eps_edit_inact = command_args["eps_edit_inact"] | |
248 sd_act = command_args["sd_act"] | |
249 n_gRNA_total = command_args["n_gRNA_total"] | |
250 viz = ["visualize"] | |
251 | |
252 p_gRNA_edit = gRNA_edit_distribution(f_act, eps_edit_act, eps_edit_inact, sd_act, n_gRNA_total; visualize=false) | |
253 grna_dict["p_gRNA_edit"] = p_gRNA_edit | |
254 # write to excel file | |
255 fn = command_args["out_file"] * ".xlsx" | |
256 labels = ["gRNA_edit_efficiency"] | |
257 columns = Vector() | |
258 push!(columns, p_gRNA_edit) | |
259 XLSX.openxlsx(fn, mode="w") do xf | |
260 sheet = xf[1] | |
261 XLSX.writetable!(sheet, columns, labels) | |
262 end | |
263 | |
264 out_dict["output file"] = fn | |
265 | |
266 elseif parsed_args["%COMMAND%"] == "sim" || parsed_args["%COMMAND%"] == "ccp" | |
267 | |
268 filename = command_args["f"] | |
269 sheet = 1 | |
270 data = DataFrame(XLSX.readtable(filename, sheet)...) | |
271 p_gRNA_reads = data[!,"gRNA_read"] | |
272 p_gRNA_reads_normalized = p_gRNA_reads/sum(p_gRNA_reads) # normalize | |
273 f = p_gRNA_reads_normalized | |
274 grna_dict["p_gRNA_reads"] = f | |
275 | |
276 filename = command_args["e"] | |
277 sheet = 1 | |
278 data = DataFrame(XLSX.readtable(filename, sheet)...) | |
279 p_gRNA_edit = data[!,"gRNA_edit_efficiency"] | |
280 e = p_gRNA_edit | |
281 grna_dict["p_gRNA_edit"] = e | |
282 | |
283 x = command_args["x"] | |
284 g = command_args["g"] | |
285 r = command_args["r"] | |
286 t = command_args["t"] # n_gRNA_total | |
287 E = command_args["E"] # ϵ_KO # iter = 500 | |
288 | |
289 args_info["# of target genes in the experiment"] = command_args["x"] | |
290 args_info["# of gRNAs designed per target gene"] = command_args["g"] | |
291 args_info["# of gRNAs / combi gRNA/Cas construct"] = command_args["r"] | |
292 args_info["Total number of gRNAs"] = command_args["t"] | |
293 args_info["Relative frequencies for all gRNAs"] = command_args["f"] | |
294 args_info["Genome editing efficiencies for all gRNAs"] = command_args["e"] | |
295 args_info["Global knockout efficiency"] = command_args["E"] | |
296 | |
297 if parsed_args["%COMMAND%"] == "sim" | |
298 tool_info["method"] = "simulation" | |
299 tool_info["description"] = "simulation-based approaches for computing the minimal "* | |
300 "plant library size that guarantees full combinatorial "* | |
301 "coverage (and other relevant statistics)" | |
302 i = command_args["i"] # iter = 500 | |
303 args_info["# of simulated experiments"] = command_args["i"] | |
304 | |
305 if command_args["M"] == 1 | |
306 tool_info["mode"] = "simulate_Nx1" | |
307 tool_info["mode_description"] = "Computes the expected value and the standard deviation "* | |
308 "of the minimal plant library size for full coverage of "* | |
309 "all single gene knockouts (E[Nx,1] and σ[Nx,1]) using simulation" | |
310 E_sim, sd_sim = simulate_Nₓ₁(x, g, r, t, f, e, E; iter=i) | |
311 out_dict["E_sim"] = E_sim | |
312 out_dict["sd_sim"] = sd_sim | |
313 | |
314 elseif command_args["M"] == 2 | |
315 tool_info["mode"] = "simulate_Nx2" | |
316 tool_info["mode_description"] = "Computes the expected value and the standard deviation of "* | |
317 "the minimal plant library size for full coverage of "* | |
318 "all pairwise combinations of gene knockouts in a "* | |
319 "multiplex CRISPR/Cas experiment (E[Nx,2] and σ[Nx,2]) using simulation" | |
320 | |
321 E_sim, sd_sim = simulate_Nₓ₂(x, g, r, t, f, e, E; iter=i) | |
322 out_dict["E_sim"] = E_sim | |
323 out_dict["sd_sim"] = sd_sim | |
324 | |
325 elseif command_args["M"] == 3 | |
326 tool_info["mode"] = "simulate_Nx3" | |
327 tool_info["mode_description"] = "Computes the expected value and the standard deviation of "* | |
328 "the minimal plant library size for full coverage of "* | |
329 "all triple combinations of gene knockouts in a "* | |
330 "multiplex CRISPR/Cas experiment (E[Nx,3] and σ[Nx,3]) using simulation" | |
331 | |
332 E_sim, sd_sim = simulate_Nₓ₃(x, g, r, t, f, e, E; iter=i) | |
333 out_dict["E_sim"] = E_sim | |
334 out_dict["sd_sim"] = sd_sim | |
335 | |
336 elseif command_args["M"] == 4 | |
337 tool_info["mode"] = "simulate_Nx2_countKOs" | |
338 tool_info["mode_description"] = "Counts of the number of knockouts per plant in the experiment" | |
339 | |
340 n_KOs_vec = simulate_Nₓ₂_countKOs(x, g, r, t, f, e, E; iter=i) | |
341 out_dict["n_KOs_vec"] = n_KOs_vec | |
342 | |
343 # write to excel file | |
344 fn = "countKOs.xlsx" | |
345 labels = ["countKOs"] | |
346 columns = Vector() | |
347 push!(columns, n_KOs_vec) | |
348 XLSX.openxlsx(fn, mode="w") do xf | |
349 sheet = xf[1] | |
350 XLSX.writetable!(sheet, columns, labels) | |
351 end | |
352 | |
353 out_dict["output file"] = fn | |
354 | |
355 end | |
356 | |
357 elseif parsed_args["%COMMAND%"] == "ccp" | |
358 tool_info["method"] = "BioCCP" | |
359 tool_info["description"] = "BioCCP-based approaches for computing the minimal "* | |
360 "plant library size that guarantees full combinatorial "* | |
361 "coverage (and other relevant statistics)" | |
362 | |
363 N = command_args["N"] | |
364 if haskey(command_args,"s") && haskey(command_args,"MN") | |
365 s = command_args["s"] | |
366 MN = command_args["MN"] | |
367 args_info["Step size"] = command_args["s"] | |
368 args_info["Maximum Plant library size"] = command_args["MN"] | |
369 end | |
370 args_info["Plant library size"] = command_args["N"] | |
371 | |
372 | |
373 if command_args["M"] == 1 | |
374 tool_info["mode"] = "BioCCP_Nx1" | |
375 tool_info["mode_description"] = "Computes the expected value and the standard deviation of "* | |
376 "the minimal plant library size for full coverage of all "* | |
377 "single gene knockouts (E[Nx,1] and σ[Nx,1]) using BioCCP" | |
378 | |
379 E_sim, sd_sim = BioCCP_Nₓ₁(x, g, r, t, f, e, E) | |
380 out_dict["E_sim"] = E_sim | |
381 out_dict["sd_sim"] = sd_sim | |
382 | |
383 elseif command_args["M"] == 2 | |
384 tool_info["mode"] = "BioCCP_Nx2" | |
385 tool_info["mode_description"] = "Computes the expected value and the standard deviation of "* | |
386 "the minimal plant library size for full coverage of all "* | |
387 "pairwise combinations of gene knockouts in a multiplex "* | |
388 "CRISPR/Cas experiment (E[Nx,2] and σ[Nx,2]) using BioCCP" | |
389 | |
390 E_sim, sd_sim = BioCCP_Nₓ₂(x, g, r, t, f, e, E) | |
391 out_dict["E_sim"] = E_sim | |
392 out_dict["sd_sim"] = sd_sim | |
393 | |
394 elseif command_args["M"] == 3 | |
395 tool_info["mode"] = "BioCCP_Nx3" | |
396 tool_info["mode_description"] = "Computes the expected value and the standard deviation of "* | |
397 "the minimal plant library size for full coverage of all triple combinations of "* | |
398 "gene knockouts in a multiplex CRISPR/Cas experiment (E[Nx,3] and σ[Nx,3]) using BioCCP" | |
399 | |
400 E_sim, sd_sim = BioCCP_Nₓ₃(x, g, r, t, f, e, E) | |
401 out_dict["E_sim"] = E_sim | |
402 out_dict["sd_sim"] = sd_sim | |
403 | |
404 elseif command_args["M"] == 4 | |
405 tool_info["mode"] = "BioCCP_Px1" | |
406 tool_info["mode_description"] = "Computes the probability of full coverage of "* | |
407 "all single gene knockouts (Px,1) for an experiment with given "* | |
408 "plant library size using BioCCP" | |
409 | |
410 if s != nothing && MN != nothing | |
411 plant_library_sizes = N:s:MN | |
412 else | |
413 plant_library_sizes = N | |
414 end | |
415 PT = [] | |
416 global N_95_P = nothing | |
417 for N in plant_library_sizes | |
418 Pr = BioCCP_Pₓ₁(x, N, g, r, t, f, e, E) | |
419 push!(PT, Pr) | |
420 if Pr < 0.95 | |
421 N_95_P = N | |
422 end | |
423 end | |
424 # P = BioCCP_Pₓ₁(x, N, g, r, t, f, e, E) | |
425 out_dict["P_sim"] = PT | |
426 out_dict["N_95_P"] = N_95_P | |
427 out_dict["pls"] = plant_library_sizes | |
428 | |
429 elseif command_args["M"] == 5 | |
430 tool_info["mode"] = "BioCCP_Px2" | |
431 tool_info["mode_description"] = "Computes the probability of full coverage of "* | |
432 "all pairwise combinations of gene knockouts (Px,2) "* | |
433 "for an experiment with given plant library size using BioCCP" | |
434 | |
435 if s != nothing && MN != nothing | |
436 plant_library_sizes = N:s:MN | |
437 else | |
438 plant_library_sizes = N | |
439 end | |
440 PT = [] | |
441 global N_95_P = nothing | |
442 for N in plant_library_sizes | |
443 Pr = BioCCP_Pₓ₂(x, N, g, r, t, f, e, E) | |
444 push!(PT, Pr) | |
445 if Pr < 0.95 | |
446 N_95_P = N | |
447 end | |
448 end | |
449 # P = BioCCP_Pₓ₂(x, N, g, r, t, f, e, E) | |
450 out_dict["P_sim"] = PT | |
451 out_dict["N_95_P"] = N_95_P | |
452 out_dict["pls"] = plant_library_sizes | |
453 | |
454 elseif command_args["M"] == 6 | |
455 tool_info["mode"] = "BioCCP_Px3" | |
456 tool_info["mode_description"] = "Computes the probability of full coverage of all "* | |
457 "triple combinations of gene knockouts (Px,3) for an experiment "* | |
458 "with given plant library size using BioCCP" | |
459 | |
460 if s != nothing && MN != nothing | |
461 plant_library_sizes = N:s:MN | |
462 else | |
463 plant_library_sizes = N | |
464 end | |
465 PT = [] | |
466 global N_95_P = nothing | |
467 for N in plant_library_sizes | |
468 Pr = BioCCP_Pₓ₃(x, N, g, r, t, f, e, E) | |
469 push!(PT, Pr) | |
470 if Pr < 0.95 | |
471 N_95_P = N | |
472 end | |
473 end | |
474 # P = BioCCP_Pₓ₃(x, N, g, r, t, f, e, E) | |
475 out_dict["P_sim"] = PT | |
476 out_dict["N_95_P"] = N_95_P | |
477 out_dict["pls"] = plant_library_sizes | |
478 | |
479 elseif command_args["M"] == 7 | |
480 tool_info["mode"] = "BioCCP_γx1" | |
481 tool_info["mode_description"] = "Computes the expected coverage of all "* | |
482 "single gene knockouts (E[γx,1]) for an experiment "* | |
483 "with given plant library size using BioCCP" | |
484 if s != nothing && MN != nothing | |
485 plant_library_sizes = N:s:MN | |
486 else | |
487 plant_library_sizes = N | |
488 end | |
489 exp_cov = [] | |
490 global N_95 = nothing | |
491 for N in plant_library_sizes | |
492 E_cov = BioCCP_γₓ₁(x, N, g, r, t, f, e, E) | |
493 push!(exp_cov, E_cov) | |
494 if E_cov < 0.95 | |
495 N_95 = N | |
496 end | |
497 end | |
498 # E_sim, sd_sim = BioCCP_γₓ₁(x, N, g, r, t, f, e, E) | |
499 out_dict["E_cov"] = exp_cov | |
500 out_dict["N_95"] = N_95 | |
501 out_dict["pls"] = plant_library_sizes | |
502 | |
503 elseif command_args["M"] == 8 | |
504 tool_info["mode"] = "BioCCP_γx2" | |
505 tool_info["mode_description"] = "Computes the expected coverage of all "* | |
506 "pairwise combinations of gene knockouts (E[γx,2]) for an experiment with "* | |
507 "given plant library size using BioCCP" | |
508 | |
509 if s != nothing && MN != nothing | |
510 plant_library_sizes = N:s:MN | |
511 else | |
512 plant_library_sizes = N | |
513 end | |
514 exp_cov = [] | |
515 global N_95 = nothing | |
516 for N in plant_library_sizes | |
517 E_cov = BioCCP_γₓ₂(x, N, g, r, t, f, e, E) | |
518 push!(exp_cov, E_cov) | |
519 if E_cov < 0.95 | |
520 N_95 = N | |
521 end | |
522 end | |
523 # E_sim, sd_sim = BioCCP_γₓ₂(x, N, g, r, t, f, e, E) | |
524 out_dict["E_cov"] = exp_cov | |
525 out_dict["N_95"] = N_95 | |
526 out_dict["pls"] = plant_library_sizes | |
527 | |
528 elseif command_args["M"] == 9 | |
529 tool_info["mode"] = "BioCCP_γx3" | |
530 tool_info["mode_description"] = "Computes the expected coverage of all "* | |
531 "triple combinations of gene knockouts (E[γx,3]) for an experiment with "* | |
532 "given plant library size using BioCCP" | |
533 | |
534 if s != nothing && MN != nothing | |
535 plant_library_sizes = N:s:MN | |
536 else | |
537 plant_library_sizes = N | |
538 end | |
539 exp_cov = [] | |
540 global N_95 = nothing | |
541 for N in plant_library_sizes | |
542 E_cov = BioCCP_γₓ₃(x, N, g, r, t, f, e, E) | |
543 push!(exp_cov, E_cov) | |
544 if E_cov < 0.95 | |
545 N_95 = N | |
546 end | |
547 end | |
548 # E_sim, sd_sim = BioCCP_γₓ₃(x, N, g, r, t, f, e, E) | |
549 out_dict["E_cov"] = exp_cov | |
550 out_dict["N_95"] = N_95 | |
551 out_dict["pls"] = plant_library_sizes | |
552 | |
553 end | |
554 end | |
555 end | |
556 | |
557 println(parsed_args) | |
558 println("Parsed args:") | |
559 for (key,val) in parsed_args | |
560 println(" $key => $(repr(val))") | |
561 end | |
562 println() | |
563 println("Command: ", parsed_args["%COMMAND%"]) | |
564 # h1 = histogram(grna_dict["p_gRNA_reads"], label="", | |
565 # xlabel="Number of reads per gRNA", | |
566 # linecolor="white", | |
567 # normalize=:probability, | |
568 # xtickfontsize=10,ytickfontsize=10, | |
569 # color=:mediumturquoise, size=(600,350), bins = 25, | |
570 # ylabel="Relative frequency", | |
571 # title="gRNA frequency distribution") | |
572 | |
573 # h2 = histogram(grna_dict["p_gRNA_edit"], | |
574 # normalize = :probability, | |
575 # linecolor = "white", | |
576 # label="", | |
577 # color=:turquoise4, | |
578 # xtickfontsize=10,ytickfontsize=10, xlim = (0, 1), | |
579 # xticks=(0:0.1:1), | |
580 # bins = 150, | |
581 # xlabel="gRNA editing efficiency", | |
582 # ylabel="Relative frequency", | |
583 # title="gRNA genome editing effiency distribution") | |
584 | |
585 # p_plot = plot(plant_library_sizes, Pₓ₂, label="Pₓ₂", | |
586 # title="Probability of full combinatorial coverage with respect to plant library size", | |
587 # xlabel="N", ylabel="Pₓₖ", | |
588 # xticks = (0:500:50000, string.(0:500:50000)), | |
589 # size=(900,400), color=:turquoise4, linewidth=2) | |
590 # hline!([0.95], linestyle=:dash, color=:grey, label="Pₓₖ = 0.95", legend=:bottomright) | |
591 | |
592 # exp_plot = plot(plant_library_sizes, expected_γₓ₂, | |
593 # label="E[γₓ₂]", title="Expected combinatorial coverage w.r.t. plant library size", | |
594 # xlabel="N", ylabel="E[γₓₖ]", | |
595 # xticks = (0:500:50000, string.(0:500:50000)), | |
596 # size=(800,400), color=:turquoise4, linewidth=2) | |
597 # hline!([0.95], linestyle=:dash, color=:grey, label="E[γₓₖ] = 0.95", legend=:bottomright) | |
598 | |
599 | |
600 ENV["GKSwstype"]="nul" | |
601 weave(string(@__DIR__) * "/report.jmd", | |
602 args = (parsed_args = parsed_args, | |
603 tool_info = tool_info, | |
604 args_info = args_info, | |
605 grna_dict = grna_dict, | |
606 #h1 = h1, h2 = h2, | |
607 output = out_dict); | |
608 doctype = "md2html", out_path = :pwd) | |
609 ENV["GKSwstype"]="gksqt" | |
610 end | |
611 | |
612 main(ARGS) |