Skip to content

Commit

Permalink
Add indexes documentation for genetic_relatedness_weighted
Browse files Browse the repository at this point in the history
  • Loading branch information
brieuclehmann committed Jun 29, 2023
1 parent 039a3b8 commit d442686
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/python-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ Single site
TreeSequence.Fst
TreeSequence.genealogical_nearest_neighbours
TreeSequence.genetic_relatedness
TreeSequence.genetic_relatedness_weighted
TreeSequence.general_stat
TreeSequence.segregating_sites
TreeSequence.sample_count_stat
Expand Down
6 changes: 6 additions & 0 deletions docs/stats.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ appears beside the listed method.
* Multi-way
* {meth}`~TreeSequence.divergence`
* {meth}`~TreeSequence.genetic_relatedness`
{meth}`~TreeSequence.genetic_relatedness_weighted`
* {meth}`~TreeSequence.f4`
{meth}`~TreeSequence.f3`
{meth}`~TreeSequence.f2`
Expand Down Expand Up @@ -590,6 +591,11 @@ and boolean expressions (e.g., {math}`(x > 0)`) are interpreted as 0/1.
where {math}`m = \frac{1}{n}\sum_{k=1}^n x_k` with {math}`n` the total number
of samples.

`genetic_relatedness_weighted`
: {math}`f(w_i, w_j, x_i, x_j) = \frac{1}{2}w_iw_j(x_i - m)(x_j - m)`,

where {math}`m = \frac{1}{n}\sum_{k=1}^n x_k` with {math}`n` the total number
of samples.
`Y2`
: {math}`f(x_1, x_2) = \frac{x_1 (n_2 - x_2) (n_2 - x_2 - 1)}{n_1 n_2 (n_2 - 1)}`

Expand Down
7 changes: 5 additions & 2 deletions python/tskit/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -7705,11 +7705,14 @@ def genetic_relatedness_weighted(
then the k-th column of output will be
:math:`\sum_{a,b} W_{ai} W_{bj} C_{ab}`,
where :math:`W` is the matrix of weights, and :math:`C_{ab}` is the
{meth}`.genetic_relatedness` between sample i and sample j.
:meth:`genetic_relatedness <.TreeSequence.genetic_relatedness>` between sample
a and sample b, summing over all pairs of samples in the tree sequence.
:param numpy.ndarray W: An array of values with one row for each sample and one
column for each set of weights.
:param list indexes: A list of 2-tuples, or None.
:param list indexes: A list of 2-tuples, or None (default). Note that if
indexes = None, then W must have exactly two columns and this is equivalent
to indexes = [(0,1)].
:param list windows: An increasing list of breakpoints between the windows
to compute the statistic in.
:param str mode: A string giving the "type" of the statistic to be computed
Expand Down

0 comments on commit d442686

Please sign in to comment.