profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/petrelharp/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

cggh/scikit-allel 215

A Python package for exploring and analysing genetic variation data

gbradburd/conStruct 28

method for modeling continuous and discrete population genetic structure

kr-colab/locator 25

deep learning prediction of geographic location from individual genome sequences

bodkan/slendr 12

Spatial simulations for population genetics in R & SLiM 🌍

jgallowa07/tsencode 5

This is the starting code for endcoding an msprime TreeSequence Object into a 3D array for ML and visualization purposes

kr-colab/spaceness 5

Space is the Place: Effects of Continuous Spatial Structure on Analysis of Population Genetic Data

atcg/cPWP 4

Program to infer pairwise pi among individuals using aligned short-read sequencing data.

push eventUO-Biostats/UO_ABS

peter

commit sha 15d6fbe50c77a4c080ebb0b2307fd02492645bbe

room number

view details

push time in a day

push eventUO-Biostats/UO_ABS

peter

commit sha 8042ec78923cd6e809ee4f9602a9b647a3f5e228

oh update

view details

push time in 2 days

push eventuo-applied-math/applied_math

peter

commit sha 4c0daf62e56f8a34bbc7bb8fbef766069fb9fe61

link

view details

push time in 2 days

push eventUO-Biostats/UO_ABS

peter

commit sha 7742d72ca15a55d0ac235acd4020280226837612

slides tweaks

view details

push time in 2 days

push eventUO-Biostats/UO_ABS

peter

commit sha 9978a791701a07038b2a103551a6b82575545802

week 1 slides

view details

push time in 2 days

push eventUO-Biostats/UO_ABS

peter

commit sha 06f010e01914d40918df7bc28d475c57228853fc

oh

view details

push time in 2 days

push eventUO-Biostats/UO_ABS

peter

commit sha de5d15396b7a34f59cff8d3127a496e182cf560b

class time

view details

push time in 2 days

push eventpopsim-consortium/stdpopsim

Maria Izabel Cavassim Alves

commit sha cdfb99b76e7a32b433da8d1747cd11a8ffdc7880

Adding DFE class

view details

Peter Ralph

commit sha 1cf504966c5c727b73f81125218808a2d0ddf6d1

Merge pull request #1002 from izabelcavassim/DFE_class Adding DFE class

view details

push time in 3 days

PR merged popsim-consortium/stdpopsim

Adding DFE class

Adding a DFE class to stdpopsim. The structure is similar to how DemographicModel class was built. This is the first attempt, and still not working properly. I need some help to integrate the stuff that is in ext/ to this new class. So we won't necessarily need to do stdpopsim.ext.MutationType(), to specify a given mutation type, for instance. Maybe @grahamgower can help me with that?

Thanks!

+496 -6

12 comments

11 changed files

izabelcavassim

pr closed time in 3 days

issue commentpopsim-consortium/stdpopsim

finalise the selection API

Let's do it in a separate PR.

grahamgower

comment created time in 3 days

push eventizabelcavassim/stdpopsim

Maria Izabel Cavassim Alves

commit sha cdfb99b76e7a32b433da8d1747cd11a8ffdc7880

Adding DFE class

view details

push time in 3 days

pull request commentpopsim-consortium/stdpopsim

Adding DFE class

Looks good (still)! I tidied up a few more loose ends, and will squash again.

izabelcavassim

comment created time in 3 days

push eventizabelcavassim/stdpopsim

peter

commit sha 7d98ff3d4e4b6fb9408bb53e9f4a69ba0dd07d8c

minor adjustments

view details

push time in 3 days

issue openedpopsim-consortium/stdpopsim

test that msprime will not run with a non-neutral contig

Right now you can simulate with a non-neutral DFE with msprime, and nothing errors. It should, and for this we probably need a contifg.is_neutral() method. I'm adding a test for this in #1002 (but skipping it).

created time in 3 days

push eventuo-applied-math/applied_math

peter

commit sha 8881268250cd03e357264bd0705ed17ef578eb7f

410/510

view details

push time in 3 days

issue openedMesserLab/SLiM

allow loading from treeSeq even when treeSeq isn't enabled?

