Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of variant_stats #1119

Merged
merged 5 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ New Features
(:user:`timothymillar`, :pr:`1100`, :issue:`1062`)
- Add :func:`display_pedigree` function.
(:user:`timothymillar`, :pr:`1104`, :issue:`1097`)
- Add option to count variant alleles directly from call genotypes in function :func:`count_variant_alleles`.
(:user:`timothymillar`, :pr:`1119`, :issue:`1116`)

.. Breaking changes
.. ~~~~~~~~~~~~~~~~

.. Deprecations
.. ~~~~~~~~~~~~

.. Improvements
.. ~~~~~~~~~~~~
Improvements
~~~~~~~~~~~~

- Improve performance of :func:`variant_stats` and :func:`sample_stats` functions.
(:user:`timothymillar`, :pr:`1119`, :issue:`1116`)

.. Bug fixes
.. ~~~~~~~~~
Expand Down
6 changes: 3 additions & 3 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ shows how it can be used in the context of doing something simple like counting

# Now the result is correct -- only the third sample is heterozygous so the count should be 1.
# This how many sgkit functions handle missing data internally:
sg.variant_stats(ds).variant_n_het.item(0)
sg.variant_stats(ds).variant_n_het.values.item(0)

Windowing
---------
Expand Down Expand Up @@ -320,8 +320,8 @@ Xarray and Pandas operations in a single pipeline:
# for windows of size 20 variants
(
ds
# Add call rate and other statistics
.pipe(sg.variant_stats)
# Add and compute call rate and other statistics
.pipe(sg.variant_stats).compute()
# Apply filter to include variants present across > 80% of samples
.pipe(lambda ds: ds.sel(variants=ds.variant_call_rate > .8))
# Create windows of size 20 variants
Expand Down
Loading
Loading