Skip to content
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
117 changes: 111 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,116 @@
# Nextflow pipeline for running the bioBakery

by Kevin Bonham, PhD
by Kevin Bonham, PhD

- `KneadData`
- `MetaPhlAn`
- `HUMAnN`
[bioBakery](https://github.com/biobakery): software, documentation, and tutorials for microbial community profiling (created and mantained by the Huttenhower lab)

## Setup
- [`KneadData`](https://github.com/biobakery/kneaddata):
a data quality-control pipeline that trims low quality reads
and removes host genomic data within our metagenomic samples.
Particularly, this pipeline uses a database containing a reference human genome
so that all human DNA is removed from the samples.
Link to more information here: (https://huttenhower.sph.harvard.edu/kneaddata/).
- [`MetaPhlAn`](https://github.com/biobakery/MetaPhlAn):
a computational tool for species-level microbial profiling (bacteria, archaea, eukaryotes, and viruses)
from metagenomic shotgun sequencing data.
Link to more information here:(https://huttenhower.sph.harvard.edu/metaphlan)
- [`HUMAnN`](https://github.com/biobakery/humann):
a pipeline for efficiently and accurately profiling the presence/absence and abundance of microbial pathways
in a community from metagenomic or metatranscriptomic sequencing data
(typically millions of short DNA/RNA reads).
This process, referred to as functional profiling,
aims to describe the metabolic potential of a microbial community and its members.
Link to more information here:(https://huttenhower.sph.harvard.edu/humann)

**TODO**
## Environment setup
Instructions for setting up a local environment to run the pipeline can be found on Danielle's notebook [here](https://github.com/BonhamLab/daniellepinto/blob/main/PeriodicMeetings/2025-06-17.md#danielles-personal-notes).

Computing environments on the Tufts HPC and AWS should already be set-up with container-based (docker, apptainer) or conda environments.

## Running the pipeline
This nextflow pipeline can be run on three different types of machines:
1) Locally
2) Tufts high performance cluster (HPC)
3) Amazon website services cloud (AWS)

Based on the profiles described in `nextflow.config`, we can run the pipeline with the following Nextflow commands:


### Running locally
`nextflow run main.nf -profile local -params-file params.yaml`

### Running on the HPC

Jobs on the Tufts HPC can be run in two different ways:

- **Batch**: the job will be sent to the queue
and it will be completed based on how many resources you have requested,
current cluster load,
and fairshare (have you recently used the cluster)

- **Preempt**: this allows you to run your job using free nodes from another lab that paid for these compute resources.
However, if they attempt to queue a job, your job will be preempted and killed, so you'll have to resubmit it.

With how the HPC environment is currently defined in `nextflow.config`,
jobs will first be submitted to the `batch` or `preempt` queue, whichever is available first.


- `nextflow run main.nf -profile tufts_hpc -params-file params.yaml`

### Running on AWS
`nextflow main.nf -profile amazon -params-file params.yaml`

> Kevin may want to add additional comments here about different ways to run the pipeline

> Note: We can also process samples on the MIT `engaging` cluster, but that should probably not be used without permission

## Databases
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I'm not confident about all the details in this database section, as I'm not an expert on which software and database versions play nicely together

Several databases must be installed to run this pipeline.

### Kneaddata
- A database containing a reference human genome so that unwanted human DNA can be removed from our metagenomic samples.
- The `Homo_sapiens_hg39_T2T_Bowtie2_v0.1` bowtie2 database can be downloaded from [here](https://huttenhower.sph.harvard.edu/kneadData_databases/Homo_sapiens_hg39_T2T_Bowtie2_v0.1.tar.gz).
- This version of the database can be used for all analyses and there shouldn't be a big need to upgrade the database (unless we have an updated human genome!)
- Other reference databases can be added as well if other types of data want to be removed (eg. human transcriptome, mouse genome, etc.)

### MetaPhlAn
- `mpa_vOct22_CHOCOPhlAnSGB_202403` is the most recent MetaPhlAn database that is compatible with the versions of HUMAnN we are using.
- It can be found/downloaded manually from [here](http://cmprod1.cibio.unitn.it/biobakery4/metaphlan_databases/). The easiest way to download is by running `metaphlan --install #any_other_args`
- Note: there is a more up-to-date version (released in January 2025) that we will probably eventually want to shift to once HUMAnN is able to support it.

### HUMAnN
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I would love more insight into which specific humann database to use and which versions are compatible with which versions of humann!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Me too! It's a bit of a mess. I can follow up with hutlab... I think I know

- Database can be downloaded [here](http://cmprod1.cibio.unitn.it/databases/HUMAnN/).


## Information on software versions
This pipeline supports the following versions of MetaPhlAn and HUMAnN:

### MetaPhlAn
- MetaPhlAn 3.1.0
- MetaPhlAn 4

### HUMAnN
- HUMAnN3 3.7
- HUMAnN3 4 alpha

## Testing the pipeline
There are some raw fastq files in `test/` which can be processed through the pipeline

## Using the `template-params.yaml` file
The `template-params.yaml` file defines all input parameters that you may want to use to run the Nextflow pipeline. The file should **not** be used directly to run the pipeline. Rather, the user should select the params they need from the file based on how they would like to use the pipeline (software versions of MetaPhlAn or HUMAnN, computing environment, databases, input data etc. ), and paste these into a separate yaml file. This second yaml file can be used to run the Nextflow pipeline.

### Overview of parameters in `template-params.yaml`
- `input_data_type`: type of input data (either `fastq` or `bam`)
- `paired_end`: True or False, given the type of input data
- `filepattern`: regex describing sample naming convention (relative to the input data type)

- `metaphlan_version`: MetaPhlAn software version (either `metaphlan_v3` or `metaphlan_v4`)
- `humann_version`: HUMAnN3 software version (either `humann_v37` or `humann_v4a`)
- `readsdir`: path to directory that contains raw data
- `outdir`: path to directory where processed results will be saved
- `human_genome`: path to directory that contains human reference database used during Kneaddata
- `metaphlan_db`: path to directory that contains metaphlan databases
- `metaphlan_index`: database version (database must exist within `metaphlan_db`)
- `humann_nucleotide_db`: path to directory containing chocophlan database
- `humann_protein_db`: path to directory containing UniRef database
- `humann_utility_db`: path to directory containing databases that have conversions between different protein annotations (eg UniRef90 to KO or EC), and names for all of the different annotations that have them
14 changes: 12 additions & 2 deletions processes/metaphlan.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ process metaphlan {


script:
// metphlan4 changed metaphlan db variable from bowtie2db to db_dir
// also changed from bowtie2out to mapout
if (params.metaphaln_ver == 'metaphlan4') {
db_arg = 'db_dir'
out_arg = 'mapout'}
else (params.metaphaln_ver == 'metaphlan3.1.0'){
db_arg = 'bowtie2db'
out_arg = 'bowtie2out'
}

"""
metaphlan $kneads -o ${sample}_profile.tsv \
--mapout ${sample}_bowtie2.tsv \
--${out_arg} ${sample}_bowtie2.tsv \
--samout ${sample}.sam \
--input_type fastq \
--nproc ${task.cpus} \
--db_dir ${params.metaphlan_db} \
--${dbarg} ${params.metaphlan_db} \
--index ${params.metaphlan_index} \
-t rel_ab_w_read_stats
"""
Expand Down
56 changes: 56 additions & 0 deletions template-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
### Data type
input_data_type: "bam"
input_data_type: "fastq"
# paired end data
paired_end: "True"

filepattern: "*.bam" # need to adjust if bam or fastq
# filepattern: "*.fastq"
# filepattern: "*.fastq.gz"


### Metaphlan version
# metaphlan3.1.0 params
metaphlan_version : "metaphlan_v3"
# metaphlan4 params
metaphlan_version : "metaphlan_v4"

# humann3.7 params
humann_version : "humann_v37"
# humann4alpha params
humann_version : "humann_v4a"



### Computing environment
# local params (will need to fill out yourself based on the location of files on your personal computer)

# readsdir:
# outdir:
# human_genome:
# metaphlan_db:
# metaphlan_index:
# humann_nucleotide_db:
# humann_protein_db:
# humann_utility_db:

# Tufts HPC params
readsdir: "/cluster/tufts/bonhamlab/shared/sequencing/bam"
outdir: "/cluster/tufts/bonhamlab/shared/sequencing/processed"
human_genome: "/cluster/tufts/bonhamlab/shared/databases/biobakery/kneaddata"
metaphlan_db: "/cluster/tufts/bonhamlab/shared/databases/biobakery/metaphlan"
metaphlan_index: "mpa_vOct22_CHOCOPhlAnSGB_202403"
humann_nucleotide_db: "/cluster/tufts/bonhamlab/shared/databases/biobakery/humann/chocophlan"
humann_protein_db: "/cluster/tufts/bonhamlab/shared/databases/biobakery/humann/uniref"
humann_utility_db: "/cluster/tufts/bonhamlab/shared/databases/biobakery/humann/utility_mapping"


# AWS params
readsdir: "s3://vkc-nextflow/rawfastq/"
outdir: "s3://vkc-nextflow/output/"
human_genome: "s3://biobakery-databases/kneaddata_databases/"
metaphlan_db: "s3://biobakery-databases/metaphlan_databases/"
humann_bowtie_db: "s3://biobakery-databases/humann_databases/chocophlan"
humann_protein_db: "s3://biobakery-databases/humann_databases/uniref"
humann_utility_db: "s3://biobakery-databases/humann_databases/utility_mapping"