Currently, trying to do sim.readFromPopulationFile() raises an error if you haven't done initializeTreeSeq(). Sometimes people want to run simulations without tree sequence recording, for speed, and so do things like

c.     Wrote a script to take the treesequence at time 0 and write a file in slim output

to move from a treeseq simulation to one without. However, I don't know of any reason that you shouldn't be able to load in a simulation from a tree sequence and yet not have tree sequence recording turned on? This would make it possible, for instance, to intiialize a giant simulation from an msprime simulation and run it without recording the tree sequence (for speed).

created time in 3 days

issue openedpopsim-consortium/stdpopsim

test all demographic models using SLiM

I'm not sure (and it's late) but I think that some of the demographic models currently produce errors in SLiM. TODO: check that they are being tested with SLiM and fix errors if any occur.

created time in 4 days

pull request commentpopsim-consortium/stdpopsim

Adding DFE class

I may have gotten the tests working - there seem to be some other slim-related errors for certain demographic models, but that's separate from this PR.

izabelcavassim

comment created time in 4 days

push eventizabelcavassim/stdpopsim

peter

commit sha f62d66c4a1205833fc2c2aba9f32a66f89107481

test fewer models and a few other tweaks

view details

push time in 4 days

PullRequestReviewEvent

Pull request review commentpopsim-consortium/stdpopsim

