Skip to content

Modifying GNN to work for internal nodes #148

Closed

Description

@awohns

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

p = parent[u]

Activity

  1. jeromekelleher commented on Mar 17, 2019

    @jeromekelleher
    Member

    Can you come up with a simple example of this failing please @awohns?

  2. hyanwong commented on Mar 18, 2019

    @hyanwong
    Member

    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?

  3. hyanwong commented on Mar 18, 2019

    @hyanwong
    Member

    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]

  4. added a commit that references this issue on May 28, 2019
    a39f594
  5. hyanwong commented on May 28, 2019

    @hyanwong
    Member

    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]])
    
  6. jeromekelleher commented on May 29, 2019

    @jeromekelleher
    Member

    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.

  7. hyanwong commented on Jun 4, 2019

    @hyanwong
    Member

    Yes, I will do this.

  8. added a commit that references this issue on Jun 5, 2019
  9. added a commit that references this issue on Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions