tskit: Sample_sets incorrect in genetic_relatedness_matrix
In #2823 we added support for the genetic_relatedness_matrix function as a follow-up usage of divergence_matrix using sample sets. This doesn’t work when the sample_sets have a length > 1. It’s not clear what the problem is, but it’s something to do with the conversion of the divergence matrix into the GRM via the normalisation function (currently kludged to observationally work with single-sample sets)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (16 by maintainers)
Commits related to this issue
- divmat works for sample sets; closes #2888 — committed to mmosmond/tskit by petrelharp 2 years ago
- divmat works for sample sets; closes #2888 lint changelog apply @jeromekelleher comments lint a few more low-level tests one more test — committed to mmosmond/tskit by petrelharp 2 years ago
- Adding a centre=False option to genetic_relatedness statistic (#1623) rebase of @mmsomond's previous commits to add centered option to genetic_relatedness initialize all nodes in branch stats; close... — committed to hfr1tz3/tskit by mmosmond 2 years ago
I don’t really have an opinion on how the stat should be defined, but I think it’s fine to change change older definitions if we like - they haven’t been around for that long, and I doubt many people are using them.
Okay - the behavior observed above is expected, since recall that diversity and divergence are defined “without replacement”, e.g. (docs for diversity)
and also (docstring for divergence_matrix)
So, the diagonal of
D_i_altas computed above should be multiplied by 2 since it’s diploids; more generally theith diagonal it should be multiplied byn[i]/(n[i]-1)ifn[i]is the size of theith sample set.I’ll figure out what’s going on in the code and tidy things up.