Change substitution model in SARS-CoV-2 workflow?

Dear Nextstrain team,

Is there currently a way to customize the tree-builder-args in the SARS-CoV-2 workflow, e.g. changing the substitution model?

I see there is an open pull request related to this (Add parameter to enable overriding tree args by huddlej · Pull Request #871 · nextstrain/ncov · GitHub)

Best wishes,
Robert

1 Like

Hi Robert,

Thanks for getting in touch here. Good digging, I’m not sure the PR is ever going to get merged - there’s a good chance we’ll simplify how we produce SARS-CoV-2 trees in the future - the current workflow is rather complicated.

In general, the easiest might be to fork and make the changes you’d want directly in the code base.

Looking at this particular question of tree builder args I see two options:

  1. You should be able to change it here in the default.yaml config file: https://github.com/nextstrain/ncov/blob/a29a3b2d98b0835444a88c819925fae07ac9b826/defaults/parameters.yaml#L123

  2. If this doesn’t work, you can always fork the workflow and just directly make the changes you’d like to make to tree builder args here: https://github.com/nextstrain/ncov/blob/a29a3b2d98b0835444a88c819925fae07ac9b826/workflow/snakemake_rules/main_workflow.smk#L808

Let me know if this doesn’t work or you encounter some other issues.

Best,

Cornelius

Hi Cornelius!
Thanks for the rapid reply!

I had tried to modify both the default.yaml and the main workflow file but still got the same error (“conflict with hardcoded defaults”), so I wonder where the value ‘-ninit 10 -n 4’ is hardcoded?

Best,
Robert

I think the way to specify substitution model is via --substitution-model as opposed to default args:

augur tree -h
usage: augur tree [-h] --alignment ALIGNMENT [--method {fasttree,raxml,iqtree}] [--output OUTPUT] [--substitution-model SUBSTITUTION_MODEL]
                  [--nthreads NTHREADS] [--vcf-reference VCF_REFERENCE] [--exclude-sites EXCLUDE_SITES] [--tree-builder-args TREE_BUILDER_ARGS]
                  [--override-default-args]

Build a tree using a variety of methods.
...SNIP...
  --substitution-model SUBSTITUTION_MODEL
                        substitution model to use. Specify 'auto' to run ModelTest. Currently, only available for IQ-TREE. (default: GTR)

Also see the relevant tree.py code:
check_conflicting_args(tree_builder_args, (“-ntmax”, “-s”, “-m”))

auto is a special argument, but anything else gets passed through. See IQtree2 manual for valid substitution model strings:

iqtree2 -h
...SNIP...
--m MODEL_STRING          Specify the evolutionary model. See Manual for more detail

Link to relevant IQtree docs: http://www.iqtree.org/doc/Substitution-Models

Very good suggestion! It worked when I did the following modifications:
In main_workflow.smk I add to params and shell in rule tree:

rule tree:
    params:
        subst_model = config["tree"]["subst_model"]
    shell:
            --substitution-model {params.subst_model} 

and in parameters.yaml:

tree:
  subst_model: "GTR+F+R2"

Many thanks Cornelius!
Robert

2 Likes