Skip to content

[query/vds] Add LEN field to VDS #14675

Merged
hail-ci-robot merged 11 commits into
hail-is:mainfrom
chrisvittal:vds/len-end-translation
Oct 5, 2024
Merged

[query/vds] Add LEN field to VDS #14675
hail-ci-robot merged 11 commits into
hail-is:mainfrom
chrisvittal:vds/len-end-translation

Conversation

@chrisvittal

@chrisvittal chrisvittal commented Sep 9, 2024

Copy link
Copy Markdown
Collaborator

This is the beginning of a series of changes to support export of VDS to VCF 4.5, the version of VCF that contains the standardized form of our work that culminated in SVCR/VDS.

Reference blocks were standardized with a LEN rather than an END. So, now, by default, add LEN to all VDS reads and drop END in favor of LEN on all VDS writes. Our optimizer will be able to take care of pruning away the dead field in pipelines that don't use it.

We make sure that all VDS creation (other than the combiner), such as read_vds and from_merged_representation, contains both LEN and END preserving user code that depends on the presence of the END field.

Furthermore, this change contains necessary combiner updates to prefer LEN over END, and to use LEN in the combiner itself.

@chrisvittal chrisvittal mentioned this pull request Sep 9, 2024
7 tasks
@chrisvittal chrisvittal marked this pull request as ready for review September 9, 2024 20:44

@patrick-schultz patrick-schultz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few small things

Comment thread hail/python/hail/vds/combiner/variant_dataset_combiner.py Outdated
Comment thread hail/python/hail/vds/variant_dataset.py Outdated
Comment thread hail/python/hail/vds/variant_dataset.py Outdated

@patrick-schultz patrick-schultz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris!

@cjllanwarne cjllanwarne left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I've left a few minor comments but happy to switch over to Approve if you prefer to leave things as they are.

