afquery 0.4.2__tar.gz → 0.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {afquery-0.4.2 → afquery-0.5.0}/PKG-INFO +1 -1
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/coverage-evidence.md +8 -4
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/debugging-results.md +1 -1
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/ploidy-and-sex-chroms.md +2 -2
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/preprocessing.md +10 -2
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/understanding-output.md +15 -2
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/annotate-vcf.md +1 -1
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/query.md +5 -2
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/variant-info.md +8 -11
- {afquery-0.4.2 → afquery-0.5.0}/docs/reference/python-api.md +4 -1
- {afquery-0.4.2 → afquery-0.5.0}/resources/normalize_vcf.sh +12 -1
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/_version.py +2 -2
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/annotate.py +24 -34
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/dump.py +25 -69
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/query.py +155 -97
- {afquery-0.4.2 → afquery-0.5.0}/tests/oracle.py +13 -1
- afquery-0.5.0/tests/test_multiallelic.py +153 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_oracle_consistency.py +59 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_variant_info.py +106 -0
- {afquery-0.4.2 → afquery-0.5.0}/.dockerignore +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/.github/workflows/ci.yml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/.github/workflows/docs.yml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/.github/workflows/release.yml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/.gitignore +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/CONTRIBUTING.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/Dockerfile +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/LICENSE +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/README.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/.gitignore +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/INSTALL.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/README.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/Snakefile +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/.gitignore +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/01a_assign_samples.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/01b_write_manifests.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/02_build_databases.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/03_compute_metrics.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/04_classify_acmg.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/05_plot_figures.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/README.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/Snakefile +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/__init__.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/beds/SureSelect_v5.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/beds/SureSelect_v6.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/beds/SureSelect_v7.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/capture_kit/config.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/config.yaml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/envs/benchmark.yaml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/.gitignore +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/01_prepare_data.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/02_query_scaling.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/03_build.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/04_annotate.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/05_vs_bcftools.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/06_plot.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/README.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/Snakefile +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/collect_annotate.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/collect_bcftools.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/collect_build_perf.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/collect_prepare.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/collect_query_scaling.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/config.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/performance/config_smoke.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/shared/__init__.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/shared/config.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/shared/rules/download_1kg.smk +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/benchmarks/shared/utils.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/benchmarking.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/filter-pass-tracking.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/multi-cohort-strategies.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/performance.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/advanced/pipeline-integration.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/assets/img/gap2_mixed_technologies.png +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/faq.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/concepts.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/installation.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/motivation.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/quickstart.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/getting-started/tutorial.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/create-database.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/dump-export.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/manifest-format.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/sample-filtering.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/guides/update-database.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/index.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/reference/cli.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/reference/data-model.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/reference/glossary.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/scripts/gen_gap2_figure.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/stylesheets/extra.css +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/troubleshooting.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/acmg-use-cases.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/clinical-prioritization.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/cohort-stratification.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/population-specific-af.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/pseudo-controls.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/sex-specific-af.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/docs/use-cases/technology-integration.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/examples/demo/README.md +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/examples/demo/create_demo_data.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/mkdocs.yml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/pyproject.toml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/recipes/afquery/meta.yaml +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/__init__.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/benchmark.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/bitmaps.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/capture.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/cli.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/cli.pyr +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/constants.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/database.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/models.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/ploidy.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/__init__.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/build.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/compact.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/ingest.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/manifest.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/regions.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/synth.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/preprocess/update.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/storage.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/src/afquery/variant_info.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/conftest.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/annotate_input.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/annotate_multi_bucket.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/annotate_multi_chrom.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/beds/wes_kit_a.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/beds/wes_kit_b.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/beds/wes_kit_nochr.bed +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/expected_results.json +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/manifest.tsv +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S00.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S01.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S02.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S03.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S04.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S05.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S06.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S07.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S08.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/data/vcfs/S09.vcf +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_annotate.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_batch.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_benchmark.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_bitmaps.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_capture.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_cli.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_cli_docs_consistency.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_compact.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_constants.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_dump.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_haploid_stats.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_info.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_invariants.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_no_coverage.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_pass_filter.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_ploidy.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_preprocess.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_query.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_sample_filter.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_storage.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_synth.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_synthetic_stats.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_update.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_update_metadata.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_update_partitioned.py +0 -0
- {afquery-0.4.2 → afquery-0.5.0}/tests/test_warnings.py +0 -0
|
@@ -17,12 +17,16 @@ into `N_HOM_REF`. The flags below decide *which* samples land there.
|
|
|
17
17
|
## What `N_NO_COVERAGE` represents
|
|
18
18
|
|
|
19
19
|
`N_NO_COVERAGE` counts eligible samples whose hom-ref status is not trusted
|
|
20
|
-
under the active criteria.
|
|
20
|
+
under the active criteria. At a biallelic site the genotype invariant becomes:
|
|
21
21
|
|
|
22
22
|
```
|
|
23
23
|
N_HET + N_HOM_ALT + N_HOM_REF + N_FAIL + N_NO_COVERAGE = n_eligible
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
At a multi-allelic site, eligible samples that carry only another ALT allele at
|
|
27
|
+
the position fall in none of these categories for this allele, so the sum is
|
|
28
|
+
lower than `n_eligible` by exactly that number of samples.
|
|
29
|
+
|
|
26
30
|
Samples in `N_NO_COVERAGE` remain in `eligible` and contribute to `AN` (just
|
|
27
31
|
like `N_FAIL`), so AC/AN/AF stay conservative — the field never inflates
|
|
28
32
|
allele frequencies. Two rules always hold:
|
|
@@ -45,7 +49,7 @@ position. They run at query time, so no database rebuild is needed.
|
|
|
45
49
|
|
|
46
50
|
| Flag | Effect |
|
|
47
51
|
|------|--------|
|
|
48
|
-
| `--min-pass K` | A partially-covered tech must have ≥K PASS carriers (`het ∪ hom`) at the position. If it falls short, all of its non-carrier samples move from `N_HOM_REF` to `N_NO_COVERAGE`. |
|
|
52
|
+
| `--min-pass K` | A partially-covered tech must have ≥K PASS carriers (`het ∪ hom`) at the position. Carriers of any ALT allele there count, since each shows the position was sequenced. If it falls short, all of its non-carrier samples move from `N_HOM_REF` to `N_NO_COVERAGE`. |
|
|
49
53
|
| `--min-observed K` | Same shape, but counts every recorded carrier (`het ∪ hom ∪ fail`). Useful when a non-PASS call still proves the position was sequenced. |
|
|
50
54
|
|
|
51
55
|
When both flags are >0, both must hold (AND). The default `0` disables the
|
|
@@ -98,7 +102,7 @@ coverage decision is baked in.
|
|
|
98
102
|
| `--min-dp D` | Minimum `FORMAT/DP` per carrier. |
|
|
99
103
|
| `--min-gq G` | Minimum `FORMAT/GQ` per carrier. |
|
|
100
104
|
| `--min-qual Q` | Minimum VCF `QUAL` per carrier. |
|
|
101
|
-
| `--min-covered K`| Per partially-covered tech, the position is "trusted" only if at least K of its carriers pass the quality thresholds. Non-carriers of failing positions are recorded as `N_NO_COVERAGE`. |
|
|
105
|
+
| `--min-covered K`| Per partially-covered tech, the position is "trusted" only if at least K of its carriers pass the quality thresholds. Non-carriers of failing positions are recorded as `N_NO_COVERAGE`. The gate is evaluated at build time for each ALT allele separately; samples carrying another allele at the position are never counted as `N_NO_COVERAGE`. |
|
|
102
106
|
|
|
103
107
|
A carrier counts as quality-passing only if **all** active thresholds hold
|
|
104
108
|
(unset thresholds are simply ignored). At least one of these flags must be
|
|
@@ -133,7 +137,7 @@ afquery query --db ./db/ --locus chr1:925952 --min-quality-evidence 5
|
|
|
133
137
|
```
|
|
134
138
|
|
|
135
139
|
`--min-quality-evidence K` requires each partially-covered tech to have ≥K
|
|
136
|
-
quality-passing carriers at the position. Non-carriers of failing techs
|
|
140
|
+
quality-passing carriers of any ALT allele at the position. Non-carriers of failing techs
|
|
137
141
|
(other than those already filtered at build time) move to `N_NO_COVERAGE`.
|
|
138
142
|
|
|
139
143
|
Running the flag against a database that was not built with quality data
|
|
@@ -16,7 +16,7 @@ AN=0 means no eligible samples at the queried position. Work through these check
|
|
|
16
16
|
| Position exists in database | `afquery query --db ./db/ --locus chr1:12345678` | If no result at all, the variant was not observed in any sample during ingestion. |
|
|
17
17
|
| BED coverage (WES) | `afquery info --db ./db/` | If all eligible samples are WES and the position is outside capture regions, AN=0 is correct. |
|
|
18
18
|
| Sample filter too restrictive | Remove `--phenotype` and `--sex` filters | Query with no filters first. If AN>0 without filters, the filter is excluding all samples. |
|
|
19
|
-
| WES samples missing from AN |
|
|
19
|
+
| WES samples missing from AN | `afquery query --db ./db/ --locus chr1:12345678 --tech WES_kit_A` | If this prints `No variants found for the given filters.` for a technology whose kit should cover the position, while the unfiltered query returns the variant, that technology's capture index is not matching the position. `afquery` warns on open when a capture BED is empty or matches no known chromosome, naming the offending contigs. |
|
|
20
20
|
| AN=0 only on chrM | `afquery query --db ./db/ --locus chrM:3243` | Mitochondrial coverage is easy to lose on its own: a BED naming it `chrMT` still matches on the autosomes, so nothing else looks wrong. Names are normalized (`MT`, `M`, `chrMT` → `chrM`) since v0.4.0 — databases built before that may need the capture BED re-checked. |
|
|
21
21
|
| Technology filter | Remove `--tech` filter | Check if any samples match the requested technology. |
|
|
22
22
|
|
|
@@ -103,11 +103,11 @@ afquery query --db ./db/ --locus chrM:3243
|
|
|
103
103
|
|
|
104
104
|
### Counting Identity
|
|
105
105
|
|
|
106
|
-
For every query result, the following identity holds:
|
|
106
|
+
For every query result at a biallelic site, the following identity holds:
|
|
107
107
|
|
|
108
108
|
**N_HET + N_HOM_ALT + N_HOM_REF + N_FAIL + N_NO_COVERAGE = n_eligible**
|
|
109
109
|
|
|
110
|
-
This can be used to validate results. N_HOM_REF is the number of eligible samples that are homozygous reference (i.e.,
|
|
110
|
+
This can be used to validate results. At a multi-allelic site, eligible samples that carry only another ALT allele at the position fall in none of these categories, so the sum is lower by exactly that number of samples (see [Multi-allelic sites](../getting-started/understanding-output.md#multi-allelic-sites)). N_HOM_REF is the number of eligible samples that are homozygous reference (i.e., carry no ALT allele at the position and passed quality filters). N_NO_COVERAGE is 0 unless a coverage-evidence filter is active — see [Coverage Evidence](coverage-evidence.md).
|
|
111
111
|
|
|
112
112
|
!!! note "Mutual exclusivity"
|
|
113
113
|
N_HET, N_HOM_ALT, N_HOM_REF, N_FAIL, and N_NO_COVERAGE are mutually exclusive. A sample with a non-ref allele but FILTER≠PASS is counted in N_FAIL only — it does not appear in N_HET or N_HOM_ALT. Likewise, N_HOM_REF counts only PASS-filtered samples.
|
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
AFQuery ingests single-sample, normalized VCF files. While AFQuery itself does not perform VCF normalization, the accuracy of your allele frequency estimates depends on the quality and consistency of your input VCFs. This page explains why normalization matters and provides a reference pipeline.
|
|
4
4
|
|
|
5
|
-
A ready-to-use normalization script is provided at [`resources/normalize_vcf.sh`](https://github.com/babelomics/afquery/blob/master/resources/normalize_vcf.sh).
|
|
5
|
+
A ready-to-use normalization script is provided at [`resources/normalize_vcf.sh`](https://github.com/babelomics/afquery/blob/master/resources/normalize_vcf.sh). It requires **bcftools 1.20 or later**: older releases refuse to split multi-allelic records and remove duplicates in the same `bcftools norm` call, and the script exits with an error if it finds one.
|
|
6
|
+
|
|
7
|
+
!!! warning "VCFs normalized with the script from afquery 0.4.2 or earlier"
|
|
8
|
+
Those versions of the script did not split multi-allelic records, and removed
|
|
9
|
+
one of two different indels at the same position as a duplicate. Indels from
|
|
10
|
+
multi-allelic sites could therefore be stored untrimmed (e.g. `CAAAAAAA>CAAAAAAAAAAAA`
|
|
11
|
+
instead of `C>CAAAAA`), so the same variant appeared under two representations, or
|
|
12
|
+
were dropped. Re-normalize those VCFs with the current script and rebuild the
|
|
13
|
+
database to correct them.
|
|
6
14
|
|
|
7
15
|
|
|
8
16
|
---
|
|
@@ -17,7 +25,7 @@ Multi-allelic variants and complex indels can be represented in multiple equival
|
|
|
17
25
|
- Multi-allelic sites may not be decomposed into biallelic records
|
|
18
26
|
- Duplicate records can inflate AC
|
|
19
27
|
|
|
20
|
-
`bcftools norm` left-aligns
|
|
28
|
+
`bcftools norm -m -both` decomposes multi-allelic sites into biallelic records, and left-aligns and trims each allele against the reference genome, ensuring consistent representation across samples. `-d exact` then drops only records whose alleles are identical, so two different alleles at the same position are both kept.
|
|
21
29
|
|
|
22
30
|
### Ploidy correction for sex chromosomes
|
|
23
31
|
|
|
@@ -13,7 +13,7 @@ This page explains what each field in AFQuery output means and how to interpret
|
|
|
13
13
|
| **AF** | float | Allele frequency — `AC / AN`. `None` when AN=0 |
|
|
14
14
|
| **N_HET** | int | Number of eligible samples heterozygous for the alt allele (GT=0/1) |
|
|
15
15
|
| **N_HOM_ALT** | int | Number of eligible samples homozygous for the alt allele (GT=1/1 or GT=1). Includes haploid carriers on sex chromosomes and chrM. See [Ploidy](../advanced/ploidy-and-sex-chroms.md#genotype-counting). |
|
|
16
|
-
| **N_HOM_REF** | int | Number of eligible samples homozygous reference (GT=0/0 or GT=0) |
|
|
16
|
+
| **N_HOM_REF** | int | Number of eligible samples homozygous reference (GT=0/0 or GT=0). Samples carrying another ALT allele at the same position are not counted (see [Multi-allelic sites](#multi-allelic-sites)). |
|
|
17
17
|
| **n_eligible** | int | Number of eligible samples — those passing the sex/phenotype/tech filters *and* covered at this position |
|
|
18
18
|
| **N_FAIL** | int | Number of eligible samples whose call at this position had FILTER≠PASS. These samples are counted *only* in N_FAIL — not in N_HET, N_HOM_ALT, or N_HOM_REF — but they stay eligible and still count toward AN. |
|
|
19
19
|
| **N_NO_COVERAGE** | int | Number of eligible samples whose tech lacks coverage evidence at this position. Excluded from `N_HOM_REF` to keep AC/AN conservative. Always `0` unless a coverage-evidence filter is active. See [Coverage Evidence](../advanced/coverage-evidence.md). |
|
|
@@ -84,6 +84,19 @@ AN=0 means no eligible samples have coverage at this position. This happens when
|
|
|
84
84
|
!!! warning "AN=0 does not mean the variant is absent"
|
|
85
85
|
AN=0 means AFQuery has no data to compute frequency. It is not evidence of rarity.
|
|
86
86
|
|
|
87
|
+
### Multi-allelic sites
|
|
88
|
+
|
|
89
|
+
Each ALT allele at a position is reported on its own line, and its counts refer to
|
|
90
|
+
that allele only. A sample carrying a different ALT allele at the same position
|
|
91
|
+
(for example `G/T` on the `G>A` line) is neither a carrier nor homozygous
|
|
92
|
+
reference for this allele, so it appears in none of `N_HET`, `N_HOM_ALT`,
|
|
93
|
+
`N_HOM_REF`, `N_FAIL` or `N_NO_COVERAGE`. The five counts add up to
|
|
94
|
+
`n_eligible` at biallelic sites; at a multi-allelic site they fall short by the
|
|
95
|
+
number of such samples. AC, AN and AF are not affected.
|
|
96
|
+
|
|
97
|
+
A sample with two different ALT alleles (`GT=1/2`) is counted as heterozygous on
|
|
98
|
+
both lines.
|
|
99
|
+
|
|
87
100
|
### Warnings
|
|
88
101
|
|
|
89
102
|
afquery emits a `AfqueryWarning` to stderr when a query may silently return fewer or no results. Common causes:
|
|
@@ -126,7 +139,7 @@ When using `afquery annotate`, the following INFO fields are added to each varia
|
|
|
126
139
|
| `AFQUERY_AF` | A (per ALT) | Allele frequency — one value per ALT allele |
|
|
127
140
|
| `AFQUERY_N_HET` | A (per ALT) | Heterozygous sample count per ALT allele |
|
|
128
141
|
| `AFQUERY_N_HOM_ALT` | A (per ALT) | Homozygous alt sample count per ALT allele |
|
|
129
|
-
| `AFQUERY_N_HOM_REF` | A (per ALT) | Homozygous ref sample count per ALT allele |
|
|
142
|
+
| `AFQUERY_N_HOM_REF` | A (per ALT) | Homozygous ref sample count per ALT allele, excluding carriers of other ALT alleles at the position |
|
|
130
143
|
| `AFQUERY_N_FAIL` | 1 (per site) | Fail sample count — shared across all ALT alleles |
|
|
131
144
|
| `AFQUERY_N_NO_COVERAGE` | A (per ALT) | Eligible samples whose tech lacks coverage evidence at this position. Always `0` unless a coverage-evidence filter is active. See [Coverage Evidence](../advanced/coverage-evidence.md). |
|
|
132
145
|
|
|
@@ -25,7 +25,7 @@ afquery annotate \
|
|
|
25
25
|
| `AFQUERY_AF` | Float | A (per ALT) | Allele frequency (`AC / AN`) |
|
|
26
26
|
| `AFQUERY_N_HET` | Integer | A (per ALT) | Heterozygous sample count |
|
|
27
27
|
| `AFQUERY_N_HOM_ALT` | Integer | A (per ALT) | Homozygous alt sample count |
|
|
28
|
-
| `AFQUERY_N_HOM_REF` | Integer | A (per ALT) | Homozygous ref sample count |
|
|
28
|
+
| `AFQUERY_N_HOM_REF` | Integer | A (per ALT) | Homozygous ref sample count, excluding carriers of other ALT alleles at the position (including alleles stored in the database but absent from the input record) |
|
|
29
29
|
| `AFQUERY_N_FAIL` | Integer | 1 (per site) | Eligible samples whose call had FILTER≠PASS. Excluded from AC, but still counted in AN. Mutually exclusive with N_HET/N_HOM_ALT/N_HOM_REF. |
|
|
30
30
|
| `AFQUERY_N_NO_COVERAGE` | Integer | A (per ALT) | Eligible samples whose tech lacks coverage evidence at this position. Excluded from `N_HOM_REF` to keep AC/AN conservative. Always `0` unless a coverage-evidence filter is active. See [Coverage Evidence](../advanced/coverage-evidence.md). |
|
|
31
31
|
|
|
@@ -155,7 +155,7 @@ that fall below a threshold are reported in **N_NO_COVERAGE** instead of N_HOM_R
|
|
|
155
155
|
|
|
156
156
|
| Flag | Meaning |
|
|
157
157
|
|------|---------|
|
|
158
|
-
| `--min-pass K` | A partially-covered tech is valid for hom-ref at a position only if it has ≥K PASS carriers (het\|hom). Otherwise its non-carrier samples move to `N_NO_COVERAGE`. |
|
|
158
|
+
| `--min-pass K` | A partially-covered tech is valid for hom-ref at a position only if it has ≥K PASS carriers (het\|hom) of any ALT allele there. Otherwise its non-carrier samples move to `N_NO_COVERAGE`. |
|
|
159
159
|
| `--min-observed K` | Same as `--min-pass`, but counts any VCF entry (`het\|hom\|fail`). Useful when you want to include calls that failed FILTER as evidence the position was sequenced. |
|
|
160
160
|
| `--min-quality-evidence K` | Requires ≥K quality-passing carriers per partially-covered tech. Requires a database built with `--min-dp`, `--min-gq`, `--min-qual`, or `--min-covered`. |
|
|
161
161
|
|
|
@@ -167,8 +167,11 @@ afquery query --db ./db/ --locus chr1:925952 --min-pass 1
|
|
|
167
167
|
afquery query --db ./db/ --region chr1:900000-1000000 --min-observed 2 --min-pass 1
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
At a biallelic site the genotype invariant becomes:
|
|
171
171
|
`N_HET + N_HOM_ALT + N_HOM_REF + N_FAIL + N_NO_COVERAGE = n_eligible`.
|
|
172
|
+
At a multi-allelic site, eligible samples that carry only another ALT allele at
|
|
173
|
+
the position fall in none of these categories for this allele, so the sum is
|
|
174
|
+
lower than `n_eligible` by exactly that number of samples.
|
|
172
175
|
|
|
173
176
|
Fully-covered samples (those whose tech was registered without a BED) are
|
|
174
177
|
never affected. Carrier samples (het/hom/fail) are never moved to
|
|
@@ -15,17 +15,14 @@ afquery variant-info --db ./db/ --locus chr1:925952
|
|
|
15
15
|
!!! tip
|
|
16
16
|
`variant-info` is the natural next step after `query` — once you find a variant of interest, use it to see which specific samples carry it.
|
|
17
17
|
|
|
18
|
-
!!! note "
|
|
19
|
-
`variant-info` lists
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
A *large* gap is worth investigating: if `variant-info` shows many carriers from a
|
|
27
|
-
technology that contributes nothing to `AN`, check that technology's capture index
|
|
28
|
-
(see [Debugging Results](../advanced/debugging-results.md)).
|
|
18
|
+
!!! note "Carriers match the counts reported by `query`"
|
|
19
|
+
`variant-info` lists only samples whose capture regions cover the position, the same
|
|
20
|
+
eligible set `query` uses. A WES sample with a call outside its own BED is not counted
|
|
21
|
+
in `AN`, `AC` or the genotype tallies, and is not listed here either. On diploid
|
|
22
|
+
regions the number of `het`, `hom` and `alt` carriers therefore equals `N_HET`,
|
|
23
|
+
`N_HOM_ALT` and `N_FAIL` for the same allele and filters. (In haploid regions a
|
|
24
|
+
single-allele call is listed as `het` but counted in `N_HOM_ALT`.) Earlier versions
|
|
25
|
+
also listed off-target carriers, so the two commands could disagree.
|
|
29
26
|
|
|
30
27
|
By default all samples are queried and results are printed as an aligned text table:
|
|
31
28
|
|
|
@@ -457,8 +457,11 @@ class QueryResult:
|
|
|
457
457
|
N_NO_COVERAGE: int # Eligible samples whose tech lacks evidence (excluded from N_HOM_REF)
|
|
458
458
|
```
|
|
459
459
|
|
|
460
|
-
|
|
460
|
+
At a biallelic site the genotype categories partition the eligible samples:
|
|
461
461
|
`N_HET + N_HOM_ALT + N_HOM_REF + N_FAIL + N_NO_COVERAGE == n_samples_eligible`.
|
|
462
|
+
At a multi-allelic site, eligible samples that carry only another ALT allele at
|
|
463
|
+
the position fall in none of these categories for this allele, so the sum is
|
|
464
|
+
lower than `n_samples_eligible` by exactly that number of samples.
|
|
462
465
|
See [Coverage Evidence](../advanced/coverage-evidence.md) for details on
|
|
463
466
|
`N_NO_COVERAGE`.
|
|
464
467
|
|
|
@@ -25,6 +25,17 @@ REF="$3"
|
|
|
25
25
|
GENDER="$4"
|
|
26
26
|
THREADS="${5:-4}"
|
|
27
27
|
|
|
28
|
+
# -----------------------------
|
|
29
|
+
# bcftools version (< 1.20 refuses to combine -m and -d in bcftools norm)
|
|
30
|
+
# -----------------------------
|
|
31
|
+
MIN_BCFTOOLS="1.20"
|
|
32
|
+
BCFTOOLS_VERSION=$(bcftools --version | head -n1 | awk '{print $2}')
|
|
33
|
+
if [[ "$(printf '%s\n' "${MIN_BCFTOOLS}" "${BCFTOOLS_VERSION}" | sort -V | head -n1)" != "${MIN_BCFTOOLS}" ]]
|
|
34
|
+
then
|
|
35
|
+
echo "ERROR: bcftools >= ${MIN_BCFTOOLS} is required (found ${BCFTOOLS_VERSION})"
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
|
|
28
39
|
OUT="${VCF_ID}_norm.vcf.gz"
|
|
29
40
|
CHR_MAP="chr_list.txt"
|
|
30
41
|
GENDER_FILE="${VCF_ID}_gender.txt"
|
|
@@ -88,8 +99,8 @@ bcftools annotate \
|
|
|
88
99
|
--rename-chrs "${CHR_MAP}" \
|
|
89
100
|
"${VCF}" | \
|
|
90
101
|
bcftools norm \
|
|
102
|
+
-m -both \
|
|
91
103
|
-d exact \
|
|
92
|
-
-d both \
|
|
93
104
|
-f "${REF}" \
|
|
94
105
|
--check-ref ws \
|
|
95
106
|
--targets "${TARGETS}" | \
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.
|
|
22
|
-
__version_tuple__ = version_tuple = (0,
|
|
21
|
+
__version__ = version = '0.5.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 5, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -7,7 +7,6 @@ from . import storage
|
|
|
7
7
|
from .bitmaps import deserialize
|
|
8
8
|
from .constants import normalize_chrom
|
|
9
9
|
from .models import AfqueryWarning, SampleFilter
|
|
10
|
-
from .ploidy import split_ploidy
|
|
11
10
|
|
|
12
11
|
logger = logging.getLogger(__name__)
|
|
13
12
|
|
|
@@ -33,8 +32,6 @@ def _compute_chunk_annotations(
|
|
|
33
32
|
AfqueryWarning, stacklevel=2,
|
|
34
33
|
)
|
|
35
34
|
sample_bm = engine._build_sample_bitmap(sf)
|
|
36
|
-
male_bm = engine._male_bm
|
|
37
|
-
female_bm = engine._female_bm
|
|
38
35
|
|
|
39
36
|
unique_positions = list({pos for pos, _ref, _alts in records})
|
|
40
37
|
|
|
@@ -83,6 +80,15 @@ def _compute_chunk_annotations(
|
|
|
83
80
|
if pos in valid_pos_set:
|
|
84
81
|
variant_data[(pos, ref, alt)] = tuple(bytes(b) for b in row[3:3 + n_bitmap_cols])
|
|
85
82
|
|
|
83
|
+
unpacked = {key: engine._unpack_bitmaps(raw) for key, raw in variant_data.items()}
|
|
84
|
+
stored_by_pos: dict[int, list[tuple]] = {}
|
|
85
|
+
for (pos, _ref, _alt), bitmaps in unpacked.items():
|
|
86
|
+
stored_by_pos.setdefault(pos, []).append(bitmaps)
|
|
87
|
+
sites = {
|
|
88
|
+
pos: engine._site_evidence(group) if len(group) > 1 else None
|
|
89
|
+
for pos, group in stored_by_pos.items()
|
|
90
|
+
}
|
|
91
|
+
|
|
86
92
|
result: dict[tuple[int, str, str], tuple[int, int, bool, int, int, int, int, int]] = {}
|
|
87
93
|
for pos, ref, alts in records:
|
|
88
94
|
eligible, AN = pos_data[pos]
|
|
@@ -92,38 +98,21 @@ def _compute_chunk_annotations(
|
|
|
92
98
|
continue # dedup
|
|
93
99
|
if AN == 0:
|
|
94
100
|
result[key] = (0, 0, False, 0, 0, 0, 0, 0)
|
|
95
|
-
elif key in
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
haploid_elig, diploid_elig = split_ploidy(
|
|
100
|
-
eligible, male_bm, female_bm, chrom, pos, engine._genome_build
|
|
101
|
-
)
|
|
102
|
-
het_elig = het_bm & eligible
|
|
103
|
-
hom_elig = hom_bm & eligible
|
|
104
|
-
AC = (len((het_elig | hom_elig) & haploid_elig)
|
|
105
|
-
+ len(het_elig & diploid_elig)
|
|
106
|
-
+ 2 * len(hom_elig & diploid_elig))
|
|
107
|
-
N_HET = len(het_elig & diploid_elig)
|
|
108
|
-
N_HOM_ALT = (
|
|
109
|
-
len(hom_elig & diploid_elig) + len((het_elig | hom_elig) & haploid_elig)
|
|
110
|
-
)
|
|
111
|
-
N_FAIL: int = len(fail_bm & eligible)
|
|
112
|
-
no_cov_bm = engine._compute_no_coverage_bm(
|
|
113
|
-
eligible, het_bm, hom_bm, fail_bm,
|
|
114
|
-
sf.min_pass, sf.min_observed,
|
|
115
|
-
filtered_bm=filtered_bm,
|
|
116
|
-
quality_pass_bm=quality_pass_bm,
|
|
117
|
-
min_quality_evidence=sf.min_quality_evidence,
|
|
101
|
+
elif key in unpacked:
|
|
102
|
+
s = engine._variant_stats(
|
|
103
|
+
chrom, pos, eligible, unpacked[key], sites[pos],
|
|
104
|
+
sf.min_pass, sf.min_observed, sf.min_quality_evidence,
|
|
118
105
|
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
result[key] = (AC, AN, True, N_FAIL, N_HET, N_HOM_ALT, N_HOM_REF, N_NO_COVERAGE)
|
|
106
|
+
result[key] = (s.AC, AN, True, s.N_FAIL, s.N_HET, s.N_HOM_ALT,
|
|
107
|
+
s.N_HOM_REF, s.N_NO_COVERAGE)
|
|
122
108
|
else:
|
|
123
|
-
#
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
|
|
109
|
+
# Allele not in Parquet: eligible samples are hom-ref unless they
|
|
110
|
+
# carry another allele stored at this position. Phase 1/2 filters
|
|
111
|
+
# do not apply because this allele has no carriers to evaluate.
|
|
112
|
+
stored = stored_by_pos.get(pos)
|
|
113
|
+
n_other = (len(engine._site_evidence(stored).carrier_bm & eligible)
|
|
114
|
+
if stored else 0)
|
|
115
|
+
result[key] = (0, AN, False, 0, 0, 0, len(eligible) - n_other, 0)
|
|
127
116
|
|
|
128
117
|
return result
|
|
129
118
|
|
|
@@ -170,7 +159,8 @@ def annotate_vcf(
|
|
|
170
159
|
})
|
|
171
160
|
vcf.add_info_to_header({
|
|
172
161
|
"ID": "AFQUERY_N_HOM_REF", "Number": "A", "Type": "Integer",
|
|
173
|
-
"Description": "Count of homozygous ref eligible samples per alt allele"
|
|
162
|
+
"Description": "Count of homozygous ref eligible samples per alt allele, "
|
|
163
|
+
"excluding carriers of other alt alleles at the position",
|
|
174
164
|
})
|
|
175
165
|
vcf.add_info_to_header({
|
|
176
166
|
"ID": "AFQUERY_N_FAIL", "Number": "1", "Type": "Integer",
|
|
@@ -11,7 +11,6 @@ from . import storage
|
|
|
11
11
|
from .bitmaps import deserialize
|
|
12
12
|
from .constants import normalize_chrom, ALL_CHROMS
|
|
13
13
|
from .models import SampleFilter
|
|
14
|
-
from .ploidy import split_ploidy
|
|
15
14
|
|
|
16
15
|
logger = logging.getLogger(__name__)
|
|
17
16
|
|
|
@@ -180,10 +179,12 @@ def _dump_bucket_worker(
|
|
|
180
179
|
pos_cache: dict[int, tuple] = {}
|
|
181
180
|
group_pos_cache: dict[tuple, tuple] = {}
|
|
182
181
|
|
|
182
|
+
unpacked = [engine._unpack_bitmaps(row[3:]) for row in rows]
|
|
183
|
+
sites = engine._site_evidence_by_pos([row[0] for row in rows], unpacked)
|
|
184
|
+
|
|
183
185
|
result_rows = []
|
|
184
|
-
for row in rows:
|
|
186
|
+
for row, bitmaps in zip(rows, unpacked):
|
|
185
187
|
pos, ref, alt = row[0], row[1], row[2]
|
|
186
|
-
het_bm, hom_bm, fail_bm, filtered_bm, quality_pass_bm = engine._unpack_bitmaps(row[3:])
|
|
187
188
|
|
|
188
189
|
# Base eligible / AN
|
|
189
190
|
if pos not in pos_cache:
|
|
@@ -193,49 +194,27 @@ def _dump_bucket_worker(
|
|
|
193
194
|
if AN == 0:
|
|
194
195
|
continue
|
|
195
196
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
het_elig = het_bm & eligible
|
|
200
|
-
hom_elig = hom_bm & eligible
|
|
201
|
-
AC = (
|
|
202
|
-
len((het_elig | hom_elig) & haploid_elig)
|
|
203
|
-
+ len(het_elig & diploid_elig)
|
|
204
|
-
+ 2 * len(hom_elig & diploid_elig)
|
|
197
|
+
s = engine._variant_stats(
|
|
198
|
+
chrom, pos, eligible, bitmaps, sites[pos],
|
|
199
|
+
base_sf.min_pass, base_sf.min_observed, base_sf.min_quality_evidence,
|
|
205
200
|
)
|
|
206
201
|
|
|
207
|
-
if AC == 0 and not include_ac_zero:
|
|
202
|
+
if s.AC == 0 and not include_ac_zero:
|
|
208
203
|
continue # main row filter
|
|
209
204
|
|
|
210
|
-
N_HET = len(het_elig & diploid_elig)
|
|
211
|
-
N_HOM_ALT = (
|
|
212
|
-
len(hom_elig & diploid_elig) + len((het_elig | hom_elig) & haploid_elig)
|
|
213
|
-
)
|
|
214
|
-
AF = AC / AN
|
|
215
|
-
N_FAIL = len(fail_bm & eligible)
|
|
216
|
-
no_cov_bm = engine._compute_no_coverage_bm(
|
|
217
|
-
eligible, het_bm, hom_bm, fail_bm,
|
|
218
|
-
base_sf.min_pass, base_sf.min_observed,
|
|
219
|
-
filtered_bm=filtered_bm,
|
|
220
|
-
quality_pass_bm=quality_pass_bm,
|
|
221
|
-
min_quality_evidence=base_sf.min_quality_evidence,
|
|
222
|
-
)
|
|
223
|
-
N_NO_COVERAGE = len(no_cov_bm)
|
|
224
|
-
N_HOM_REF = len(eligible) - N_HET - N_HOM_ALT - N_FAIL - N_NO_COVERAGE
|
|
225
|
-
|
|
226
205
|
out_row: dict = {
|
|
227
206
|
"chrom": chrom,
|
|
228
207
|
"pos": pos,
|
|
229
208
|
"ref": ref,
|
|
230
209
|
"alt": alt,
|
|
231
|
-
"AC": AC,
|
|
210
|
+
"AC": s.AC,
|
|
232
211
|
"AN": AN,
|
|
233
|
-
"AF":
|
|
234
|
-
"N_HET": N_HET,
|
|
235
|
-
"N_HOM_ALT": N_HOM_ALT,
|
|
236
|
-
"N_HOM_REF": N_HOM_REF,
|
|
237
|
-
"N_FAIL": N_FAIL,
|
|
238
|
-
"N_NO_COVERAGE": N_NO_COVERAGE,
|
|
212
|
+
"AF": s.AC / AN,
|
|
213
|
+
"N_HET": s.N_HET,
|
|
214
|
+
"N_HOM_ALT": s.N_HOM_ALT,
|
|
215
|
+
"N_HOM_REF": s.N_HOM_REF,
|
|
216
|
+
"N_FAIL": s.N_FAIL,
|
|
217
|
+
"N_NO_COVERAGE": s.N_NO_COVERAGE,
|
|
239
218
|
}
|
|
240
219
|
|
|
241
220
|
# Per-group columns
|
|
@@ -246,42 +225,19 @@ def _dump_bucket_worker(
|
|
|
246
225
|
group_pos_cache[cache_key] = engine._compute_eligible(chrom, pos, g_bm)
|
|
247
226
|
g_eligible, g_AN = group_pos_cache[cache_key]
|
|
248
227
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
g_het_elig = het_bm & g_eligible
|
|
253
|
-
g_hom_elig = hom_bm & g_eligible
|
|
254
|
-
g_AC = (
|
|
255
|
-
len((g_het_elig | g_hom_elig) & g_haploid)
|
|
256
|
-
+ len(g_het_elig & g_diploid)
|
|
257
|
-
+ 2 * len(g_hom_elig & g_diploid)
|
|
258
|
-
)
|
|
259
|
-
g_N_HET = len(g_het_elig & g_diploid)
|
|
260
|
-
g_N_HOM_ALT = (
|
|
261
|
-
len(g_hom_elig & g_diploid) + len((g_het_elig | g_hom_elig) & g_haploid)
|
|
262
|
-
)
|
|
263
|
-
g_AF = g_AC / g_AN if g_AN > 0 else 0.0
|
|
264
|
-
g_N_FAIL = len(fail_bm & g_eligible)
|
|
265
|
-
g_no_cov_bm = engine._compute_no_coverage_bm(
|
|
266
|
-
g_eligible, het_bm, hom_bm, fail_bm,
|
|
267
|
-
g_sf.min_pass, g_sf.min_observed,
|
|
268
|
-
filtered_bm=filtered_bm,
|
|
269
|
-
quality_pass_bm=quality_pass_bm,
|
|
270
|
-
min_quality_evidence=g_sf.min_quality_evidence,
|
|
271
|
-
)
|
|
272
|
-
g_N_NO_COVERAGE = len(g_no_cov_bm)
|
|
273
|
-
g_N_HOM_REF = (
|
|
274
|
-
len(g_eligible) - g_N_HET - g_N_HOM_ALT - g_N_FAIL - g_N_NO_COVERAGE
|
|
228
|
+
g = engine._variant_stats(
|
|
229
|
+
chrom, pos, g_eligible, bitmaps, sites[pos],
|
|
230
|
+
g_sf.min_pass, g_sf.min_observed, g_sf.min_quality_evidence,
|
|
275
231
|
)
|
|
276
232
|
|
|
277
|
-
out_row[f"AC_{label}"] =
|
|
233
|
+
out_row[f"AC_{label}"] = g.AC
|
|
278
234
|
out_row[f"AN_{label}"] = g_AN
|
|
279
|
-
out_row[f"AF_{label}"] =
|
|
280
|
-
out_row[f"N_HET_{label}"] =
|
|
281
|
-
out_row[f"N_HOM_ALT_{label}"] =
|
|
282
|
-
out_row[f"N_HOM_REF_{label}"] =
|
|
283
|
-
out_row[f"N_FAIL_{label}"] =
|
|
284
|
-
out_row[f"N_NO_COVERAGE_{label}"] =
|
|
235
|
+
out_row[f"AF_{label}"] = g.AC / g_AN if g_AN > 0 else 0.0
|
|
236
|
+
out_row[f"N_HET_{label}"] = g.N_HET
|
|
237
|
+
out_row[f"N_HOM_ALT_{label}"] = g.N_HOM_ALT
|
|
238
|
+
out_row[f"N_HOM_REF_{label}"] = g.N_HOM_REF
|
|
239
|
+
out_row[f"N_FAIL_{label}"] = g.N_FAIL
|
|
240
|
+
out_row[f"N_NO_COVERAGE_{label}"] = g.N_NO_COVERAGE
|
|
285
241
|
|
|
286
242
|
result_rows.append(out_row)
|
|
287
243
|
|