Two cases, decided per panel and marker by how many samples placed their cut
at a density minimum (valley_*, otsu):
Arguments
- thr
Data frame with
sample_id,panel,marker,threshold,source, one row per sample and marker.- z_max
Robust z beyond which a tail cut is replaced when the marker has no majority of density minima.
- min_peers
Minimum number of reference cuts.
- min_peer_frac
Minimum share of the panel's samples the reference must cover.
Value
A data frame of replacements (sample_id, panel, marker,
old_threshold, old_source, threshold, n_peers, robust_z,
reason), or NULL when nothing is replaced.
Details
At least
min_peersand at leastmin_peer_fracof the samples did. The marker is then bimodal in this assay, and a sample without a minimum – aquantile_fallbackor atailgate*cut – takes the median of the minima. On the KMT2C/KMT2D cohort one sample's CD19 tail cut at 3.24, against minima between 2.28 and 2.50 elsewhere, counted 0.9% B cells where manual gating counted 5.7%.Fewer did. The other samples' cuts, fallbacks excluded, are the reference: a fallback takes their median, and a tail cut more than
z_maxrobust SDs from them (MAD floored at 0.25, as forscale_outlier) does too.
Cuts from a control, a config entry or a manual override are never touched.
