fasta_lake.aggregate#
fasta_lake.aggregate
#
Cross-sample aggregation for FastaLake search results.
Wraps the Rust aggregation_engine for dual-index (peptide + protein group) aggregation, and provides Python utilities for cross-sample comparison, quantification matrices, and cohort-level statistics.
The Rust aggregation_engine handles: - Peptide-level aggregation with protein group normalization - Source tag stripping (REF|, SAMPLE|REF|) - Protein group classification (human, microbial, mixed) - Dual-index output (both peptide and protein group level)
This Python module adds: - Multi-sample loading and merging - Quantification matrix construction - Cross-sample statistics (CV, missing values, overlap) - Comparison with canonical baseline (via benchmark.py)
SampleResult
dataclass
#
Parsed search result for one sample.
Source code in fasta_lake/aggregate.py
load_diann_sample
#
load_diann_sample(report_path: str | Path, sample_id: str | None = None, qvalue: float = 0.01) -> SampleResult
Load a single-sample DIA-NN report.
Source code in fasta_lake/aggregate.py
build_quant_matrix
#
build_quant_matrix(samples: list[SampleResult], level: str = 'gene') -> tuple[list[str], list[str], list[list[float]]]
Build a quantification matrix across samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
list of SampleResult
|
|
required |
level
|
'gene', 'peptide', or 'protein_group'
|
|
'gene'
|
Returns:
| Type | Description |
|---|---|
(sample_ids, feature_ids, matrix)
|
|
Source code in fasta_lake/aggregate.py
compute_cross_sample_stats
#
compute_cross_sample_stats(samples: list[SampleResult], level: str = 'gene') -> dict
Compute cross-sample statistics.
Returns dict with: - n_samples, n_features - completeness: % of matrix cells that are non-zero - per_feature_cv: coefficient of variation for each feature (across samples where present) - median_cv: median CV across all features - features_in_all: features found in every sample - features_in_one: features found in only one sample
Source code in fasta_lake/aggregate.py
run_rust_aggregation
#
run_rust_aggregation(input_tsv: str | Path, output_dir: str | Path, dataset: str, data_type: str = 'lfq', threads: int = 1, binary: str | None = None) -> Path
Run the Rust aggregation_engine binary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_tsv
|
path
|
Input search result TSV (DIA-NN or SAGE format). |
required |
output_dir
|
path
|
Output directory for aggregated results. |
required |
dataset
|
str
|
Dataset name for labeling. |
required |
data_type
|
str
|
'lfq' (DIA-NN) or 'psm' (SAGE). |
'lfq'
|
threads
|
int
|
Number of threads. |
1
|
binary
|
str
|
Path to aggregation_engine binary. Auto-detected if None. |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Output directory. |
Source code in fasta_lake/aggregate.py
print_cohort_summary
#
print_cohort_summary(samples: list[SampleResult]) -> None
Print a summary table of all samples.