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
use crate::{
aggregation::GeneAggregationSelection, model::ModelChoice, norm::Normalization,
utils::Adjustment,
};
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[clap(subcommand)]
pub command: Commands,
}
#[derive(Parser, Debug)]
pub struct InputArgs {
/// Filepath of the input count matrix
#[arg(short, long)]
pub input: String,
/// Labels for Control Samples
#[arg(short, long, num_args=1.., required=true)]
pub controls: Vec<String>,
/// Labels for Treatment Samples
#[arg(short, long, num_args=1.., required=true)]
pub treatments: Vec<String>,
}
#[derive(Parser, Debug)]
pub struct DiffAbundanceArgs {
/// Count normalization configuration
///
/// If high numbers of zeros are encountered the normalization
/// method will default to `total` normalization.
#[arg(short, long, default_value = "median-ratio")]
pub norm: Normalization,
/// Least squares model choice
#[arg(short, long, default_value = "wols")]
pub model_choice: ModelChoice,
/// Minimum Base Mean to consider for differential abundance
#[arg(short = 'M', long, default_value = "1")]
pub min_base_mean: f64,
}
#[derive(Parser, Debug)]
pub struct RraArgs {
/// Number of permutations to perform in aRRA
#[arg(short, long, default_value = "100")]
pub permutations: usize,
/// Alpha threshold for aRRA
#[arg(short, long, default_value = "0.25")]
pub alpha: f64,
/// Do not adjust alpha threshold for RRA.
#[arg(long)]
pub no_adjust_alpha: bool,
}
#[derive(Parser, Debug)]
pub struct IncArgs {
/// Non-targeting control token
#[arg(long, default_value = "non-targeting")]
pub ntc_token: String,
/// sgRNA group size of pseudogenes to create for INC
#[arg(short = 'G', long, default_value = "5")]
pub inc_group_size: usize,
/// Calculate FDR threshold using product-score in INC instead of the MWU p-values
#[arg(long)]
pub inc_product: bool,
/// Number of draws to use in INC algorithm
#[arg(long, default_value = "100")]
pub n_draws: usize,
}
#[derive(Parser, Debug)]
pub struct MiscArgs {
/// fdr-threshold to use in inc + rra when thresholding
#[arg(short = 'f', long, default_value = "0.1")]
pub fdr: f64,
/// Do not write logging information
#[arg(short, long)]
pub quiet: bool,
/// Multiple hypothesis correction method
#[arg(short = 'f', long, default_value = "bh")]
pub correction: Adjustment,
/// Set the seed of the run
#[arg(short, long, default_value = "42")]
pub seed: u64,
/// Number of threads to use (defaults to all available)
#[arg(short = 'T', long)]
pub threads: Option<usize>,
}
#[derive(Parser, Debug)]
pub struct SgrnaColumns {
/// Column name for the low-side p-value
#[arg(long, default_value = "pvalue_low")]
pub pvalue_low: String,
/// Column name for the high-side p-value
#[arg(long, default_value = "pvalue_high")]
pub pvalue_high: String,
/// Column name for the mean value of the base samples
#[arg(long, default_value = "control")]
pub control_mean: String,
/// Column name for the mean value of the treatment samples
#[arg(long, default_value = "treatment")]
pub treatment_mean: String,
/// Column name for the sgRNA names
#[arg(long, default_value = "sgrna")]
pub sgrna: String,
/// Column name for the gene names
#[arg(long, default_value = "gene")]
pub gene: String,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Perform a differential abundance analysis
Test {
#[clap(flatten)]
input: InputArgs,
/// Output filename prefix
///
/// sgRNA results will be written to <prefix>.sgrna_results.tsv
///
/// gene results will be written to <prefix>.gene_results.tsv
///
/// hits will be written to <prefix>.hits.tsv
#[arg(short = 'o', long, default_value = "./results")]
prefix: String,
/// Differential abundance arguments
#[clap(flatten)]
diff_args: DiffAbundanceArgs,
/// Gene aggregation configuration
#[arg(short = 'g', long, default_value = "rra")]
agg: GeneAggregationSelection,
/// RRA arguments
#[clap(flatten)]
rra: RraArgs,
/// INC arguments
#[clap(flatten)]
inc: IncArgs,
/// Misc arguments
#[clap(flatten)]
misc: MiscArgs,
/// Skip performing gene aggregation
#[clap(long)]
skip_agg: bool,
},
/// Perform just the gene aggregation given sgRNA results
Agg {
/// Filepath of the input sgRNA results
#[clap(short, long)]
input: String,
/// Output filename prefix
///
/// gene results will be written to <prefix>.gene_results.tsv
///
/// hits will be written to <prefix>.hits.tsv
#[arg(short = 'o', long, default_value = "./results")]
prefix: String,
/// Gene aggregation configuration
#[arg(short = 'g', long, default_value = "rra")]
agg: GeneAggregationSelection,
/// RRA arguments
#[clap(flatten)]
rra: RraArgs,
/// INC arguments
#[clap(flatten)]
inc: IncArgs,
/// Misc arguments
#[clap(flatten)]
misc: MiscArgs,
/// Column names for sgrna results
#[clap(flatten)]
columns: SgrnaColumns,
},
}