-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
8,853 additions
and
63 deletions.
There are no files selected for viewing
4,165 changes: 4,165 additions & 0 deletions
4,165
workflow/notebooks/.ipynb_checkpoints/plot_missing_data.py-checkpoint.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
35 changes: 35 additions & 0 deletions
35
workflow/notebooks/.ipynb_checkpoints/test_path.py-checkpoint.ipynb
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,35 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"print(os.getcwd())" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.8.6" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
175 changes: 175 additions & 0 deletions
175
workflow/notebooks/.ipynb_checkpoints/treetime.py-checkpoint.ipynb
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,175 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Treetime Analysis" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Module Imports" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 17, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from Bio import Phylo\n", | ||
"from treetime.utils import parse_dates\n", | ||
"import pandas" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Input File Paths" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 15, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"../../results/iqtree/assembly/iqtree.core-chromosome.filter0.treefile\n", | ||
"../../results/treetime/assembly/metadata.tsv\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"'''\n", | ||
"tree_path = str(snakemake.input.tree)\n", | ||
"aln_path = str(snakemake.input.snp_aln)\n", | ||
"metadata_path = str(snakemake.input.metadata)\n", | ||
"treetime_path = str(snakemake.output.treetime)\n", | ||
"'''\n", | ||
"\n", | ||
"tree_path = \"../../results/iqtree/assembly/iqtree.core-chromosome.filter0.treefile\"\n", | ||
"metadata_path = \"../../results/treetime/assembly/metadata.tsv\"\n", | ||
"print(tree_path)\n", | ||
"print(metadata_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Constants and Variables" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"name_column = \"Accession\"\n", | ||
"dates_column = \"BioSampleCollectionDate\"\n", | ||
"attribute = \"BioSampleBiovar\"\n", | ||
"missing_data = \"?\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Parse Dates" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
" Accession BioSampleGeographicLocation \\\n", | ||
"0 GCA_009669545.1_ASM966954v1_genomic USA \n", | ||
"1 GCA_009669555.1_ASM966955v1_genomic USA \n", | ||
"2 GCA_009669565.1_ASM966956v1_genomic USA \n", | ||
"3 Reference USA \n", | ||
"\n", | ||
" BioSampleCollectionDate \n", | ||
"0 2000 \n", | ||
"1 2000 \n", | ||
"2 2000 \n", | ||
"3 2000 \n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"states = pandas.read_csv(metadata_path, sep='\\t')\n", | ||
"if name_column in states.columns:\n", | ||
" taxon_name = name_column\n", | ||
"if attribute in states.columns:\n", | ||
" attr = attribute\n", | ||
"\n", | ||
"# Get tips names\n", | ||
"tree = Phylo.read(tree_path, \"nexus\")\n", | ||
"tree_tip_names = [t.name for t in tree.get_terminals()]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 12, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "NameError", | ||
"evalue": "name 'treetime_path' is not defined", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | ||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", | ||
"\u001b[0;32m<ipython-input-12-3803fc66c3c7>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtreetime_path\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"w\"\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mfile\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;34m...\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | ||
"\u001b[0;31mNameError\u001b[0m: name 'treetime_path' is not defined" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"with open(treetime_path, \"w\") as file:\n", | ||
" ..." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"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.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Oops, something went wrong.