-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBarcodeDenoiser.jl
89 lines (67 loc) · 2.05 KB
/
BarcodeDenoiser.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
# BarcodeDenoiser.jl
"""
Statistically denoise barcode sequencing data.
"""
using Pkg
Pkg.activate(joinpath(@__DIR__, ".."))
Pkg.instantiate()
module BarcodeDenoiser
include("trim.jl")
include("index.jl")
include("compute.jl")
include("graph.jl")
include("utils.jl")
using ArgParse
using YAML
using Logging
function parse_cmd()
s = ArgParseSettings()
@add_arg_table s begin
"--input"
help = "Input sequencing file (FASTQ)."
arg_type = String
"--config"
help = "Config file (YAML)."
arg_type = String
"--output"
help = "Output file (PNG)."
arg_type = String
end
return parse_args(s)
end
function denoise_data(file, config, out::String)
"""
Denoise barcode sequencing data.
"""
settings = YAML.load_file(config)
@info "Read settings from $config"
trim.check_format(file)
@info "Checked format of $file."
io = open(file, "r")
V = trim.get_sequences(io)
@info "Read sequences from $file."
l, r, L, b = settings["left"], settings["right"], settings["L"], settings["b"]
V = [trim.trim_sequence(v, l, r, L) for v in V]
# Filter untrimmed sequences and sequences of incorrect length
V = String[v for v in V if v!==nothing]
@info "Trimmed sequences between '$l' and '$r'."
k = settings["k"]
A = trim.generate_windows(V, k)
@info "Generated $k-mer windows."
q = settings["q"]
W = index.index_diversity(A, q)
@info "Indexed diversity using the Hill number of order $q."
N = compute.compute_noise(W, b, k)
@info "Noise = $N."
S = compute.compute_apparent_diversity(W, b)
@info "Apparent barcode diversity = $S"
T = compute.compute_true_diversity(N, S)
@info "True barcode diversity estimated at $T."
graph.plot_diversity(W, out)
@info "Plot diversity and saved to $out."
@info "Completed successfully for $file."
end
args = parse_cmd()
file, config, out = args["input"], args["config"], args["output"]
denoise_data(file, config, out)
end