Adding DFE class

 def test_add_genomic_element_type(self):         contig.add_genomic_element_type(intervals2, [m1], [0.2])         assert len(contig.genomic_element_types) == 2         assert len(contig.mutation_types) == 2++    def test_add_DFE_errors(self):+        contig = stdpopsim.Contig.basic_contig(length=100)+        props = [0.3, 0.7]+        mt = [stdpopsim.ext.MutationType() for _ in props]+        # bad intervals+        dfe = stdpopsim.DFE(+            id="abc",+            description="test",+            long_description="test test",+            proportions=props,+            mutation_types=mt,+        )+        with pytest.raises(ValueError):+            contig.add_DFE(np.array([10, 20]), dfe)++    def test_add_DFE(self):+        contig = stdpopsim.Contig.basic_contig(length=100)+        contig.clear_genomic_mutation_types()+        props = [0.3, 0.7]+        mt = [stdpopsim.ext.MutationType() for _ in props]+        dfes = [+            stdpopsim.DFE(+                id=str(j),+                description="test",+                long_description="test test",+                proportions=props,+                mutation_types=mt,+            )+            for j in range(2)+        ]+        contig.add_DFE(intervals=np.array([[10, 30], [50, 100]]), DFE=dfes[0])+        contig.add_DFE(intervals=np.array([[30, 40]]), DFE=dfes[1])+        assert len(contig.genomic_element_types) == 2+        assert len(contig.mutation_types) == len(mt)+++class TestAll_DFE_Models:+    """+    Tests for registered simulation dfe models.+    """++    def test_non_empty(self):+        assert len(list(stdpopsim.all_dfes())) > 0++    @pytest.mark.parametrize("DFE", stdpopsim.all_dfes())+    def test_all_instances(self, DFE):+        assert len(DFE.id) > 0+        assert len(DFE.description) > 0+        assert len(DFE.long_description) > 0+        assert len(DFE.citations) > 0+++class TestDFE:+    def test_basic_DFE(self):+        desc = "test test"+        long_desc = "test test 🐢"+        for props in ([0.4, 0.6], [1.0, 0.0], [1.0], [1 / 3, 1 / 3, 1 / 3]):+            mt = [stdpopsim.ext.MutationType() for _ in props]+            dfe = stdpopsim.DFE(+                id="abc",+                description=desc,+                long_description=long_desc,+                proportions=props,+                mutation_types=mt,+            )+            assert dfe.id == "abc"+            assert dfe.description == desc+            assert dfe.long_description == long_desc+            for a, b in zip(props, dfe.proportions):+                assert a == b+            for a, b in zip(mt, dfe.mutation_types):+                assert a == b++    def test_DFE_defaults(self):+        m1 = stdpopsim.ext.MutationType()+        desc = "test test"+        long_desc = "test test 🐢"+        dfe = stdpopsim.DFE(+            id="abc",+            description=desc,+            long_description=long_desc,+            mutation_types=[m1],+        )+        assert isinstance(dfe.proportions, list)+        assert len(dfe.proportions) == 1+        assert dfe.proportions[0] == 1.0++    def test_printing_DFE(self, capsys):+        m1 = stdpopsim.ext.MutationType()+        desc = "test test"+        long_desc = "test test 🐢"+        dfe = stdpopsim.DFE(+            id="abc",+            description=desc,+            long_description=long_desc,+            mutation_types=[m1],+        )+        print(dfe)+        captured = capsys.readouterr()+        assert "DFE:\n" in captured.out+        assert "║" in captured.out+        assert "║  id               = abc\n" in captured.out++    def test_DFE_errors(self):+        m1 = stdpopsim.ext.MutationType()+        m2 = stdpopsim.ext.MutationType()+        for bad_props in [["abc"], 1.0, [1.0], [0.2, 0.4, 0.4]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=bad_props,+                    mutation_types=[m1, m2],+                )+        for bad_mut_types in ["abc", {}, [1.0, 2.0], [m1], m1, ["a", "b"]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=[0.6, 0.4],+                    mutation_types=bad_mut_types,+                )+        for bad_sums in [[-0.4, 0.5], [0.6, 0.8], [139487135987, 0.0], [0.2, 0.3]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=bad_sums,+                    mutation_types=[m1, m2],+                )+++class DFEModelTestMixin:+    """+    Mixin for testing specific models. Subclasses should extend+    this class and define the self.model (as the model instance).+    """++    # To be defined in subclasses.+    model = None++    def test_debug_runs(self):+        dbg = self.model.model.debug()+        dfe_model = self.dfe+        assert dfe_model+        assert dbg.num_epochs > 0++    @pytest.mark.filterwarnings("ignore:.*Zigzag_1S14.*:UserWarning")+    def test_simulation_runs(self):+        # With a recombination_map of None, we simulate a coalescent without+        # recombination in msprime, with madeup mutation rate.+        contig = stdpopsim.Contig.basic_contig(+            length=5000, mutation_rate=self.model.mutation_rate+        )+        contig.clear_genomic_mutation_types()+        contig.mutation_rate = 2.35e-8  # should I define one or use the model one?+        # adding dfe to the contig+        contig.add_DFE(+            intervals=np.array([[0, 5000]]),+            DFE=self.dfe,+        )++        # Generate vector with 2 samples for each pop with sampling enabled+        sample_count = []+        for p in self.model.populations:+            if p.allow_samples:+                sample_count.append(2)+            else:+                sample_count.append(0)+        samples = self.model.get_samples(*sample_count)+        engine = stdpopsim.get_engine("slim")+        ts = engine.simulate(+            self.model, contig, samples, slim_scaling_factor=10, slim_burn_in=10+        )++        mut_info = {}+        for mut in ts.mutations():+            for j, md in zip(+                mut.derived_state.split(","), mut.metadata["mutation_list"]+            ):+                if j not in mut_info:+                    mut_info[int(j)] = md++        num_nonneutral = sum([mut_info[j]["selection_coeff"] != 0.0 for j in mut_info])+        assert ts.num_populations == self.model.num_populations+        assert len(mut_info.keys()) > 0  # number of mutations+        assert num_nonneutral > 0  # nonneutral mutations+++class CatalogDFEModelTestMixin(DFEModelTestMixin):+    """+    Mixin for demographic models in the catalog.+    """++    def test_id_valid(self):+        assert utils.is_valid_dfe_model_id(self.dfe.id)+++qc_test_classes = []+for species in stdpopsim.all_species():+    for model in species.demographic_models:+        for dfe in species.dfes:

Hm - and, this won't test DFEs at all in species without demographic models. I'm replacing this with a generic model.

izabelcavassim

comment created time in 4 days

issue commentMesserLab/SLiM

"empty" chromosomes should not be in tree sequence, at least sometimes?

It's amazing how you tug on one string and it turns out to be connected to all the other strings, isn't it?

lol, yes. I just hope they don't get all tangled up.

