question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add individual statistics (eg heterozygosity)

See original GitHub issue

Something like

def individual_heterozygosity(ts, ind):
   ts.pairwise_diversity(ind.nodes)

should do it - very simple, but we want to make it easy and natural for people to deal with individuals.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:23 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
castedocommented, Oct 31, 2020

So wrapping up on the scope of this:

  • A) add function(s) in the Python API with “heterozygosity” in the name

With @petrelharp’s observed_heterozygosity Python example, I’ve got a great specification for A), thanks! The name is unambiguous and matches nicely and in an analogous way to all the other stats functions.

  • A.i) make sure works for non-autosomal chromosome pairs (e.g. X&Y, W&Z)

Handling sex chromosomes is way out of scope right now. There are challenging issues in trying to deal with this and I’ll not worry about.

  • B) define and code a function which generalizes heterozygosity to non-diploid species

“observed heterozygosity” has a consistent meaning in the field (I think, I hope!) and @petrelharp’s clatification is a totally logical extension of it and NaN is the value for monoploids. (As a side note, this definition of heterozygosity seems sensible for diploids, because it has a max value of 1. But it seem wonky to me to use it rather than ‘gene diversity’ (see #961), as a statistic to use across many types of ploidy. Just a sort of esthetic personal reaction.)

  • C) add function(s) in the Python API with “F_IT” and “F_IS” in the name

Hammer out the details in (or after) #858 and make a separate GitHub issue to track implementing F_IT and F_IS.

  • D) enhance documentation and Python API to show how many individual-based statistics can be achieved with “efficient building blocks” of the API

This is too hard to hash out now in Github issues. More appropriate for brainstorming face-(to-screen-to-)face and/or after all this other stuff become more clear.

1reaction
petrelharpcommented, Nov 21, 2022

As this is showing up in the SLiM list, here’s how to compute individual heterozygosities:

ts.diversity([i.nodes for i in ts.individuals()])
Read more comments on GitHub >

github_iconTop Results From Across the Web

Pop Ecol Lect 35
Heterozygosity is one of the best ways to approach the analysis of differences among populations. We will use heterozygosities as the basis for...
Read more >
21 Genetic Structure - Applied Population Genetics
This is the expected heterozygosity if all the data were merged and mating as a single panmictic population. This parameter is estimated as...
Read more >
Heterozygosity Ratio, a Robust Global Genomic Measure of ...
CHARACTERIZING genetic diversity across individuals and populations is ... Data set. To examine the population diversity of the heterozygosity ratio, ...
Read more >
Statistical Analysis of Heterozygosity Data - JSTOR
certain of detecting them. In addition, it is emphasized that, for small numbers of loci (<25), the statistical detection of differences of interesting ......
Read more >
Measures of genetic diversity
of our molecular study with other types of data (e.g. geographical). In the slide, Ind1, Ind2, … may represent, instead of individuals, populations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found