Skip to main content

Module qc_lib

Module qc_lib 

Source
Expand description

Cell-axis quality control (library-only): robust (MAD) outlier detection plus the near-empty floor. Built on the streaming stat collectors in the sibling qc module and consumed by senna / pinto — NOT by the data-beans CLI — so it lives in its own module that the binary never compiles (keeps qc fully bin-used and avoids dead-code in the bin target).

Structs§

QcArgs
Clap surface for cell QC, shared by senna and pinto subcommands.
QcConfig
Configuration for cell QC. Plain struct (no clap) so non-clap crates can construct it directly; the clap surface is QcArgs.
QcReport
Per-cell / per-feature QC outcome.

Enums§

Tail
Which side(s) of the robust band count as outliers.

Functions§

compute_qc
Compute the two-tier cell-QC report. block_size controls the streaming stat passes (None = default chunking).
compute_qc_exempting
compute_qc with columns that are not cells exempted — a prior run’s carried pseudobulks. exempt[c] = true keeps column c out of all band statistics and out of every verdict. See qc_from_metrics.
compute_qc_stack
Modality-agnostic cell QC for a SparseIoStack: per-cell n_genes / total_counts are summed across all member modalities (mirrors senna gem’s “a cell rich in any one modality is kept”). Mito/ribo and feature-axis QC are skipped on stacks (row names are per-modality).
filter_by_keep
Filter a per-cell Vec<T> in lockstep with a cell keep-mask. Used to keep batch labels / coordinates aligned after mask_columns.
resolve_rows_by_regex
Resolve a regex over row (feature) names into matching row indices, in the same compact-row order as SparseIoVec::row_names(). Feeds collect_column_stat_across_vec(.., Some(&rows), ..) for subset sums.
robust_outlier_keep
Robust outlier keep-mask: keep[i] = false when values[i] falls outside median ± n_mads · MAD · 1.4826 on the requested tail. Count-like metrics should pass log1p = true so the band is symmetric on the multiplicative scale. Consolidates the median+MAD idiom used in cnv::hmm. consider (when Some) restricts the median/MAD band to the cells it marks true — so e.g. near-empty cells don’t contaminate the robust center — while the keep decision is still returned for every cell.
write_qc_report
Write a per-cell QC table (TSV): name, n_genes, total_counts, [mito_frac], [ribo_frac], near_empty (0/1), train_keep (0/1).