Comment thread hail/python/hail/vds/variant_dataset.py
Comment thread hail/python/hail/vds/variant_dataset.py Outdated
Comment thread hail/python/hail/vds/variant_dataset.py Outdated
Comment thread hail/python/hail/vds/variant_dataset.py
.when(hl.is_defined(mt[ref_block_indicator_field]) & mt[gt_field].is_hom_ref(), True)
.or_error(
hl.str(
'cannot create VDS from merged representation -' ' found END field with non-reference genotype at '

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL python lets you concatenate strings by just putting them next to each other like this 🤯

chrisvittal added a commit to chrisvittal/hail that referenced this pull request Sep 18, 2024
After split_multi, LGT is dropped from the variant data of a VDS. After
PR hail-is#14560, LGT is added to datasets after creation via the combiner.
After hail-is#14675 the same is true for `from_merged_representation`. We
should keep the GT/LGT field consistent across ref and var data. This
change does so for split_multi.

Resolves hail-is#14694
chrisvittal added a commit to chrisvittal/hail that referenced this pull request Sep 19, 2024
After split_multi, LGT is dropped from the variant data of a VDS. After
PR hail-is#14560, LGT is added to datasets after creation via the combiner.
After hail-is#14675 the same is true for `from_merged_representation`. We
should keep the GT/LGT field consistent across ref and var data. This
change does so for split_multi.

Resolves hail-is#14694
hail-ci-robot pushed a commit that referenced this pull request Sep 19, 2024
After split_multi, LGT is dropped from the variant data of a VDS. After
PR #14560, LGT is added to datasets after creation via the combiner.
After #14675 the same is true for `from_merged_representation`. We
should keep the GT/LGT field consistent across ref and var data. This
change does so for split_multi.

Resolves #14694
@chrisvittal chrisvittal force-pushed the vds/len-end-translation branch from 9bce5c9 to d7d31cb Compare September 20, 2024 17:14
We can't do this anymore since genotype may be something other than
diploid.

Missed this in the original VDS ploidy changes
chrisvittal and others added 9 commits September 23, 2024 14:20
This is the beginning of a series of changes to support export of VDS to
VCF 4.5, the version of VCF that contains the standardized form of our
work that culminated in SVCR/VDS.

Reference blocks were standardized with a LEN rather than an END. So,
now, by default, add LEN to all VDS reads and drop END in favor of LEN
on all VDS writes. Our optimizer will be able to take care of pruning
away the dead field.

We make sure that all VDS creation (other than the combiner), such as
read_vds and from_merged_representation, contains both LEN and END
preserving user code that depends on the presence of the END field.
Co-authored-by: Patrick Schultz <pschultz@broadinstitute.org>
@chrisvittal chrisvittal force-pushed the vds/len-end-translation branch from 473e90f to f39364c Compare September 23, 2024 18:21
@chrisvittal chrisvittal dismissed patrick-schultz’s stale review September 30, 2024 16:27

dismissing this since I'd like another look after working around one of the core issues discoverd here

@patrick-schultz patrick-schultz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks Chris!

@hail-ci-robot hail-ci-robot merged commit 97e7833 into hail-is:main Oct 5, 2024
chrisvittal added a commit to chrisvittal/hail that referenced this pull request May 21, 2025
As of hail-is#14675, we are automatically adding a `LEN` field to VDS on read,
while also dropping the `END` field on write. For older VDS, this puts
the `LEN` field at the end of the reference entry struct. PR hail-is#14675 puts
`LEN` as the first item in the entry struct when creating new reference
data from a GVCF. This leads to an incompatibility when running the
combiner on a mixture of old and new datasets. The solution here can be
very simple. Just put `LEN` at the end of the entry struct on GVCF
import as well.
chrisvittal added a commit to chrisvittal/hail that referenced this pull request May 23, 2025
…#14897)

As of hail-is#14675, we are automatically adding a `LEN` field to VDS on read,
while also dropping the `END` field on write. For older VDS, this puts
the `LEN` field at the end of the reference entry struct. PR hail-is#14675 puts
`LEN` as the first item in the entry struct when creating new reference
data from a GVCF. This leads to an incompatibility when running the
combiner on a mixture of old and new datasets. The solution here can be
very simple. Just put `LEN` at the end of the entry struct on GVCF
import as well.

## Security Assessment

Delete all except the correct answer:
- This change cannot impact the Hail Batch instance as deployed by Broad
Institute in GCP
jmarshall pushed a commit to populationgenomics/hail that referenced this pull request May 25, 2025
…#14897)

As of hail-is#14675, we are automatically adding a `LEN` field to VDS on read,
while also dropping the `END` field on write. For older VDS, this puts
the `LEN` field at the end of the reference entry struct. PR hail-is#14675 puts
`LEN` as the first item in the entry struct when creating new reference
data from a GVCF. This leads to an incompatibility when running the
combiner on a mixture of old and new datasets. The solution here can be
very simple. Just put `LEN` at the end of the entry struct on GVCF
import as well.

[Cherry-picked from upstream 012856c]
milo-hyben pushed a commit to populationgenomics/hail that referenced this pull request May 25, 2025
…#14897) (#366)

As of hail-is#14675, we are automatically adding a `LEN` field to VDS on read,
while also dropping the `END` field on write. For older VDS, this puts
the `LEN` field at the end of the reference entry struct. PR hail-is#14675 puts
`LEN` as the first item in the entry struct when creating new reference
data from a GVCF. This leads to an incompatibility when running the
combiner on a mixture of old and new datasets. The solution here can be
very simple. Just put `LEN` at the end of the entry struct on GVCF
import as well.

[Cherry-picked from upstream 012856c]

Co-authored-by: Christopher Vittal <cvittal@broadinstitute.org>
ehigham added a commit to ehigham/hail that referenced this pull request Jun 24, 2026
…ail-is#15543)

Adds two `Simplify` rules that push `MatrixFilterCols` through
`MatrixMapEntries` and `MatrixFilterEntries`, so column reduction runs
before per-entry work.

_should_ fix a regression in VDS queries introduced by hail-is#14675 (which
added a LEN field via `MatrixMapEntries`). The regression occurs because
`MatrixFilterCols` sits outside `MatrixMapEntries` after lowering,
forcing the entries map to materialize the full entries array for all
columns before column filtering subsets it — producing an extra
`ToArray` of the entire entries array per row. (to verify)

This change does not affect the broad-managed batch service in gcp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants