(
adata: &IMAnnData,
groupby: &str,
reference: Option<&str>,
groups: Option<&[&str]>,
method: Option<TestMethod>,
n_genes: Option<usize>,
correction_method: CorrectionMetho
| 241 | |
| 242 | #[allow(clippy::too_many_arguments)] |
| 243 | pub fn rank_gene_groups_dataframe( |
| 244 | adata: &IMAnnData, |
| 245 | groupby: &str, |
| 246 | reference: Option<&str>, |
| 247 | groups: Option<&[&str]>, |
| 248 | method: Option<TestMethod>, |
| 249 | n_genes: Option<usize>, |
| 250 | correction_method: CorrectionMethod, |
| 251 | compute_logfoldchanges: Option<bool>, |
| 252 | pseudocount: Option<f64>, |
| 253 | ) -> anyhow::Result<DataFrame> { |
| 254 | let method = method.unwrap_or(TestMethod::TTest(TTestType::Welch)); |
| 255 | let compute_lfc = compute_logfoldchanges.unwrap_or(true); |
| 256 | let pseudocount = pseudocount.unwrap_or(1.0); |
| 257 | let n_genes = n_genes.unwrap_or(adata.n_vars()); |
| 258 | |
| 259 | let computation = compute_rank_gene_groups( |
| 260 | adata, |
| 261 | groupby, |
| 262 | reference, |
| 263 | groups, |
| 264 | method, |
| 265 | n_genes, |
| 266 | correction_method, |
| 267 | compute_lfc, |
| 268 | pseudocount, |
| 269 | )?; |
| 270 | |
| 271 | let RankGeneGroupsComputed { |
| 272 | groups: groups_to_test, |
| 273 | results, |
| 274 | reference, |
| 275 | } = computation; |
| 276 | |
| 277 | let DifferentialExpressionResults { |
| 278 | mut scores, |
| 279 | mut pvals, |
| 280 | mut pvals_adj, |
| 281 | mut logfoldchanges, |
| 282 | mut gene_names, |
| 283 | } = results; |
| 284 | |
| 285 | let mut group_column: Vec<String> = Vec::new(); |
| 286 | let mut reference_column: Vec<String> = Vec::new(); |
| 287 | let mut gene_column: Vec<String> = Vec::new(); |
| 288 | let mut score_column: Vec<f64> = Vec::new(); |
| 289 | let mut pval_column: Vec<f64> = Vec::new(); |
| 290 | let mut pval_adj_column: Vec<f64> = Vec::new(); |
| 291 | let mut logfc_column: Vec<f64> = Vec::new(); |
| 292 | |
| 293 | let reference_label = reference.as_deref().unwrap_or("rest"); |
| 294 | |
| 295 | for group in &groups_to_test { |
| 296 | let group_scores = scores |
| 297 | .remove(group) |
| 298 | .ok_or_else(|| anyhow::anyhow!("Missing score vector for group '{}'", group))?; |
| 299 | let group_pvals = pvals |
| 300 | .remove(group) |
nothing calls this directly
no test coverage detected