You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The referenced line should be p=u if we want GNN to work for internal nodes. As it is now, the code automatically jumps up to the parent of u when looking for v
I've been chatting about this with Wilder. It depends a bit on what you expect a "nearest neighbour" to mean. Something like this gives an example:
> ts = msprime.simulate(4, random_seed=123)
> print(ts.first().draw(format="unicode"))
6
┏━┻━┓
┃ 5
┃ ┏━┻┓
┃ ┃ 4
┃ ┃ ┏┻┓
2 0 1 3
> set1 = [1,3]
> set2 = [0,2]
> ts.genealogical_nearest_neighbours([4],[set1, set2])
> # In this case the closest relatives to 4 are its immediate descendants, 1 and 3
> # so we might expect the GNN to be entirely in the first set (i.e. [1,0])
> ts.genealogical_nearest_neighbours([4],[set1, set2])
array([[0.66666667, 0.33333333]])
> # this is more like what we expect for "closest relatives"
> ts.genealogical_nearest_neighbours([3],[set1, set2])
array([[1., 0.]])
I guess it depends if by "neighbour" you also mean descendant. I prefer the term "genetic closest relatives", FWIW. But I think "GNN" is a Gil-ism?
By the way, there is another small issue with the GNN calculation: if the focal node is not in any of the reference sets, then we probably shouldn't define v as we do in the paper, which says "v is the first node in t on the path to root from u such that C^t_v > 1". Instead in this case we should use C^t_v > 0. Or to put it more generally, the condition for C^t_v should use the Iversonian condition from the GNN definition in the paper.
The original issue flagged up here isn't solved - I think the issue probably needs reopening or addressing.
> ts = msprime.simulate(4, random_seed=123)
> print(ts.first().draw(format="unicode"))
6
┏━┻━┓
┃ 5
┃ ┏━┻┓
┃ ┃ 4
┃ ┃ ┏┻┓
2 0 1 3
> set1 = [1,3]
> set2 = [0,2]
> # In the case below the closest relatives to 4 are its immediate descendants, 1 and 3
> # so we might expect the GNN to be entirely in the first set (i.e. [1,0])
> ts.genealogical_nearest_neighbours([4],[set1, set2])
array([[0.66666667, 0.33333333]])
Ah, I see. Can you take this up and make a PR with the proposed changes please @awohns and @hyanwong? #184 should give you a good guide on where things need changing.
Activity
jeromekelleher commentedon Mar 17, 2019
Can you come up with a simple example of this failing please @awohns?
hyanwong commentedon Mar 18, 2019
I've been chatting about this with Wilder. It depends a bit on what you expect a "nearest neighbour" to mean. Something like this gives an example:
I guess it depends if by "neighbour" you also mean descendant. I prefer the term "genetic closest relatives", FWIW. But I think "GNN" is a Gil-ism?
hyanwong commentedon Mar 18, 2019
By the way, there is another small issue with the GNN calculation: if the focal node is not in any of the reference sets, then we probably shouldn't define v as we do in the paper, which says "v is the first node in t on the path to root from u such that C^t_v > 1". Instead in this case we should use C^t_v > 0. Or to put it more generally, the condition for C^t_v should use the Iversonian condition from the GNN definition in the paper.
C^t_v > [u∈U^K_j=1 R_j]
Updated GNN stat to use new definition.
hyanwong commentedon May 28, 2019
The original issue flagged up here isn't solved - I think the issue probably needs reopening or addressing.
jeromekelleher commentedon May 29, 2019
Ah, I see. Can you take this up and make a PR with the proposed changes please @awohns and @hyanwong? #184 should give you a good guide on where things need changing.
hyanwong commentedon Jun 4, 2019
Yes, I will do this.
Address tskit-dev#148
Merge pull request #197 from hyanwong/GNN-for-internal-nodes