tavareshugo/smk-indexer

Snakemake workflow for indexing reference genomes

Overview

Topics:

Latest release: None, Last update: 2024-06-07

Linting: linting: failed, Formatting:formatting: failed

Deployment

Step 1: Install Snakemake and Snakedeploy

Snakemake and Snakedeploy are best installed via the Mamba package manager (a drop-in replacement for conda). If you have neither Conda nor Mamba, it is recommended to install Miniforge. More details regarding Mamba can be found here.

When using Mamba, run

mamba create -c conda-forge -c bioconda --name snakemake snakemake snakedeploy

to install both Snakemake and Snakedeploy in an isolated environment. For all following commands ensure that this environment is activated via

conda activate snakemake

Step 2: Deploy workflow

With Snakemake and Snakedeploy installed, the workflow can be deployed as follows. First, create an appropriate project working directory on your system and enter it:

mkdir -p path/to/project-workdir
cd path/to/project-workdir

In all following steps, we will assume that you are inside of that directory. Then run

snakedeploy deploy-workflow https://github.com/tavareshugo/smk-indexer . --tag None

Snakedeploy will create two folders, workflow and config. The former contains the deployment of the chosen workflow as a Snakemake module, the latter contains configuration files which will be modified in the next step in order to configure the workflow to your needs.

Step 3: Configure workflow

To configure the workflow, adapt config/config.yml to your needs following the instructions below.

Step 4: Run workflow

The deployment method is controlled using the --software-deployment-method (short --sdm) argument.

To run the workflow with automatic deployment of all required software via conda/mamba, use

snakemake --cores all --sdm conda

Snakemake will automatically detect the main Snakefile in the workflow subfolder and execute the workflow module that has been defined by the deployment in step 2.

For further options such as cluster and cloud execution, see the docs.

Step 5: Generate report

After finalizing your data analysis, you can automatically generate an interactive visual HTML report for inspection of results together with parameters and code inside of the browser using

snakemake --report report.zip

Configuration

The following section is imported from the workflow’s config/README.md.

Workflow configuration: smk-indexer

Genome sheet

The main input is a CSV file specifying the source of the genome files, with the following columns:

  • name: will be used as the output directory name; we use <species>-<genome>-<source>-<release/version> as a convention (see naming details below).
  • genome: url to genome file.
  • gtf: url to gtf annotation file.
  • gff: url to gff annotation file.

For consistency, we name our genome directories as <species>-<genome>-<source>-<release/version>, where:

  • organism is the first letter of the genus followed by species scientific name.
  • genome is the name of the genome in the respective database.
  • source is the source of the genome. For example ensembl, gencode, ncbi, flybase, etc.
  • release/version is the release or version number of the genome release on the respective database. If no version number is available use YYYYMMDD of the genome file being downloaded.

Here's some examples:

  • hsapiens-GRCh38-ensembl-112 human genome using ENSEMBL release 112 (source)
  • hsapiens-GRCh38-gencode-45 effectively the same assembly as above, but using GENCODE release 45 (source)
  • hsapiens-GRCh37-gencode-45 the same GENCODE release, but for an earlier version of the human genome (source)
  • mmusculus-A_J_v1-ensembl-112 mouse reference genome for strain A/J on ENSEMBL release 112 (source)
  • dmelanogaster-BDGP6-ensembl-112 Drosophila melanogaster genome, using the genome name given in ENSEMBL release 112 (source)
  • dsimulans-dsim-flybase-r2.02 Drosophila simulans genome from flybase, release r2.02 (source)

Options

The config/options.yml can be used to configure the workflow options:

  • input: is the path to the genome CSV sheet, as detailed above.
  • outdir: is the path to the output directory. Sub-directories will be created within this, as detailed above.

Running the workflow

On CSD3, the workflow can be run with the following command:

snakemake --workflow-profile csd3 --singularity-args "--bind $PWD"
  • The --workflow-profile csd3 option makes snakemake look at the csd3/config.yaml file and takes resource specification from there. This is set to use SLURM and sets default resources for each rule of the workflow.
    • Make sure to edit this config file if using a different CSD3 account.
  • On Cambridge CSD3 we recommend running this from a tmux/screen session on a login node. Snakemake should then submit jobs to SLURM automatically.

For a dry-run (i.e. indicate which steps would be run without actually doing anything) do:

snakemake -np

Adding a new genome

To add a new genome, edit the genomes.csv file, adding a new row with the name and links for the new genome. Re-run the workflow as above, which should run only the steps necessary to index the new genome.

Always do a dry-run first, to check everything looks right (snakemake -np)

Using the genomes in your analysis

Within each genome directory, the following files can be found:

  • genome.fa.gz: compressed reference genome in FASTA format.
  • genome.fai: samtools index file for the FASTA file.
  • annotation.gtf.gz: compressed reference annotation in GTF format.
  • annotation.gff3.gz: compressed reference annotation in GFF3 format.

And the following directories, containing index files for the respective software tools:

  • bowtie2
  • bwa
  • bwa-mem2
  • hisat2
  • salmon
  • star

Linting and formatting

Linting results

Lints for snakefile /tmp/tmph2oh8tuw/workflow/Snakefile:
    * Deprecated singularity directive used for container definition in line 12.:
      Use the container directive instead (it is agnostic of the underlying
      container runtime).
      Also see:
      https://snakemake.readthedocs.io/en/latest/snakefiles/deployment.html#running-jobs-in-containers
    * Deprecated singularity directive used for container definition in line 13.:
      Use the container directive instead (it is agnostic of the underlying
      container runtime).
      Also see:
      https://snakemake.readthedocs.io/en/latest/snakefiles/deployment.html#running-jobs-in-containers

Lints for rule download (line 1, /tmp/tmph2oh8tuw/workflow/rules/download.smk):
    * Shell command directly uses variable config from outside of the rule:
      It is recommended to pass all files as input and output, and non-file
      parameters via the params directive. Otherwise, provenance tracking is
      less accurate.
      Also see:
      https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules
    * Shell command directly uses variable config from outside of the rule:

... (truncated)

Formatting results

[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/bwa.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/star.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/samtools.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/hisat2.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/uncompress.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/gffread.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/Snakefile":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/common.smk":  Formatted content is different from original
[DEBUG] 
[DEBUG] In file "/tmp/tmph2oh8tuw/workflow/rules/salmon.smk":  Formatted content is different from original

... (truncated)