fasta_lake.diagnose#
fasta_lake.diagnose
#
FastaLake diagnose — FDR calibration curves and per-sample QC.
Given a directory of SAGE entrapment searches, produces: - Calibration curve: empirical FDP vs nominal q-value, per entrapment type - Score distribution comparison: target vs decoy vs entrap - Per-sample QC: flags samples with outlier FDP
CLI: fasta-lake diagnose --results-dir PATH -o OUTPUT_DIR [--plot]
per_sample_fdp_at_q
#
per_sample_fdp_at_q(rows: list[dict], entrap_prefix: str, q_thr: float, min_length: int = 9, exclude_contaminants: bool = True) -> dict
Compute per-sample PSM- and protein-level FDP at a given q threshold.
Protein-level FDR uses the picked-protein method (Savitski 2015): for each protein, keep only the best PSM; then count target/decoy/entrap at the protein level. This is typically 2-5× tighter than PSM-level FDR.
Contaminants (CON_ prefix, or accessions in the default contaminant DB)
are excluded from both target and entrapment counts — they are neither
false positives nor true targets.
Source code in fasta_lake/diagnose.py
calibration_curve
#
calibration_curve(results_dir: Path, entrap_db_sizes: dict[str, int] | None = None, target_db_size_fn=None, min_length: int = 9) -> dict
Compute empirical FDP vs nominal q-value curve across samples.
Source code in fasta_lake/diagnose.py
97 98 99 100 101 102 103 104 105 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 | |
outlier_samples
#
outlier_samples(results_dir: Path, q_thr: float = 0.01, fdp_z_threshold: float = 2.0, min_length: int = 9) -> list[dict]
Identify samples with FDP > mean + z*std (outliers).
Source code in fasta_lake/diagnose.py
write_report
#
Write calibration JSON/CSV and outlier JSON into the requested directory.
Existing report files are overwritten. An empty calibration curve produces no new CSV file; the caller supplies the computed report dictionary.