diff --git a/book/_toc.yml b/book/_toc.yml index 833da68..a2edb77 100644 --- a/book/_toc.yml +++ b/book/_toc.yml @@ -16,6 +16,9 @@ parts: - file: markdown/kingman_coalsecent/mutation_frequencies - file: markdown/kingman_coalsecent/expectations - file: markdown/kingman_coalsecent/distributions + - caption: Diffusion models + chapters: + - file: markdown/diffusion/sfs_selection - caption: Linked selection chapters: - file: markdown/classic_selection_drift/sweep_from_new_mutation diff --git a/book/markdown/diffusion/sfs_selection.md b/book/markdown/diffusion/sfs_selection.md new file mode 100644 index 0000000..698282b --- /dev/null +++ b/book/markdown/diffusion/sfs_selection.md @@ -0,0 +1,39 @@ +--- +jupytext: + formats: md:myst + text_representation: + extension: .md + format_name: myst +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# Mutation frequencies under selection (interactive Python) + +This notebook requires Binder for the interactive features to function. +See {ref}`here ` for more information. + +This applet uses [moments](https://moments.readthedocs.io) {cite:p}`Jouganous2017-tg` to calculate the site-frequency spectrum in a sample of size 20 as a function of $\gamma = 2N_es$, the scaled strength of selection. + +```{code-cell} python +import holoviews as hv +import moments + +hv.extension('bokeh') + +def fs_negative_selection(gamma): + fs_neg = moments.Spectrum( + moments.LinearSystem_1D.steady_state_1D(20, gamma=gamma) + )[1:-1] + b = hv.Histogram(([int(i)+1 for i in range(20)], fs_neg)) + b = b.redim(y=hv.Dimension('y',range=(0, 1.1*fs_neg.max()))) + b = b.opts(xlabel="Sample frequency", ylabel="Density") + return b + +kdims = [hv.Dimension('gamma',range=(-10, 10), step=1, default=0)] +fsplot = hv.DynamicMap(fs_negative_selection, + kdims=kdims).opts(framewise=True, width=500) +fsplot +``` diff --git a/book/references.bib b/book/references.bib index f2b80ec..6d64e01 100644 --- a/book/references.bib +++ b/book/references.bib @@ -106,7 +106,10 @@ @ARTICLE{Jouganous2017-tg keywords = "demographic inference; diffusion approximation; joint allele frequency spectrum; moments equations;polygenic\_inference\_R01;fwdpy11\_manual;popgen-course-material;Stehany", - language = "en" + language = "en", + issn = "0016-6731, 1943-2631", + pmid = "28495960", + pmc = "PMC5500150" } @ARTICLE{Kreitman1983-xr, diff --git a/requirements.txt b/requirements.txt index 188b6e4..134ab0c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ matplotlib numpy msprime==1.0.1 pandas +git+https://bitbucket.com/simongravel/moments