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
306
307
308
use crate::{
aggregation::{GeneAggregationSelection, GeoPAGGWeightConfigEnum},
enrich::TestStrategy,
model::ModelChoice,
norm::Normalization,
utils::Adjustment,
};
use clap::{
builder::{
styling::{AnsiColor, Effects},
Styles,
},
Parser, Subcommand,
};
// Configures Clap v3-style help menu colors
const STYLES: Styles = Styles::styled()
.header(AnsiColor::Green.on_default().effects(Effects::BOLD))
.usage(AnsiColor::Green.on_default().effects(Effects::BOLD))
.literal(AnsiColor::Cyan.on_default().effects(Effects::BOLD))
.placeholder(AnsiColor::Cyan.on_default());
#[derive(Parser, Debug)]
#[command(styles=STYLES)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[clap(subcommand)]
pub command: Commands,
}
#[derive(Parser, Debug)]
#[clap(next_help_heading = "Input Arguments")]
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)]
#[clap(next_help_heading = "Differential Abundance Arguments")]
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 = "100")]
pub min_base_mean: f64,
/// Sample testing strategy
#[arg(short = 'S', long, default_value = "cm")]
pub strategy: TestStrategy,
}
#[derive(Parser, Debug)]
#[clap(next_help_heading = "alpha-RRA Arguments")]
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)]
#[clap(next_help_heading = "INC Arguments")]
pub struct IncArgs {
/// 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)]
#[clap(next_help_heading = "GeoPAGG Arguments")]
pub struct GeopaggArgs {
/// Weight configuration for GeoPAGG
#[arg(long, default_value = "drop-first")]
pub weight_config: GeoPAGGWeightConfigEnum,
/// Drop-First weight configuration alpha parameter (only used if weight_config is drop-first)
#[arg(long, default_value = "0.5")]
pub df_alpha: f64,
/// Use all sgRNAs when making amalgam genes
#[arg(long)]
pub use_all: bool,
/// Calculate Empirical FDR using product-score instead of the aggregated p-values
#[arg(long)]
pub use_product: bool,
/// Set a z-score threshold for non-targeting control distribution before making amalgam genes
#[arg(long)]
pub zscore_threshold: Option<f64>,
}
#[derive(Parser, Debug)]
#[clap(next_help_heading = "Miscellaneous Arguments")]
pub struct MiscArgs {
/// fdr-threshold to use in inc + rra when thresholding
#[arg(short = 'f', long, default_value = "0.1")]
pub fdr: f64,
/// Non-targeting control token
#[arg(long, default_value = "non-targeting")]
pub ntc_token: String,
/// Do not write logging information
#[arg(short, long)]
pub quiet: bool,
/// Multiple hypothesis correction method
#[arg(short = 'C', 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)]
#[clap(next_help_heading = "sgRNA Column Name Arguments")]
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)]
#[clap(next_help_heading = "Subcommands")]
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,
/// GeoPAGG arguments
#[clap(flatten)]
geopagg: GeopaggArgs,
/// 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,
/// GeoPAGG arguments
#[clap(flatten)]
geopagg: GeopaggArgs,
/// Misc arguments
#[clap(flatten)]
misc: MiscArgs,
/// Column names for sgrna results
#[clap(flatten)]
columns: SgrnaColumns,
},
/// Resample the input count matrix with various parameterizations
Resample {
/// Filepath of the input count matrix
#[clap(short, long)]
input: String,
/// Filepath to write the resampled count matrix
///
/// [default: stdout]
#[arg(short, long)]
output: Option<String>,
/// Number of resamples to perform
#[arg(short, long)]
n_resamples: usize,
/// Sequencing Depth to use for resampling
///
/// [default: mean[original_depth]]
#[arg(short, long)]
depth: Option<usize>,
/// Samples to use for calculating mean depth
///
/// Will use the mean depth across the samples provided
#[arg(short = 'S', long, num_args=1.., conflicts_with = "depth")]
depth_samples: Option<Vec<String>>,
/// Seed to use for resampling
#[arg(long, default_value = "42")]
seed: u64,
/// Sample names whose data should be resampled
#[arg(short, long, num_args=1.., required = true)]
samples: Vec<String>,
/// Quiet the logger
#[arg(short, long)]
quiet: bool,
},
}