{"id":31600299,"url":"https://github.com/robertfmath/population-genetic-modeling","last_synced_at":"2025-10-06T06:56:12.866Z","repository":{"id":220585538,"uuid":"559708994","full_name":"robertfmath/Population-Genetic-Modeling","owner":"robertfmath","description":"Provides functionality to model the genetics of biological populations and obtain population genetic statistics","archived":false,"fork":false,"pushed_at":"2022-10-30T23:14:05.000Z","size":669,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-02T22:33:19.708Z","etag":null,"topics":["modeling","population-genetics","python","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/robertfmath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-30T23:13:43.000Z","updated_at":"2024-02-02T22:33:21.511Z","dependencies_parsed_at":"2024-02-02T22:43:29.693Z","dependency_job_id":null,"html_url":"https://github.com/robertfmath/Population-Genetic-Modeling","commit_stats":null,"previous_names":["robertfmath/population-genetic-modeling"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/robertfmath/Population-Genetic-Modeling","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FPopulation-Genetic-Modeling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FPopulation-Genetic-Modeling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FPopulation-Genetic-Modeling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FPopulation-Genetic-Modeling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/robertfmath","download_url":"https://codeload.github.com/robertfmath/Population-Genetic-Modeling/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/robertfmath%2FPopulation-Genetic-Modeling/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278572004,"owners_count":26008686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["modeling","population-genetics","python","simulation"],"created_at":"2025-10-06T06:56:08.728Z","updated_at":"2025-10-06T06:56:12.857Z","avatar_url":"https://github.com/robertfmath.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Population Genetic Modeling\n\n## Description\n\nThis repository provides functionality to model the genetics of biological populations and obtain population genetic statistics.\n\n## Dependencies\n\n- NumPy\n- Matplotlib\n\nFor a full list of dependencies—both direct and transitive—please refer to the provided requirements.txt file.\n\n## Usage\n\nThere are two main source code files, both found in ```/src```: *population.py* and *drift_simulation.py*.\n\n### *population.py* \nProvides a Population class as well as various other functions that are related to biological populations. \n\n- **Population class**\n    - Attributes (only pfreq is required)\n        - p and q allele frequencies  \n        - AA, Aa, aa genotype frequencies  \n        - Heterozygosity (assumed to be Aa unless specified)  \n        - 2N  \n        - Mutation rate  \n        - Theta\n    - Methods\n        - Get H-W frequencies  \n        - Get fixation index\n        - Get theta-predicted heterozygosity\n        - Drift-selection balance, and drift-gene flow balance  \n        - Calculate probability of coalescence in discrete time\n        - Simulate drift  \n        - Population structure stats with another population  \n        - Calculate Future heterozygosity\n\n- **Other functions**\n    - Disequilibrium stats  \n    - Estimate Ne using census population sizes through time \n    - Solve Breeder's equation  \n    - Calculate mean fitness  \n    - Calculate exponential population growth  \n    - Calculate Fst and Nem in the infinite island model\n    - Calculate colony Fst in the metapopulation model\n\nExample code:\n\n```\n\u003e\u003e\u003e import population\n\u003e\u003e\u003e pop1 = population.Population(0.6, AAfreq=0.3, Aafreq=0.53, twoN=100, mutation_rate=0.01)\n\u003e\u003e\u003e pop1.pfreq\n0.6\n\u003e\u003e\u003e pop1.qfreq\n0.4\n\u003e\u003e\u003e pop1.twoN\n100\n\u003e\u003e\u003e pop1.get_hw_freqs()\n{'AA': 0.36, 'Aa': 0.48, 'aa': 0.16}\n\u003e\u003e\u003e pop1.get_fixation_index()\n-0.1\n\u003e\u003e\u003e pop1.theta\n4.0\n\u003e\u003e\u003e pop1.theta_hetero()\n0.8\n\u003e\u003e\u003e pop1.drift_sel_balance(selection=0.03)\n'4Nes: 12.0; Selection is stronger than drift.'\n\u003e\u003e\u003e pop1.drift_geneFlow_balance(m=0.04)\n'4Nem: 16.0; Gene flow is stronger than drift.'\n\u003e\u003e\u003e pop1.prob_coalescence_discrete(t=5)\n0.0096\n\u003e\u003e\u003e pop2 = population.Population(0.3, AAfreq=0.4, Aafreq=0.35, twoN=100)\n\u003e\u003e\u003e pop1.get_mix_stats(pop2)\n{'F_IS': 0.02, 'F_ST': 0.09, 'F_IT': 0.11}\n\u003e\u003e\u003e pop1.sim_selection(wAA=1, wAa=0.98, waa=0.96)\n'Delta p: 0.0049’\n\u003e\u003e\u003e pop1.pfreq\n0.6049\n\u003e\u003e\u003e pop1.sim_drift(gens=100)\n\u003e\u003e\u003e pop1.pfreq\n1\n\u003e\u003e\u003e pop1.future_hetero(t=5)\n0.5040\n\u003e\u003e\u003e population.get_diseq_stats(0.5, 0, 0, 0.5)\n'D: 0.25'\n\u003e\u003e\u003e population.get_diseq_stats(0.5, 0, 0, 0.5, p1=0.5, p2=0.5)\n'D: 0.25; r2: 1.00'\n\u003e\u003e\u003e population.Ne_through_time([100, 10, 100])\n25.0\n\u003e\u003e\u003e population.solve_breeders(R=50, S=100)\n'h2: 0.5'\n\u003e\u003e\u003e population.inf_island_fst(Ne=100, m=0.03)\n0.07692\n\u003e\u003e\u003e population.inf_island_Nem(Fst=0.09)\n2.5278\n\u003e\u003e\u003e population.colony_fst(Fst=0.06, k=4, phi=0.2)\n0.1355\n\u003e\u003e\u003e population.exp_growth(n0=20, r=1.05, t=10)\n726310\n\u003e\u003e\u003e population.get_mean_fitness(0.6, wAA=1, wAa=0.98, waa=0.96)\n0.984\n```\n### *drift_simulation.py*\nSimulates drift in replicate populations/loci of three different sizes. The user can set these sizes, along with the number of replicates, generations, and starting allele frequency.\n \nExample:\n\n![drift simulation output](/images/drift_simulation_output.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfmath%2Fpopulation-genetic-modeling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frobertfmath%2Fpopulation-genetic-modeling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frobertfmath%2Fpopulation-genetic-modeling/lists"}