Convenient function to calculate standard QC metrics with mitochondrial genes. This is a simplified interface for the most common QC analysis in single-cell studies. It automatically identifies mitochondrial genes and computes standard QC metrics. ## What it does 1. **Identifies mitochondrial genes**: Finds genes starting with "MT-" or "mt-" 2. **Adds mito annotation**: Creates boolean column i
(adata: &IMAnnData)
| 446 | /// If your data uses different naming conventions, use `calculate_qc_metrics` directly |
| 447 | /// with custom gene sets. |
| 448 | pub fn qc_metrics(adata: &IMAnnData) -> anyhow::Result<()> { |
| 449 | let var_names = adata.var_names(); |
| 450 | let mito_mask: Vec<bool> = var_names |
| 451 | .iter() |
| 452 | .map(|name| name.starts_with("MT-") || name.starts_with("mt-")) |
| 453 | .collect(); |
| 454 | |
| 455 | let mut var_df = adata.var().get_data(); |
| 456 | var_df.with_column(Column::new("mito".into(), mito_mask))?; |
| 457 | adata.var().set_data(var_df)?; |
| 458 | |
| 459 | calculate_qc_metrics( |
| 460 | adata, |
| 461 | Some("counts"), |
| 462 | Some("genes"), |
| 463 | Some(vec!["mito"]), |
| 464 | Some(vec![50, 100, 200, 500]), |
| 465 | None, |
| 466 | false, |
| 467 | true, |
| 468 | true, |
| 469 | )?; |
| 470 | |
| 471 | Ok(()) |
| 472 | } |
nothing calls this directly
no test coverage detected