Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[phylo] Reconnect traits to export #252

Merged
merged 5 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions phylogenetic/build-configs/ci/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ clock_rate: 5.7e-5
clock_std_dev: 2e-5
divergence_units: "mutations"

traits:
columns: ""
sampling_bias_correction: 3

## recency
recency: true

Expand Down
4 changes: 4 additions & 0 deletions phylogenetic/defaults/hmpxv1/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ clock_rate: 5.7e-5
clock_std_dev: 2e-5
divergence_units: "mutations"

traits:
columns: ""
sampling_bias_correction: 3

## recency
recency: true

Expand Down
4 changes: 4 additions & 0 deletions phylogenetic/defaults/hmpxv1_big/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ clock_rate: 5.7e-5
clock_std_dev: 2e-5
divergence_units: "mutations"

traits:
columns: ""
sampling_bias_correction: 3

## recency
recency: true

Expand Down
4 changes: 4 additions & 0 deletions phylogenetic/defaults/mpxv/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ clock_rate: 3e-6
clock_std_dev: 6e-6
divergence_units: "mutations-per-site"

traits:
columns: ""
sampling_bias_correction: 3

## recency
recency: true

Expand Down
4 changes: 2 additions & 2 deletions phylogenetic/rules/annotate_phylogeny.smk
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ rule traits:
output:
node_data=build_dir + "/{build_name}/traits.json",
params:
columns="country",
sampling_bias_correction=3,
columns=config["traits"]["columns"],
sampling_bias_correction=config["traits"]["sampling_bias_correction"],
strain_id=config["strain_id_field"],
shell:
"""
Expand Down
16 changes: 10 additions & 6 deletions phylogenetic/rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ OUTPUTS:

rule remove_time:
input:
"results/{build_name}/branch_lengths.json",
build_dir + "/{build_name}/branch_lengths.json",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is probably some snakemake lore i haven't absorbed yet, but i wonder: why concatenate instead of interpolate? (e.g., "{build_dir}/{build_name}/branch_lengths.json")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is using concatenation because the workflow uses a mix of variable (build_dir) and Snakemake wildcard (build_name) in the file paths.

We could update it to f"{build_dir}/{{build_name}}/branch_lengths.json" with double braces around build_name to keep the wildcard reference.

output:
"results/{build_name}/branch_lengths_no_time.json",
build_dir + "/{build_name}/branch_lengths_no_time.json",
shell:
"""
python3 scripts/remove_timeinfo.py --input-node-data {input} --output-node-data {output}
Expand Down Expand Up @@ -66,11 +66,15 @@ rule export:
tree=build_dir + "/{build_name}/tree.nwk",
metadata=build_dir + "/{build_name}/metadata.tsv",
branch_lengths=(
"results/{build_name}/branch_lengths.json"
build_dir + "/{build_name}/branch_lengths.json"
if config.get("timetree", False)
else "results/{build_name}/branch_lengths_no_time.json"
else build_dir + "/{build_name}/branch_lengths_no_time.json"
),
traits=(
build_dir + "/{build_name}/traits.json"
if config.get("traits", {}).get("columns", False)
else []
),
traits=build_dir + "/{build_name}/traits.json",
nt_muts=build_dir + "/{build_name}/nt_muts.json",
aa_muts=build_dir + "/{build_name}/aa_muts.json",
clades=build_dir + "/{build_name}/clades.json",
Expand All @@ -95,7 +99,7 @@ rule export:
--tree {input.tree} \
--metadata {input.metadata} \
--metadata-id-columns {params.strain_id} \
--node-data {input.branch_lengths} {input.nt_muts} {input.aa_muts} {input.mutation_context} {input.clades} {input.recency}\
--node-data {input.branch_lengths} {input.traits} {input.nt_muts} {input.aa_muts} {input.mutation_context} {input.clades} {input.recency}\
--colors {input.colors} \
--lat-longs {input.lat_longs} \
--description {input.description} \
Expand Down