Skip to content

Commit

Permalink
fix IAF computation for all samples (#563) (#564)
Browse files Browse the repository at this point in the history
* fix IAF computation for all samples

* fix Mamba build

Co-authored-by: Adam Wenocur <[email protected]>
  • Loading branch information
github-actions[bot] and awenocur authored Aug 16, 2023
1 parent a87964b commit 51c9bdb
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions apis/python/tests/test_tiledbvcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ def test_ingest_with_stats(tmp_path):
).bool()
assert (
data_frame[data_frame["sample_name"] == "second"]["info_TILEDB_IAF"].iloc[0][0]
== 0.0625
== 0.9375
)
data_frame = ds.read(
samples=sample_names,
Expand All @@ -1177,7 +1177,7 @@ def test_ingest_with_stats(tmp_path):
data_frame[
(data_frame["sample_name"] == "second") & (data_frame["pos_start"] == 4)
]["info_TILEDB_IAF"].iloc[0][0]
== 0.125
== 0.9375
)


Expand Down
6 changes: 6 additions & 0 deletions ci/azure-linux_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ steps:
sudo chown -R $USER $CONDA
fi
if [[ "$AGENT_OS" == "Darwin" ]]; then
conda install -y libarchive=3.6.2=h6d8d9f1_0 -n base -c conda-forge
else
conda install -y libarchive -n base -c conda-forge
fi
# Install mamba for faster environment creation
conda install -y mamba -n base -c conda-forge
Expand Down
4 changes: 2 additions & 2 deletions libtiledbvcf/src/read/reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ bool Reader::process_query_results_v4() {
// If the allele is in GT, consider it in the pass computation
// TODO: when supporting greater than diploid organisms, expand the
// following boolean statement into a loop
if ((gt.size() > 0 && allele_index == gt[0]) ||
(gt.size() > 1 && allele_index == gt[1])) {
if (!is_ref && ((gt.size() > 0 && allele_index == gt[0]) ||
(gt.size() > 1 && allele_index == gt[1]))) {
pass = pass || allele_passes;
} else {
LOG_TRACE(" ignore allele {} not in GT", allele_index);
Expand Down
2 changes: 1 addition & 1 deletion libtiledbvcf/src/stats/variant_stats_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class AFMap {
if (next_allele == pos_map.second.end()) {
return 0;
}
return 1.0 * next_allele->second / num_samples;
return 1.0 * next_allele->second / num_samples / 2;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/eighth.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT 2/2
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT 0/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/0
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/fifth.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT:AD:AB 0/1:1:1.03493
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT:AD:AB 2/2:3:5
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT:AD:AB 2/2:20:3.5
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT:AD:AB 1/1:12:83.2
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT:AD:AB 0/0:12:83.2
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/first.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 1042.73 . ExcessHet=4.8532 GT 0/1
chr1 3 . C A,G 10.032 . ExcessHet=2.0134 GT 2/2
chr1 4 . G GTTTA,<NON_REF> 1042.73 . ExcessHet=4.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 1042.73 . ExcessHet=4.8532 GT 0/0
chr2 1 . G GTTTA 1042.73 . ExcessHet=4.8532 GT ./1
chr2 1 . G GTTTA 1042.73 . ExcessHet=4.8532 GT 1/.
chr2 3 . G GTTTA 1042.73 . ExcessHet=4.8532 GT 1/1
Expand Down
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/fourth.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/1
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT 2/2
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/0
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/seventh.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/1
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT 0/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/0
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/sixth.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT 2/2
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT 0/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/0
2 changes: 1 addition & 1 deletion libtiledbvcf/test/inputs/stats/third.vcf
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
chr1 1 . T C,<NON_REF> 829.77 . ExcessHet=3.0103 GT 0/1
chr1 2 . G GTTTA,T,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/1
chr1 3 . C A,T 10.032 . ExcessHet=8.34 GT 0/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 1/1
chr1 4 . G GTTTA,<NON_REF> 343.73 . ExcessHet=2.8532 GT 0/0

0 comments on commit 51c9bdb

Please sign in to comment.