Skip to content

Commit 7bbef58

Browse files
tomwhitemergify[bot]
authored andcommitted
Add documentation to window function
1 parent 5c59b49 commit 7bbef58

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

sgkit/variables.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,3 +399,11 @@ def _check_field(
399399
ArrayLikeSpec("variant_t_value")
400400
)
401401
"""T statistics for each beta."""
402+
window_start, window_start_spec = SgkitVariables.register_variable(
403+
ArrayLikeSpec("window_start", kind="i", ndim=1)
404+
)
405+
"""The index values of window start positions along the ``variants`` dimension."""
406+
window_stop, window_stop_spec = SgkitVariables.register_variable(
407+
ArrayLikeSpec("window_stop", kind="i", ndim=1)
408+
)
409+
"""The index values of window stop positions along the ``variants`` dimension."""

sgkit/window.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,35 @@ def window(
1717
step: int,
1818
merge: bool = True,
1919
) -> Dataset:
20-
"""Add windowing information to a dataset."""
21-
20+
"""Add fixed-size windowing information to a dataset.
21+
22+
Windows are defined over the ``variants`` dimension, and are
23+
used by some downstream functions to calculate statistics for
24+
each window.
25+
26+
Parameters
27+
----------
28+
ds
29+
Genotype call dataset.
30+
size
31+
The window size (number of variants).
32+
step
33+
The distance (number of variants) between start positions of windows.
34+
merge
35+
If True (the default), merge the input dataset and the computed
36+
output variables into a single dataset, otherwise return only
37+
the computed output variables.
38+
See :ref:`dataset_merge` for more details.
39+
40+
Returns
41+
-------
42+
A dataset containing the following variables:
43+
44+
- :data:`sgkit.variables.window_start_spec` (windows):
45+
The index values of window start positions.
46+
- :data:`sgkit.variables.window_stop_spec` (windows):
47+
The index values of window stop positions.
48+
"""
2249
n_variants = ds.dims["variants"]
2350

2451
length = n_variants

0 commit comments

Comments
 (0)