Repository navigation
Tree num lineages - #2422
Tree num lineages#2422
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2422 +/- ##
==========================================
+ Coverage 93.34% 93.36% +0.01%
==========================================
Files 28 28
Lines 27006 27052 +46
Branches 1253 1253
==========================================
+ Hits 25209 25256 +47
+ Misses 1763 1762 -1
Partials 34 34
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
42d5e31 to
b9c1a78
Compare
|
Looks good @jeromekelleher! And yes then for the test we do k = 1 + t.num_lineages(t.time(m.node)) or something (the number of lineages just below the node carrying the mutation, but we shouldn't count all of the lineages if there is a polytomy - so take number of lineages just above + 1). |
|
@petrelharp - are you happy with this definition? |
|
Looks good to me. I could imagine not wanting the roots included, but we have zero use cases for this in the many-disconnected-trees case, so no need to complexify this. (that could be an option added later if necessary) One question: will this skip missing samples? (i.e., if a sample is missing it's not included in the roots, right?) |
b9c1a78 to
8228392
Compare
Ah, hmm, great point. Actually no, it'll consider these are roots in the same way (see the test I just added in 8228392), so you'll count missing a node representing missing data as a lineage. On reflection, that probably seems right? The lineage/missing sample does exist, we just don't know anything about it. |
8228392 to
2e029b6
Compare
|
I don't think that's right - we don't know anything about it, so it might coalesce into the existing trees more recently than |
|
Hmm - so should we just count the number of edges intersecting with time |
|
That seems okay to me, yes? |
|
OK, I'll update. Better to have a simpler definition! |
Modify the definition to be the number of edges intersecting with t.
2e029b6 to
757029a
Compare
|
@petrelharp - updated to simpler definition. |
Adds the
Tree.num_lineages(t)method as discussed in #386 and elsewhere.The definition is slightly tricky because we're not just counting the edges that intersect with a given time/space coordinate, but we're also counting the number of roots. It seems logical that the number of lineages in a tree for any time greater than the root time should be 1 (assuming a single root) rather than 0.
I didn't bother adding the vector form (where t can be a sorted list of values) because it's a lot more work, and we can add it later if we want. This will be efficient enough for most purposes I think.
@savitakartik, @a-ignatieva - we should now be able to define the Relate statistic p-value easily in terms of this, right?