Refactor siblings module and enhance sampling logic
Introduces filtering for scan families, handles genome exclusion arguments, refactors the `siblings` module architecture, and clarifies invariants for statistical calculations.
This commit is contained in:
1 parent
996ebaf977
commit
fdfc1eb3dd
27 files changed
+106
-4383
No files matched your search
@@ -35,8 +35,9 @@ fn parse_gamma_shape(s: &str) -> Result<GammaShapeArg, String> {
|
||||
/// `--distance` value — either one of `obikphylo::DistanceMetric`'s
|
||||
/// whole-index metrics (routed to `IndexCache::distance`) or one of
|
||||
/// `obikphylo::SnpDistanceKind`'s `snp-*` corrections (routed to
|
||||
/// `SiblingExt::snp_distance`, the sibling-annex pipeline) — two genuinely
|
||||
/// different code paths behind one CLI vocabulary, see
|
||||
/// `obikphylo::siblings::distance_matrix`, over a tally built by
|
||||
/// `sampled_scan`/`PairwiseReducer`, the sibling-annex pipeline) — two
|
||||
/// genuinely different code paths behind one CLI vocabulary, see
|
||||
/// `DevDocMD/theory/evolutionary_distances.md`, "`--distance` unification".
|
||||
#[derive(clap::ValueEnum, Clone, Copy, Debug)]
|
||||
pub enum DistanceArg {
|
||||
@@ -121,10 +122,10 @@ pub struct PhyloArgs {
|
||||
/// Exclude a genome (by its exact label) — from `--pseudo-alignment`'s
|
||||
/// sampling (a family whose only polymorphism lived in an excluded
|
||||
/// genome is discarded during sampling, not filtered afterward — see
|
||||
/// `obikphylo::siblings::extensions::SiblingExt::snp_pseudo_alignment`'s
|
||||
/// own docs) and from the distance matrix / shared-kmer matrix CSV
|
||||
/// output (row and column both dropped; the underlying computation
|
||||
/// itself is unaffected). Repeatable.
|
||||
/// `obikphylo::siblings::sampled_scan`'s own docs) and from the
|
||||
/// distance matrix / shared-kmer matrix CSV output (row and column
|
||||
/// both dropped; the underlying computation itself is unaffected).
|
||||
/// Repeatable.
|
||||
#[arg(long = "exclude-genome", value_name = "LABEL")]
|
||||
pub exclude_genome: Vec<String>,
|
||||
|
||||
@@ -194,10 +195,9 @@ pub struct PhyloArgs {
|
||||
/// `--pseudo-alignment`/`--sankoff` (mandatory for both) and for a
|
||||
/// `snp-*` `--distance` value (optional there: omitted means exhaustive
|
||||
/// — every non-monomorphic minorant of the whole index, not an
|
||||
/// approximation, see `obikphylo::siblings::SiblingExt::snp_distance`'s
|
||||
/// own docs) — a target, not a guarantee when given (proportional
|
||||
/// per-layer sampling; see
|
||||
/// `obikphylo::siblings::SiblingExt::snp_pseudo_alignment`'s own docs).
|
||||
/// approximation) — a target, not a guarantee when given (proportional
|
||||
/// per-layer sampling; see `obikphylo::siblings::sampled_scan`'s own
|
||||
/// docs).
|
||||
#[arg(long)]
|
||||
pub subsample: Option<usize>,
|
||||
|
||||
@@ -329,7 +329,8 @@ pub struct PhyloArgs {
|
||||
/// the central-position SNP substitution spectrum (`snp-raw`, `snp-jc`,
|
||||
/// `snp-k2p`, `snp-k81`, `snp-f81`, `snp-t92`, `snp-tn93`, `snp-tv`) —
|
||||
/// the latter route to a different computation entirely
|
||||
/// (`SiblingExt::snp_distance`, requires `--sibling-annex` first; see
|
||||
/// (`obikphylo::siblings::sampled_scan` + `distance_matrix`, requires
|
||||
/// `--sibling-annex` first; see
|
||||
/// `DevDocMD/theory/evolutionary_distances.md`, "`--distance`
|
||||
/// unification" for the full catalog and why LogDet/Tajima-Nei/F84/
|
||||
/// HKY85 aren't offered yet).
|
||||
|
||||
@@ -45,10 +45,10 @@ pub fn run(args: PhyloArgs) {
|
||||
let n = labels.len();
|
||||
|
||||
// ── Genome exclusion (`--exclude-genome`) ───────────────────────────────────
|
||||
// Resolved once, up front: `snp_pseudo_alignment` needs it baked into
|
||||
// sampling itself (see its own docs), and the distance/shared-kmer CSV
|
||||
// writers below just skip these rows/columns at write time — the
|
||||
// underlying `cache.distance(...)` computation is unaffected either way.
|
||||
// Resolved once, up front: `sampled_scan` needs it baked into sampling
|
||||
// itself (see its own docs), and the distance/shared-kmer CSV writers
|
||||
// below just skip these rows/columns at write time — the underlying
|
||||
// `cache.distance(...)` computation is unaffected either way.
|
||||
let exclude_mask: Vec<bool> = {
|
||||
let mut mask = vec![false; n];
|
||||
for label in &args.exclude_genome {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Output writers for `--sankoff` — no calibration logic here, just
|
||||
//! formatting: `obikphylo::siblings::SiblingExt::sankoff_bundle` and the
|
||||
//! formatting: `obikphylo::siblings::SankoffBundle::finish` and the
|
||||
//! `cardinality_transition_probs`/`composition_transition_probs`/
|
||||
//! `pairwise_cost_matrix` calibration functions do all the actual work in
|
||||
//! `mod.rs`, this module only serialises their results.
|
||||
@@ -13,8 +13,8 @@ use tracing::info;
|
||||
|
||||
// ── Sankoff pseudo-alignment → FASTA ────────────────────────────────────────
|
||||
//
|
||||
// Same data as `--pseudo-alignment`'s output (`SnpAlignment`/
|
||||
// `snp_pseudo_alignment`), re-coded so its symbols match the accompanying
|
||||
// Same data as `--pseudo-alignment`'s own output (`SnpAlignment`, built by
|
||||
// `AlignmentReducer`), re-coded so its symbols match the accompanying
|
||||
// `--sankoff` matrix output exactly: `0` for the empty/absent state instead
|
||||
// of `-`, which TNT/PhyG would otherwise read as their own gap character
|
||||
// rather than our "family absent" state. Unless `free_loss` (`--free-loss`)
|
||||
|
||||
Reference in new issue
Block a user