Repository: popsim-consortium/stdpopsim (language: python)

Issue:
add 'best' DFE from Kyriazis et al
The paper https://www.biorxiv.org/content/10.1101/2022.08.12.503792v1 presents a "best" DFE they recommend using for a variety of other species. This is a DFE estimated from humans. We should put this one in!
add discretized h-s relationship DFE
We have discussed using the "uniform" DFE (from #1481) to add a DFE with a h-s relationship; Kirk says on Slack that 
> here's the reference for the discritized h-s relationship: https://www.biorxiv.org/content/10.1101/2022.08.12.503792v1.supplementary-material
and that
> The "best available" (also sometimes called "this paper") model is the one that I would recommend using....it's implemented in this SLiM script: https://github.com/ckyriazis/simulations_review/blob/main/simulation_scripts/SFS_scripts/SFS_newDFE_040422.slim

That's for humans; there's also an h-s relationship estimated in arabidopsis, but from the meeting:
> Linh: would this DFE be for human and Arabidopsis?
> Kirk: probably just human? Chris fit h/s distribution from Arabidopsis and tired to fit to human but didn't fit well. Too many weak recessive deleterious mutations present in the data relative to the model. Models that fit better have more additive, weakly del mutations. The model that is posted to slack is fit specifically to humans, checked on 1kg SFS- reasonable fit, also reasonable fit to estimated human inbreed load.


Discussion / hints:
From the meeting: Should this be a "generic" DFE or under HomSap? (ping @ckyriazis?)

Note that to do this you'll need to use #1488.
the way we present it in our paper is that it could be used as a "generic DFE" for species that dont have a DFE (since some evidence suggests that the DFE doesnt vary a ton, at least across mammals) but in reality it is pretty much a human DFE estimated from human data. so my vote would be to add it to HomSap
I can add more about the somewhat hacky way of implementing an h-s relationship here - my experience is that implementing an h-s relationship with the mutationEffect() callbacks in SLiM (e.g., see lines 67-75 [here](https://github.com/ckyriazis/simulations_review/blob/main/simulation_scripts/SFS_scripts/SFS_kardos_040422.slim)) is super slow, so Ben helped me think of a way to speed this up by creating different mutation types and discretizing the gamma distribution as seen in the script above. 

There may still be a better way of doing this but this is the solution I've converged on for now! Happy to discuss further if anything isnt clear. 
The approach makes perfect sense. If I run into issues I'll ping you. Thanks!
As I put on slack, to do this we need piecewise-Gamma, not piecewise-Uniform to do: https://github.com/ckyriazis/simulations_review/blob/main/simulation_scripts/SFS_scripts/SFS_newDFE_040422.slim . So, now I'm wondering whether we should

1.    add a "script" mutation type, that lets the user put in whatever SLiM code (this is how some DFEs work under the hood; this would just expose this in the DFE-creation API)
2.   add a "truncated gamma" mutation type with two extra parameters, the min and max
3.   extend the mutation type API to allow for a discretized h-s relationship, implemented as Chris has done in the SLiM code; so you could do Chris' model like so:
```
MutationType(distribution_type="g", distribution_args=[-0.013, 0.186], dominance_coeff=[0.45, 0.2, 0.05, 0.0], hs_breaks=[-0.001, -0.01, -0.1])
```
(where hs_breaks would need to be a list of lenth one shorter than dominance_coeff and indicates the bins of s that get different values of h)I'm leaning towards (3), although it'll be a bit more work.
Note that a problem for (1) is: how would we QC it?

Fix patch:
diff --git a/stdpopsim/catalog/HomSap/dfes.py b/stdpopsim/catalog/HomSap/dfes.py
index ee97bc4bc..83e1254a5 100644
--- a/stdpopsim/catalog/HomSap/dfes.py
+++ b/stdpopsim/catalog/HomSap/dfes.py
@@ -147,3 +147,56 @@ def _HuberLogNormalDFE():
 
 
 _species.add_dfe(_HuberLogNormalDFE())
+
+
+def _KyriazisDFE():
+    id = "Mixed_K23"
+    description = "Deleterious Gamma DFE with additional lethals"
+    long_description = """
+    The DFE estimated from human data recommended in Kyriazis et al.
+    (2023), https://doi.org/10.1086/726736, for general use.
+    This model is similar to the Kim et al. (2017) DFE based on human
+    genetic data, modified to include the dominance distribution from
+    Henn et al. (2016).
+    The model is also augmented with an additional proportion of 0.3% of
+    recessive lethals, based on the analysis of Wade et al. (2023).
+    """
+    citations = [
+        stdpopsim.Citation(
+            author="Kyriazis et al.",
+            year=2023,
+            doi="https://doi.org/10.1086/726736",
+            reasons={stdpopsim.CiteReason.DFE},
+        )
+    ]
+    neutral = stdpopsim.MutationType()
+    gamma_mean = -0.0131
+    gamma_shape = 0.186
+    coefs = [0.45, 0.2, 0.05, 0]
+    breaks = [0.001, 0.01, 0.1]
+    gamma = stdpopsim.MutationType(
+        dominance_coeff_list=coefs,
+        dominance_coeff_breaks=breaks,
+        distribution_type="g",  # gamma distribution
+        distribution_args=[gamma_mean, gamma_shape],
+    )
+    lethal = stdpopsim.MutationType(
+        distribution_type="f",  # fixed value
+        distribution_args=[-1],  # fitness in SLiM for homozygotes is multiiplied by 1+s
+        dominance_coeff=0,
+    )
+    proportion_deleterious = 2.31 / (1 + 2.31)
+    lethal_prop = proportion_deleterious * 0.003  # 0.3% lethals
+    gamma_prop = proportion_deleterious - lethal_prop
+    neutral_prop = 1 - proportion_deleterious
+    return stdpopsim.DFE(
+        id=id,
+        description=description,
+        long_description=long_description,
+        mutation_types=[neutral, gamma, lethal],
+        proportions=[neutral_prop, gamma_prop, lethal_prop],
+        citations=citations,
+    )
+
+
+_species.add_dfe(_KyriazisDFE())


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 7210b75f2..770b06160 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -23,7 +23,6 @@ jobs:
       CONDA_ENV_NAME: stdpopsim
       OS: ${{ matrix.os }}
       PYTHON: ${{ matrix.python }}
-
     steps:
       - name: cancel previous runs
         uses: styfle/cancel-workflow-action@0.6.0
@@ -46,10 +45,10 @@ jobs:
 
       - name: cache conda
         id: cache
-        uses: actions/cache@v2
+        uses: actions/cache@v3
         env:
           # Increase this to reset the cache if the key hasn't changed.
-          CACHE_NUM: 4
+          CACHE_NUM: 5
         with:
           path: |
             ${{ steps.find-conda.outputs.CONDA }}/envs/${{ env.CONDA_ENV_NAME }}