Skip to content

Commit 3773658

Browse files
committed
Add documentation to window function
1 parent 7eb61e5 commit 3773658

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

sgkit/variables.py

+8
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,11 @@ def _check_field(
385385
ArrayLikeSpec("variant_t_value")
386386
)
387387
"""T statistics for each beta."""
388+
window_start, window_start_spec = SgkitVariables.register_variable(
389+
ArrayLikeSpec("window_start", kind="i", ndim=1)
390+
)
391+
"""The index values of window start positions along the ``variants`` dimension."""
392+
window_stop, window_stop_spec = SgkitVariables.register_variable(
393+
ArrayLikeSpec("window_stop", kind="i", ndim=1)
394+
)
395+
"""The index values of window stop positions along the ``variants`` dimension."""

sgkit/window.py

+29-2
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)