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.
QcMetrics
Pre-computed per-cell / per-feature metrics fed to cell_verdicts. Lets the single-modality and stacked QC paths share one decision rule.
QcReport
Per-cell / per-feature QC outcome.
RobustBand
The robust band robust_outlier_keep tests against: median ± n_mads · MAD · 1.4826, on the log1p scale when asked.
Verdicts
What cell_verdicts decides: the cells kept in training, the near-empty ones, and the features kept.

Enums§

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

Functions§

cell_verdicts
The two-tier QC decision (near-empty floor + MAD outliers) on m under cfg, printing nothing: what compute_qc decides, for a view that decides again as its settings change. exempt as in compute_qc_exempting.
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_metrics
The per-cell (and, with feature_cells, per-feature) metrics QC decides on, measured once: detected features and total counts per cell, the mito and ribo fractions where cfg names their patterns, and how many cells detect each feature. cell_verdicts decides on them under any config with those patterns, without reading the data again.
compute_qc_stack
Modality-agnostic cell QC for a SparseIoStack: per-cell n_genes / total_counts are summed across all member modalities (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.
qc_report
The QcReport of metrics measured once (compute_qc_metrics), as compute_qc makes it: the histogram printed when cfg asks.
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_band
RobustBand of values (the considered ones, when given); None when none is finite, or when they have no spread (a MAD of 0).
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).