-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Billyzhang1229/feature/maximum_likelihood
Likelihood Calculation Felsenstein
- Loading branch information
Showing
12 changed files
with
576 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"import sys\n", | ||
"\n", | ||
"import msprime\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"# import local phylokit modules\n", | ||
"phylokit_path = os.path.abspath(os.path.join(os.pardir))\n", | ||
"if phylokit_path not in sys.path:\n", | ||
" sys.path.append(phylokit_path)\n", | ||
"\n", | ||
"import phylokit as pk" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def simulate_ts(num_samples, sequence_length, mutation_rate, seed=1234):\n", | ||
" tsa = msprime.sim_ancestry(\n", | ||
" num_samples, sequence_length=sequence_length, ploidy=1, random_seed=seed\n", | ||
" )\n", | ||
" return msprime.sim_mutations(tsa, rate=mutation_rate, random_seed=seed)\n", | ||
"\n", | ||
"def create_mutation_tree(num_samples, sequence_length, mutation_rate, seed=1234):\n", | ||
" ts_in = simulate_ts(num_samples, sequence_length, mutation_rate, seed=seed)\n", | ||
" pk_mts = pk.parsimony.hartigan.ts_to_dataset(ts_in)\n", | ||
" ds_in = pk.from_tskit(ts_in.first())\n", | ||
" ds = ds_in.merge(pk_mts)\n", | ||
" return ds\n", | ||
"\n", | ||
"pk_mts = create_mutation_tree(10000, 1000, 0.001, seed=1234)\n", | ||
"pk_mts" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"mutation_rate = 0.001\n", | ||
"\n", | ||
"pk.likelihood_felsenstein(pk_mts, rate=mutation_rate)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "phylokit", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.