petrelharp

comment created time in 4 days

Pull request review commentpopsim-consortium/stdpopsim

Adding DFE class

 def test_add_genomic_element_type(self):         contig.add_genomic_element_type(intervals2, [m1], [0.2])         assert len(contig.genomic_element_types) == 2         assert len(contig.mutation_types) == 2++    def test_add_DFE_errors(self):+        contig = stdpopsim.Contig.basic_contig(length=100)+        props = [0.3, 0.7]+        mt = [stdpopsim.ext.MutationType() for _ in props]+        # bad intervals+        dfe = stdpopsim.DFE(+            id="abc",+            description="test",+            long_description="test test",+            proportions=props,+            mutation_types=mt,+        )+        with pytest.raises(ValueError):+            contig.add_DFE(np.array([10, 20]), dfe)++    def test_add_DFE(self):+        contig = stdpopsim.Contig.basic_contig(length=100)+        contig.clear_genomic_mutation_types()+        props = [0.3, 0.7]+        mt = [stdpopsim.ext.MutationType() for _ in props]+        dfes = [+            stdpopsim.DFE(+                id=str(j),+                description="test",+                long_description="test test",+                proportions=props,+                mutation_types=mt,+            )+            for j in range(2)+        ]+        contig.add_DFE(intervals=np.array([[10, 30], [50, 100]]), DFE=dfes[0])+        contig.add_DFE(intervals=np.array([[30, 40]]), DFE=dfes[1])+        assert len(contig.genomic_element_types) == 2+        assert len(contig.mutation_types) == len(mt)+++class TestAll_DFE_Models:+    """+    Tests for registered simulation dfe models.+    """++    def test_non_empty(self):+        assert len(list(stdpopsim.all_dfes())) > 0++    @pytest.mark.parametrize("DFE", stdpopsim.all_dfes())+    def test_all_instances(self, DFE):+        assert len(DFE.id) > 0+        assert len(DFE.description) > 0+        assert len(DFE.long_description) > 0+        assert len(DFE.citations) > 0+++class TestDFE:+    def test_basic_DFE(self):+        desc = "test test"+        long_desc = "test test 🐢"+        for props in ([0.4, 0.6], [1.0, 0.0], [1.0], [1 / 3, 1 / 3, 1 / 3]):+            mt = [stdpopsim.ext.MutationType() for _ in props]+            dfe = stdpopsim.DFE(+                id="abc",+                description=desc,+                long_description=long_desc,+                proportions=props,+                mutation_types=mt,+            )+            assert dfe.id == "abc"+            assert dfe.description == desc+            assert dfe.long_description == long_desc+            for a, b in zip(props, dfe.proportions):+                assert a == b+            for a, b in zip(mt, dfe.mutation_types):+                assert a == b++    def test_DFE_defaults(self):+        m1 = stdpopsim.ext.MutationType()+        desc = "test test"+        long_desc = "test test 🐢"+        dfe = stdpopsim.DFE(+            id="abc",+            description=desc,+            long_description=long_desc,+            mutation_types=[m1],+        )+        assert isinstance(dfe.proportions, list)+        assert len(dfe.proportions) == 1+        assert dfe.proportions[0] == 1.0++    def test_printing_DFE(self, capsys):+        m1 = stdpopsim.ext.MutationType()+        desc = "test test"+        long_desc = "test test 🐢"+        dfe = stdpopsim.DFE(+            id="abc",+            description=desc,+            long_description=long_desc,+            mutation_types=[m1],+        )+        print(dfe)+        captured = capsys.readouterr()+        assert "DFE:\n" in captured.out+        assert "║" in captured.out+        assert "║  id               = abc\n" in captured.out++    def test_DFE_errors(self):+        m1 = stdpopsim.ext.MutationType()+        m2 = stdpopsim.ext.MutationType()+        for bad_props in [["abc"], 1.0, [1.0], [0.2, 0.4, 0.4]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=bad_props,+                    mutation_types=[m1, m2],+                )+        for bad_mut_types in ["abc", {}, [1.0, 2.0], [m1], m1, ["a", "b"]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=[0.6, 0.4],+                    mutation_types=bad_mut_types,+                )+        for bad_sums in [[-0.4, 0.5], [0.6, 0.8], [139487135987, 0.0], [0.2, 0.3]]:+            with pytest.raises(ValueError):+                _ = stdpopsim.DFE(+                    id="abc",+                    description="test test",+                    long_description="test test test test",+                    proportions=bad_sums,+                    mutation_types=[m1, m2],+                )+++class DFEModelTestMixin:+    """+    Mixin for testing specific models. Subclasses should extend+    this class and define the self.model (as the model instance).+    """++    # To be defined in subclasses.+    model = None++    def test_debug_runs(self):+        dbg = self.model.model.debug()+        dfe_model = self.dfe+        assert dfe_model+        assert dbg.num_epochs > 0++    @pytest.mark.filterwarnings("ignore:.*Zigzag_1S14.*:UserWarning")+    def test_simulation_runs(self):+        # With a recombination_map of None, we simulate a coalescent without+        # recombination in msprime, with madeup mutation rate.+        contig = stdpopsim.Contig.basic_contig(+            length=5000, mutation_rate=self.model.mutation_rate+        )+        contig.clear_genomic_mutation_types()+        contig.mutation_rate = 2.35e-8  # should I define one or use the model one?+        # adding dfe to the contig+        contig.add_DFE(+            intervals=np.array([[0, 5000]]),+            DFE=self.dfe,+        )++        # Generate vector with 2 samples for each pop with sampling enabled+        sample_count = []+        for p in self.model.populations:+            if p.allow_samples:+                sample_count.append(2)+            else:+                sample_count.append(0)+        samples = self.model.get_samples(*sample_count)+        engine = stdpopsim.get_engine("slim")+        ts = engine.simulate(+            self.model, contig, samples, slim_scaling_factor=10, slim_burn_in=10+        )++        mut_info = {}+        for mut in ts.mutations():+            for j, md in zip(+                mut.derived_state.split(","), mut.metadata["mutation_list"]+            ):+                if j not in mut_info:+                    mut_info[int(j)] = md++        num_nonneutral = sum([mut_info[j]["selection_coeff"] != 0.0 for j in mut_info])+        assert ts.num_populations == self.model.num_populations+        assert len(mut_info.keys()) > 0  # number of mutations+        assert num_nonneutral > 0  # nonneutral mutations+++class CatalogDFEModelTestMixin(DFEModelTestMixin):+    """+    Mixin for demographic models in the catalog.+    """++    def test_id_valid(self):+        assert utils.is_valid_dfe_model_id(self.dfe.id)+++qc_test_classes = []+for species in stdpopsim.all_species():+    for model in species.demographic_models:+        for dfe in species.dfes:

