Add per-family Shannon entropy calculation and reporting
Introduces an entropy.pent persisted format and algorithms to compute per-family Shannon entropy across genomic partitions. Refactors IndexCache to use Arc-based layer sharing for efficient iteration and restructures the siblings module with extension traits for annex generation. Adds a --shannon CLI flag to export partition-level entropy metrics to CSV.
This commit is contained in:
1 parent
bbb58a698f
commit
5a0b71d105
14 files changed
+762
-136
No files matched your search
@@ -51,6 +51,13 @@ pub struct PhyloArgs {
|
||||
#[arg(long)]
|
||||
pub sibling_annex: bool,
|
||||
|
||||
/// Write a per-family Shannon entropy report (CSV) — requires an
|
||||
/// already-built sibling annex (`--sibling-annex` first, in this
|
||||
/// invocation or an earlier one). Full, unsampled scan of every family;
|
||||
/// no `--subsample`/`--entropy-bias` yet.
|
||||
#[arg(long)]
|
||||
pub shannon: bool,
|
||||
|
||||
/// Distance metric to compute
|
||||
#[arg(long, value_enum, default_value = "jaccard")]
|
||||
pub metric: MetricArg,
|
||||
|
||||
@@ -58,6 +58,21 @@ pub fn run(args: PhyloArgs) {
|
||||
rep.push(t.stop());
|
||||
}
|
||||
|
||||
// ── Shannon entropy report (`--shannon`) ────────────────────────────────────
|
||||
if args.shannon {
|
||||
let path = args.output.as_ref()
|
||||
.map(|p| format!("{}_entropy.csv", p.display()))
|
||||
.unwrap_or_else(|| "entropy.csv".into());
|
||||
info!("computing per-family Shannon entropy");
|
||||
let t = Stage::start("shannon_entropy");
|
||||
cache.shannon_entropy_csv(std::path::Path::new(&path)).unwrap_or_else(|e| {
|
||||
eprintln!("error computing Shannon entropy: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
rep.push(t.stop());
|
||||
info!("entropy report → {path}");
|
||||
}
|
||||
|
||||
info!("computing {:?} distances for {} genome(s)", args.metric, n);
|
||||
|
||||
let need_shared = args.shared_kmers || args.nj || args.upgma;
|
||||
|
||||
Reference in new issue
Block a user