fasta_lake.complexity#
fasta_lake.complexity
#
Sample complexity estimation from de novo peptide results.
Maps de novo peptides to a reference database to estimate sample complexity BEFORE building the per-sample database. Reports metrics that help choose optimal inference parameters.
Metrics
- hit_rate: Fraction of de novo peptides matching the reference DB. High hit rate (>0.3) = well-characterized sample, low (<0.1) = novel organisms.
- species_richness: Number of distinct species/organisms detected. 1 = single-species, >100 = complex metaproteomics.
- peptide_diversity: Mean unique peptides per protein with evidence. High diversity = good coverage, low = sparse evidence.
- db_coverage: Fraction of DB proteins with any peptide evidence. Indicates how much of the DB is relevant to this sample.
Recommendations
Based on detected complexity, the module can auto-recommend:
- Single-species (richness=1):
razorstrategy - Low complexity (<10 species):
razororuniform_2pep - High complexity (>10 species):
species_budget - Very high complexity (>100 species):
species_budgetwith clustering
ComplexityReport
dataclass
#
Sample complexity estimation report.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hit_rate
|
float
|
Fraction of input peptides that matched the reference DB (0-1). |
0.0
|
species_richness
|
int
|
Number of distinct species/organisms detected. |
0
|
peptide_diversity
|
float
|
Mean unique peptides per protein with evidence. |
0.0
|
db_coverage
|
float
|
Fraction of DB proteins with any peptide evidence (0-1). |
0.0
|
total_peptides
|
int
|
Total input peptides analyzed. |
0
|
matched_peptides
|
int
|
Peptides that matched at least one protein. |
0
|
proteins_with_evidence
|
int
|
Proteins with at least one peptide match. |
0
|
species_counts
|
dict[str, int]
|
Proteins per species (species_id -> count). |
dict()
|
recommendation
|
str
|
Auto-recommended inference strategy. |
''
|
recommendation_reason
|
str
|
Explanation for the recommendation. |
''
|
Source code in fasta_lake/complexity.py
summary
#
Return summary dict for JSON stats output.
Source code in fasta_lake/complexity.py
estimate_complexity
#
estimate_complexity(proteins: dict[str, str], peptides: dict[str, float] | set[str], config: ComplexityConfig | None = None) -> ComplexityReport
Estimate sample complexity by mapping peptides to a reference database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proteins
|
dict[str, str]
|
Reference database proteins (protein_id -> sequence). |
required |
peptides
|
dict[str, float] or set[str]
|
De novo peptides (I/L-normalized). If dict, values are scores. |
required |
config
|
ComplexityConfig or None
|
Configuration. If None, uses defaults. |
None
|
Returns:
| Type | Description |
|---|---|
ComplexityReport
|
Complexity metrics and optional strategy recommendation. |
Source code in fasta_lake/complexity.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |