-
Notifications
You must be signed in to change notification settings - Fork 79
Implement keep_unary_in_individuals in Python #1190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2368,12 +2368,13 @@ def wf_sim_with_individual_metadata(self): | |
| 9, | ||
| 10, | ||
| seed=1, | ||
| deep_history=True, | ||
| deep_history=False, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't thought throught he implications of changing this for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Erm, not sure why should this make a difference? We still shuffle the individuals and check that they are (a) shuffled and (b) the original individual ids correspond.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But perhaps I'm not understanding something?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why change the default here? Seems gratuitous to me.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See below. If we want to check that all nodes have an individual, and all the individuals point to their correct parents, then we can't include the deep history nodes, which have no individuals (and also the nodes at the top of the WF generated simulation will not have the correct parents). I.e. if we have a deep history, we (almost by definition) cannot fully map the trees onto the individuals pedigree. It seemed worth testing that we were capturing all of the genetic pedigree in the individuals.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (yan has thought this over) |
||
| initial_generation_samples=False, | ||
| num_loci=5, | ||
| record_individuals=True, | ||
| ) | ||
| assert tables.individuals.num_rows > 50 | ||
| assert np.all(tables.nodes.individual >= 0) | ||
| individuals_copy = tables.copy().individuals | ||
| tables.individuals.clear() | ||
| tables.individuals.metadata_schema = tskit.MetadataSchema({"codec": "json"}) | ||
|
|
@@ -2404,6 +2405,26 @@ def test_individual_parent_mapping(self, wf_sim_with_individual_metadata): | |
| ) | ||
| assert set(tables.individuals.parents) != {tskit.NULL} | ||
|
|
||
| def verify_complete_genetic_pedigree(self, tables): | ||
| ts = tables.tree_sequence() | ||
| for edge in ts.edges(): | ||
| child = ts.individual(ts.node(edge.child).individual) | ||
| parent = ts.individual(ts.node(edge.parent).individual) | ||
| assert parent.id in child.parents | ||
| assert parent.metadata["original_id"] in child.metadata["original_parents"] | ||
|
|
||
| def test_no_complete_genetic_pedigree(self, wf_sim_with_individual_metadata): | ||
| tables = wf_sim_with_individual_metadata.copy() | ||
| tables.simplify() # Will remove intermediate individuals | ||
| with pytest.raises(AssertionError): | ||
| self.verify_complete_genetic_pedigree(tables) | ||
|
|
||
| def test_complete_genetic_pedigree(self, wf_sim_with_individual_metadata): | ||
| for params in [{"keep_unary": True}, {"keep_unary_in_individuals": True}]: | ||
| tables = wf_sim_with_individual_metadata.copy() | ||
| tables.simplify(**params) # Keep intermediate individuals | ||
| self.verify_complete_genetic_pedigree(tables) | ||
|
|
||
| def test_shuffled_individual_parent_mapping(self, wf_sim_with_individual_metadata): | ||
| tables = wf_sim_with_individual_metadata.copy() | ||
| tsutil.shuffle_tables( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.