Skip to content

Support migrations in keep_intervals, delete_intervals, and trim - #1129

Merged
mergify[bot] merged 1 commit into
tskit-dev:mainfrom
awohns:keep_intervals_migrations
Feb 12, 2021
Merged

mergify[bot] merged 1 commit into
tskit-dev:mainfrom
awohns:keep_intervals_migrations

Conversation

@awohns

@awohns awohns commented Jan 23, 2021 •

Copy link
Copy Markdown
Member

Description

Adds support for running keep_intervals, delete_intervals, and trim on tree sequences that contain migrations. I've modified the python api for these functions to support migrations and written some tests. However, keep_intervals calls sort, and my implementation of sorting the migration table isn't worked out yet, I would appreciate any pointers, so to speak!

Addresses the following issues

Closes #1128. If sorting the migration table is worked out, would close #22, and could be modified to address #117

@awohns
awohns marked this pull request as draft January 23, 2021 02:01
@codecov

codecov Bot commented Jan 23, 2021 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (main@6fc67f8). Click here to learn what that means.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1129   +/-   ##
=======================================
  Coverage        ?   93.70%           
=======================================
  Files           ?       26           
  Lines           ?    21470           
  Branches        ?      904           
=======================================
  Hits            ?    20118           
  Misses          ?     1314           
  Partials        ?       38           
Flag Coverage Δ
c-tests 92.46% <ø> (?)
lwt-tests 92.97% <ø> (?)
python-c-tests 94.91% <100.00%> (?)
python-tests 98.63% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
python/tskit/tables.py 99.60% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6fc67f8...4a3567b. Read the comment docs.

@jeromekelleher

Copy link
Copy Markdown
Member

@awohns, the sort stuff is a can of worms so I've opened a separate PR to do it. Can you have a look at #1131 please? Hopefully you can just drop the last commit here once that's done and then merging will be straightforward.

@awohns

awohns commented Jan 23, 2021

Copy link
Copy Markdown
Member Author

Thanks @jeromekelleher. #1131 looks good to me, I added one small comment about documenting the sorting of the migration table, to be consistent with the other tables' documentation

@jeromekelleher

Copy link
Copy Markdown
Member

@awohns, this is ready to pick up again I think. We've merged support for sorting migrations.

@awohns
awohns force-pushed the keep_intervals_migrations branch from 7b7eebe to 7575104 Compare February 11, 2021 04:18
@awohns
awohns marked this pull request as ready for review February 11, 2021 05:02
@awohns
awohns force-pushed the keep_intervals_migrations branch from fbda6ea to cc1b874 Compare February 11, 2021 05:03
@awohns

awohns commented Feb 11, 2021

Copy link
Copy Markdown
Member Author

Ok, I've rolled back my C changes to sort and tests pass so I think this is ready for review!

@jeromekelleher jeromekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@jeromekelleher

Copy link
Copy Markdown
Member

@hyanwong, can you have a quick look over this please to see if there's anything we've missed?

Comment thread python/tskit/tables.py
2D numpy array with shape (N, 2), where N is the number of intervals.
:param bool simplify: If True, run simplify on the tables so that nodes
no longer used are discarded. (Default: True).
no longer used are discarded. Must be ``False`` if input tree sequence

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is only because simplify itself does not support migrations? So should we note to change this when #20 is fixed? Perhaps we should add a test of trim() with simplify=True on a ts with migrations, that is currently expected to fail, and comment at the top of the test that once it starts passing, we need to change the docs?

Comment thread python/tskit/tables.py
if (np.min(self.migrations.left) < np.min(self.edges.left)) and (
np.max(self.migrations.right) > np.max(self.edges.right)
):
raise ValueError(

@hyanwong hyanwong Feb 11, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can't we do this? I mean, we'd lose those migrations, right? But should we just issue a warning? Or instead should we tell the user how to work around it, e.g. "this would lose information, so you have to deliberately remove migrations outside the trimmed regions using delete_intervals([[trim_left, trim_right]]) first"?

@hyanwong

Copy link
Copy Markdown
Member

@hyanwong, can you have a quick look over this please to see if there's anything we've missed?

I don't know much about migrations, but this looks like a simple change to me. 2 very minor comments above. I guess I don't need to approve or anything, though.

@AdminBot-tskit
AdminBot-tskit force-pushed the keep_intervals_migrations branch from cc1b874 to 4a3567b Compare February 12, 2021 09:07
@mergify
mergify Bot merged commit 00c28c4 into tskit-dev:main Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for migrations in keep_intervals, delete_intervals, and trim sort_tables should sort migrations

3 participants