ah, I see! Nice work figuring this out. But, I don't think we need to test all combinations of DFE and model. I don't think we need to even test DFEs with non-generic models at all - they're pretty much completely separated?

izabelcavassim

comment created time in 4 days

PullRequestReviewEvent

Pull request review commentpopsim-consortium/stdpopsim

Adding DFE class

 def simulate(         if slim_burn_in < 0:             raise ValueError("slim_burn_in must be non-negative") -        if slim_scaling_factor != 1:+        if slim_scaling_factor > 1:

Hm, I'm not sure about this change - what prompted it?

izabelcavassim

comment created time in 4 days

PullRequestReviewEvent

issue commentpopsim-consortium/stdpopsim

Contig API to add genomic element types is not working

In #1002 we're adding an add_DFE method that we think probably ought to replace this.

mufernando

comment created time in 4 days

pull request commentpopsim-consortium/stdpopsim

Adding DFE class

add a DFE argument to contig.add_genomic_element_type that pulls the proportions and mutation types

Do we still want to do this? I think contig.add_DFE does everything we want here?

izabelcavassim

comment created time in 4 days

push eventuo-applied-math/applied_math

peter

commit sha 2ca257627079b847c64a7b3f18de8acec253898e

added schedule

view details

push time in 4 days

push eventuo-applied-math/applied_math

peter

commit sha 4b4acead1441b083852bfb1f862520d205be6f64

.

view details

push time in 4 days