Skip to content

Commit

Permalink
Move rules for constructing phylogeny to its own smk file
Browse files Browse the repository at this point in the history
Part of work to update this repo to match the pathogen-repo-template.
  • Loading branch information
j23414 committed Dec 18, 2023
1 parent 2556de4 commit a87ad7e
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 49 deletions.
50 changes: 1 addition & 49 deletions phylogenetic/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,7 @@ files = rules.files.params

include: "workflow/snakemake_rules/usvi.smk"
include: "workflow/snakemake_rules/prepare_sequences.smk"

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}
"""
include: "workflow/snakemake_rules/construct_phylogeny.smk"

rule ancestral:
"""Reconstructing ancestral sequences and mutations"""
Expand Down
69 changes: 69 additions & 0 deletions phylogenetic/workflow/snakemake_rules/construct_phylogeny.smk
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}
"""

0 comments on commit a87ad7e

Please sign in to comment.