Phylogeography of SARS-CoV-2: Snakemake Pipeline for Analysis and Visualization

public public 1yr ago 0 bookmarks

Phylogeography of SARS-CoV-2

Install

  1. Download git repository.

    git clone https://github.com/ktmeaton/ncov-phylogeography.git
    cd ncov-phylogeography
    
  2. Create conda environment

    mamba env create -f workflow/envs/main/environment.yaml
    conda activate ncov-phylogeography
    
  3. Run snakemake pipeline.

    snakemake --profile workflow/profiles/laptop all
    
  4. Visualize.

    auspice view --datasetDir results/auspice/nucleotide/
    

Code Snippets

109
110
111
112
113
114
115
	shell:
		"""
        python {scripts_dir}/metadata.py \
    	  --db {params.db} \
    	  --samples-csv {params.samples} \
    	  --output {output.tsv} \
        """
146
147
148
149
150
151
152
153
154
shell:
  """
  curl -o {output.file} -s '{params.url}'
  if [[ {wildcards.reads_origin} == "reference" ]]; then
    if [[ {wildcards.ext} == "fna" || {wildcards.ext} == "gff" ]]; then
      python {scripts_dir}/rename_headers.py --file {output.file};
    fi;
  fi;      
  """
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
shell:
  """
  snippy \
    --prefix {wildcards.sample} \
    --reference {input.ref} \
    --outdir {output.snippy_dir} \
    --ctgs {input.data} \
    --mapqual {config[map_qual]} \
    --mincov {config[min_depth]} \
    --minfrac {config[min_frac]} \
    --basequal {config[base_qual]} \
    --force \
    --cpus {resources.cpus} \
    --report; 
  """
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
shell:
  """
  set +e;
  snippy-core \
    --ref {input.ref} \
    --prefix {results_dir}/snippy_multi/{wildcards.reads_origin}/snippy-multi \
    --mask auto \
    --mask-char {config[mask_char]} \
    {input.snippy_pairwise_dir} > {output.log};

  snp-sites -C {output.full_aln} > {output.constant_sites};  

  python {scripts_dir}/filter_sites.py \
    --fasta {output.full_aln} \
    --missing {params.missing_data} \
    {params.keep_singleton} \
    --output {output.filter_aln} \
    --log {output.filter_log};

  exitcode=$?;
  if [ $exitcode -eq 1 ]
  then
      exit 1
  else
      exit 0
  fi      
  """
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
    shell:
        """
        iqtree \
            -s {input.aln} \
		        {params.model} \
            --threads-max {resources.cpus} \
            -nt {resources.cpus} \
            -seed {params.seed} \
            --runs {params.runs} \
            -fconst `cat {input.constant_sites}` \
            {params.other} \
            -redo \
            -pre {params.prefix} > {output.log};

        if [[ {params.reroot} ]]; then
          python3 {scripts_dir}/root_midpoint.py -t {params.prefix}.treefile -o {params.outdir}
        else
          mv {params.prefix}.treefile {output.nwk};        
        fi    
        """
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
shell:
  """
  augur refine \
    --tree {input.tree} \
    --output-tree {output.tree}

  augur ancestral \
    --tree {output.tree} \
    --alignment {input.aln} \
    --inference {params.inference} \
    --output-node-data {output.json_nt}

  augur translate \
    --tree {output.tree} \
    --ancestral-sequences {output.json_nt} \
    --reference-sequence {input.ref} \
    --output-node-data {output.json_aa}    
  """
375
376
377
378
379
380
381
382
shell:
    """
    python3 {scripts_dir}/nwk2auspice.py \
      --tree {input.nwk} \
      --outdir {params.out_dir} \
      --metadata {input.metadata} \
      --colors {input.colors}
    """
ShowHide 4 more snippets with no or duplicated tags.

Login to post a comment if you would like to share your experience with this workflow.

Do you know this workflow well? If so, you can request seller status , and start supporting this workflow.

Free

Created: 1yr ago
Updated: 1yr ago
Maitainers: public
URL: https://github.com/ktmeaton/ncov-phylogeography
Name: ncov-phylogeography
Version: 1
Badge:
workflow icon

Insert copied code into your website to add a link to this workflow.

Downloaded: 0
Copyright: Public Domain
License: None
  • Future updates

Related Workflows

cellranger-snakemake-gke
snakemake workflow to run cellranger on a given bucket using gke.
A Snakemake workflow for running cellranger on a given bucket using Google Kubernetes Engine. The usage of this workflow ...