Skip to content
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

graph equality that ignores epoch and migration subdivisions #333

Open
grahamgower opened this issue Jun 19, 2021 · 2 comments
Open

graph equality that ignores epoch and migration subdivisions #333

grahamgower opened this issue Jun 19, 2021 · 2 comments

Comments

@grahamgower
Copy link
Member

For epochs the idea would be to make sure the demes are "equal" in the examples below, by checking equality of sizes (and other attributes) over the demes' lifetimes rather than mandating equal numbers of epochs each with equal attribute values. The below example is obvious from visual inspection, but if you do the same with exponentially-changing epochs its less obvious! I haven't really thought through the best way of achieving this. Maybe take the union of each deme's epoch end times and split epochs for each deme at all the time points? Or instead of splitting epochs, just check deme sizes for a few (5?) evenly spaced times in each interval.

demes:
- name: A
  epochs:
  - start_size: 100
demes:
- name: A
  epochs:
  - {start_size: 100, end_time: 50}
  - {start_size: 100, end_time: 0}

And similarly for comparing migrations, the following three examples should be "equal". We could just compare resulting migration matrices here.

migrations:
 - {demes: [A, B], start_time: 100, end_time: 0, rate: 1e-4}
migrations:
 - {demes: [A, B], start_time: 100, end_time: 50, rate: 1e-4}
 - {demes: [A, B], start_time: 50, end_time: 0, rate: 1e-4}
migrations:
 - {source: A, dest: B, start_time: 100, end_time: 0, rate: 1e-4}
 - {source: B, dest: A, start_time: 100, end_time: 0, rate: 1e-4}
@jeromekelleher
Copy link
Member

What's the use-case for this, out of interest?

@grahamgower
Copy link
Member Author

I can think of two:

  • msprime to_demes()/from_demes() round trip tests. Hypothesis can generate examples with consecutive epochs (or migrations) that have identical parameters. These are merged during conversion back and forth (which is reasonable).
  • demes-slim tests demes sizes are set correctly by running a simulaiton and printing deme sizes in each generation. It's fairly easy to parse this output in python and construct a new demes graph, where each deme has 1 epoch per generation (deduplicated slightly, for consecutive epochs of constant-size). It would be easiest to just do a graph equality check at this point.

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

No branches or pull requests

2 participants