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

Generated catalog figures for each published demographic model #1034

Merged
merged 3 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions docs/_ext/speciescatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sphinx.util import logging

import stdpopsim
import os

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -401,6 +402,25 @@ def model_section(self, species, model):
section += self.model_parameter_table(species, model)
return [target, section]

def model_image(self, species, model):
import demesdraw
import matplotlib.pyplot as plt
mid = self.get_demographic_model_id(species, model)
_, ax = plt.subplots(1, 1, figsize=(4, 4))
# Conversion into demes object for easier plotting
graph = model.model.to_demes()
demesdraw.tubes(graph, ax=ax);
aabiddanda marked this conversation as resolved.
Show resolved Hide resolved
ax.set_title(f"{model.id}", fontsize=10)
ax.set_xticklabels([p.name for p in model.populations],
rotation=45, ha='right', rotation_mode="anchor", fontsize=10)
ax.set_ylabel('Time (generations)', fontsize=10)
os.system(f"mkdir -p parameter_images/{species.id}/")
aabiddanda marked this conversation as resolved.
Show resolved Hide resolved
img_name = f"parameter_images/{species.id}/{mid}.png"
plt.tight_layout()
plt.savefig(img_name, dpi=150, bbox_inches='tight')
aabiddanda marked this conversation as resolved.
Show resolved Hide resolved
section = nodes.image(uri=img_name)
return section

def run(self):
species = stdpopsim.get_species(self.arguments[0])
sid = f"sec_catalog_{species.id}"
Expand All @@ -427,6 +447,7 @@ def run(self):
models_section += self.models_table(species)
for i, model in enumerate(species.demographic_models):
models_section += self.model_section(species, model)
models_section += self.model_image(species, model)
if i < len(species.demographic_models) - 1:
models_section += nodes.transition()
section += models_section
Expand Down
2 changes: 1 addition & 1 deletion docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ message:
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

**DO NOT LISTEN TO GIT IN THIS CASE!** Git is giving you is **terrible advice**
**DO NOT LISTEN TO GIT IN THIS CASE!** Git is giving you **terrible advice**
which will mess up your branch. What we need to do is replace the state of
the branch ``topic_branch_name`` on your fork on GitHub (the ``upstream`` remote)
with the state of your local branch, ``topic_branch_name``. We do this
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies:
- msprime
- scikit-allel
- matplotlib
- demesdraw
- slim
# load the stdpopsim Github repository as a library using pip
- pip:
Expand Down
2 changes: 2 additions & 0 deletions requirements/CI/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ numpy==1.21.2
scikit-allel==1.3.5
zarr==2.10.0
biopython==1.79
demes==0.1.2
demesdraw==0.1.4
2 changes: 2 additions & 0 deletions requirements/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ numpy
scikit-allel
zarr>=2.4
biopython
demes==0.1.2
demesdraw==0.1.4
2 changes: 1 addition & 1 deletion stdpopsim/catalog/HomSap/demographic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# population definitions that are reused.
_yri_population = stdpopsim.Population(
id="YRI", description="1000 Genomes YRI (Yorubans)"
id="YRI", description="1000 Genomes YRI (Yoruba)"
)
_ceu_population = stdpopsim.Population(
id="CEU",
Expand Down