-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move rules for constructing phylogeny to its own smk file
Part of work to update this repo to match the pathogen-repo-template.
- Loading branch information
Showing
2 changed files
with
70 additions
and
49 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
69 changes: 69 additions & 0 deletions
69
phylogenetic/workflow/snakemake_rules/construct_phylogeny.smk
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,69 @@ | ||
""" | ||
This part of the workflow constructs the phylogenetic tree. | ||
REQUIRED INPUTS: | ||
metadata = data/metadata_all.tsv | ||
prepared_sequences = results/aligned.fasta | ||
OUTPUTS: | ||
tree = results/tree.nwk | ||
branch_lengths = results/branch_lengths.json | ||
This part of the workflow usually includes the following steps: | ||
- augur tree | ||
- augur refine | ||
See Augur's usage docs for these commands for more details. | ||
""" | ||
|
||
rule tree: | ||
"""Building tree""" | ||
input: | ||
alignment = "results/aligned.fasta" | ||
output: | ||
tree = "results/tree_raw.nwk" | ||
shell: | ||
""" | ||
augur tree \ | ||
--alignment {input.alignment} \ | ||
--output {output.tree} | ||
""" | ||
|
||
rule refine: | ||
""" | ||
Refining tree | ||
- estimate timetree | ||
- use {params.coalescent} coalescent timescale | ||
- estimate {params.date_inference} node dates | ||
- filter tips more than {params.clock_filter_iqd} IQDs from clock expectation | ||
""" | ||
input: | ||
tree = "results/tree_raw.nwk", | ||
alignment = "results/aligned.fasta", | ||
metadata = "data/metadata_all.tsv" | ||
output: | ||
tree = "results/tree.nwk", | ||
node_data = "results/branch_lengths.json" | ||
params: | ||
coalescent = "opt", | ||
date_inference = "marginal", | ||
clock_filter_iqd = 4, | ||
strain_id = config.get("strain_id_field", "strain"), | ||
shell: | ||
""" | ||
augur refine \ | ||
--tree {input.tree} \ | ||
--alignment {input.alignment} \ | ||
--metadata {input.metadata} \ | ||
--metadata-id-columns {params.strain_id} \ | ||
--output-tree {output.tree} \ | ||
--output-node-data {output.node_data} \ | ||
--timetree \ | ||
--coalescent {params.coalescent} \ | ||
--date-confidence \ | ||
--date-inference {params.date_inference} \ | ||
--clock-filter-iqd {params.clock_filter_iqd} | ||
""" |