Skip to content

Add missing API docs to Sphinx #214

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

Merged
merged 1 commit into from
Aug 31, 2020
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
25 changes: 23 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,32 @@ API reference

This page provides an auto-generated summary of sgkits's API.

Top-level functions
===================
Creating a dataset
==================

.. autosummary::
:toctree: generated/

create_genotype_call_dataset
create_genotype_dosage_dataset
read_vcfzarr

Methods
=======

.. autosummary::
:toctree: generated/

count_call_alleles
count_variant_alleles
gwas_linear_regression
hardy_weinberg_test
regenie

Utilities
=========

.. autosummary::
:toctree: generated/

display_genotypes
2 changes: 1 addition & 1 deletion sgkit/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_genotype_dosage_dataset(
call_genotype_probability: Any,
variant_id: Any = None,
) -> xr.Dataset:
"""Create a dataset of genotype calls.
"""Create a dataset of genotype dosages.

Parameters
----------
Expand Down
7 changes: 4 additions & 3 deletions sgkit/stats/hwe.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def hardy_weinberg_test(
Dataset
Dataset containing (N = num variants):
variant_hwe_p_value : (N,) ArrayLike
P values from HWE test for each variant as float in [0, 1].
P values from HWE test for each variant as float in [0, 1].

References
----------
Expand All @@ -156,8 +156,9 @@ def hardy_weinberg_test(
Raises
------
NotImplementedError
* If ploidy of provided dataset != 2
* If maximum number of alleles in provided dataset != 2
If ploidy of provided dataset != 2
NotImplementedError
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had originally been breaking multiple causes of the same error out like this but @ravwojdyla suggested collapsing them in a past PR. @ravwojdyla did you have a reason for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sphinx doesn't render the bullets correctly, which is why I changed this.

If maximum number of alleles in provided dataset != 2
"""
if ds.dims["ploidy"] != 2:
raise NotImplementedError("HWE test only implemented for diploid genotypes")
Expand Down
31 changes: 16 additions & 15 deletions sgkit/stats/regenie.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def regenie(
) -> Dataset:
"""Regenie trait transformation.

[REGENIE](https://github.com/rgcgithub/regenie) is a whole-genome
`REGENIE <https://github.com/rgcgithub/regenie>`_ is a whole-genome
regression technique that produces trait estimates for association
tests. These estimates are subtracted from trait values and
sampling statistics (p-values, standard errors, etc.) are evaluated
Expand Down Expand Up @@ -790,14 +790,20 @@ def regenie(
Dataset
A dataset containing the following variables:
- `base_prediction` (blocks, alphas, samples, outcomes): Stage 1
predictions from ridge regression reduction .
predictions from ridge regression reduction .
- `meta_prediction` (samples, outcomes): Stage 2 predictions from
the best meta estimator trained on the out-of-sample Stage 1
predictions.
the best meta estimator trained on the out-of-sample Stage 1
predictions.
- `loco_prediction` (contigs, samples, outcomes): LOCO predictions
resulting from Stage 2 predictions ignoring effects for variant
blocks on held out contigs. This will be absent if the
data provided does not contain at least 2 contigs.
resulting from Stage 2 predictions ignoring effects for variant
blocks on held out contigs. This will be absent if the
data provided does not contain at least 2 contigs.

Raises
------
ValueError
If dosage, covariates, and trait arrays do not have the same number
of samples.

Examples
--------
Expand All @@ -824,15 +830,10 @@ def regenie(
References
----------
[1] - Mbatchou, J., L. Barnard, J. Backman, and A. Marcketta. 2020.
“Computationally Efficient Whole Genome Regression for Quantitative and Binary
Traits.” bioRxiv. https://www.biorxiv.org/content/10.1101/2020.06.19.162354v2.abstract.
[2] - https://glow.readthedocs.io/en/latest/tertiary/whole-genome-regression.html
“Computationally Efficient Whole Genome Regression for Quantitative and Binary
Traits.” bioRxiv. https://www.biorxiv.org/content/10.1101/2020.06.19.162354v2.abstract.

Raises
------
ValueError
If dosage, covariates, and trait arrays do not have the same number
of samples.
[2] - https://glow.readthedocs.io/en/latest/tertiary/whole-genome-regression.html
"""
if isinstance(covariates, str):
covariates = [covariates]
Expand Down