Skip to content

Add Demography.from_tree_sequence. - #1539

Merged
jeromekelleher merged 1 commit into
tskit-dev:mainfrom
jeromekelleher:demography-initial-state
Mar 17, 2021
Merged

jeromekelleher merged 1 commit into
tskit-dev:mainfrom
jeromekelleher:demography-initial-state

Conversation

@jeromekelleher

Copy link
Copy Markdown
Member

Closes #1528

WIP, but the basic stuff is there. Will need to figure out how to deal with metadata when appending to the population table.

@petrelharp, what do you think?

@codecov

codecov Bot commented Mar 15, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #1539 (91ae2c3) into main (ed2c222) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1539      +/-   ##
==========================================
- Coverage   91.36%   91.34%   -0.03%     
==========================================
  Files          23       23              
  Lines       10103    10148      +45     
  Branches     2119     2134      +15     
==========================================
+ Hits         9231     9270      +39     
- Misses        438      441       +3     
- Partials      434      437       +3     
Flag Coverage Δ
C 91.34% <100.00%> (-0.03%) ⬇️
python 98.61% <100.00%> (-0.16%) ⬇️

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

Impacted Files Coverage Δ
lib/util.h 100.00% <ø> (ø)
lib/msprime.c 85.76% <100.00%> (ø)
lib/util.c 98.05% <100.00%> (+0.01%) ⬆️
msprime/ancestry.py 98.24% <100.00%> (-1.16%) ⬇️
msprime/demography.py 99.46% <100.00%> (+0.01%) ⬆️

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 ed2c222...91ae2c3. Read the comment docs.

@grahamgower

Copy link
Copy Markdown
Member

In some cases, I think the user will have the demography that was used to simulate from_ts already. That should work already though, right? (But maybe there should be a test for this?)

@jeromekelleher

Copy link
Copy Markdown
Member Author

In some cases, I think the user will have the demography that was used to simulate from_ts already. That should work already though, right? (But maybe there should be a test for this?)

Yep, that should work fine. Definitely will be tests for that.

@jeromekelleher

Copy link
Copy Markdown
Member Author

Just added a couple of tests @grahamgower, works as you would expect when you don't provide a demography as a parameter.

Comment thread msprime/demography.py Resolved
@petrelharp

Copy link
Copy Markdown
Contributor

Looks good! Taking parameters (initial_size, growth_rate) from metadata seems like a big can of worms - e.g., that's the "initial size" at what time ago?

@jeromekelleher
jeromekelleher force-pushed the demography-initial-state branch 4 times, most recently from 8b90892 to 44df8da Compare March 16, 2021 19:18
@jeromekelleher

Copy link
Copy Markdown
Member Author

@petrelharp, any chance you could take a look at this and comment on how it's going? I didn't get a chance to finish it, but you'll see how it's going.

I've decided against allowing demography=None and no population_size when initial_state is specified I think - it's hard to imagine when this is actually a good idea. These are still in the code, I just convinced myself it's a bad idea while writing the docs.

Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread docs/ancestry.md Resolved
Comment thread tests/test_simulate_from.py Resolved
@petrelharp

Copy link
Copy Markdown
Contributor

Looks good! Only minor comments.

@jeromekelleher
jeromekelleher force-pushed the demography-initial-state branch from fed6949 to 3d8c0f8 Compare March 17, 2021 12:58
@jeromekelleher

Copy link
Copy Markdown
Member Author

I think this is ready to go - @grahamgower it would be great to get your eyes on this, if you can. I'm mainly trying to make it less easy to make mistakes.

There's a follow-up in #1546, but I'll let that go until this is merged as it'll be noisy.

@grahamgower grahamgower 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.

Looks excellent!

Comment thread msprime/demography.py Resolved
@jeromekelleher
jeromekelleher force-pushed the demography-initial-state branch from 4bad2b2 to 91ae2c3 Compare March 17, 2021 17:35
@jeromekelleher
jeromekelleher merged commit bb3de71 into tskit-dev:main Mar 17, 2021
@jeromekelleher
jeromekelleher deleted the demography-initial-state branch March 17, 2021 18:03
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.

sim_ancestry(initial_state=ts) does not use population names

3 participants