-
Notifications
You must be signed in to change notification settings - Fork 3
Biobakery V4 + tufts HPC config #11
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
Changes from all commits
fb844b8
26076fd
479e8e5
646b40a
79bd96f
37292ef
62de8ec
326c33d
a990d6d
69f78c1
bc78841
a387885
ac550b5
3eabbd4
21727da
5fe9fd1
b8c39a2
2506c98
3cf41cc
72dda1a
57d70e3
64c692b
93e1409
dd332d4
b1da87c
91064df
5dd757e
0758a1c
fe48fb8
7242da6
9e6a84b
6e97842
d2d32a6
2f1bb42
4fd5d1e
1eaf4f6
ca73d43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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 | ||
| - 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,54 @@ profiles { | |
| process.executor = 'local' | ||
| } | ||
|
|
||
| tufts_hpc { | ||
| process { | ||
|
|
||
| executor = 'slurm' | ||
| queue = 'batch,preempt' | ||
|
|
||
| // Default settings for all processes | ||
| memory = '4.G' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we technically don't need this "default settings" section because resources for every process is defined
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be a vestige - I will double check
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the |
||
| time = '2.h' | ||
| cpus = 2 | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [For my own curiousity] Were these resource and time limits set through experience running these pipelines? Or something else? I'm guessing we probably have a good sense of what it takes to run metagenomic samples through so we won't run into any limits
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, mostly experience. They're mostly over-estimates. There's some logic in some of the processes to re-try on failure asking for more resources, but I think those haven't worked quite as intended. Should be revisited at some point, though it's really more relevant for AWS (the cost for provisioning resources is higher there - on the HPC it just means our fairshare goes down faster, but I have not run into any queuing problems yet even with pretty heavy use) |
||
| withName: bam2fastq { | ||
| memory = '8.G' | ||
| time = '1.h' | ||
| cpus = 4 | ||
|
|
||
| } | ||
|
|
||
| withName: kneaddata { | ||
| memory = '8.G' | ||
| time = '8.h' | ||
| cpus = 8 | ||
|
|
||
| } | ||
|
|
||
| withName: metaphlan { | ||
| memory = '32.G' | ||
| time = '4.h' | ||
| cpus = 8 | ||
|
|
||
| } | ||
|
|
||
| withName: humann { | ||
| memory = '32.G' | ||
| time = '8.h' | ||
| cpus = 16 | ||
| } | ||
|
|
||
| } | ||
|
|
||
| apptainer { | ||
| enabled = true | ||
| autoMounts = true | ||
| runOptions = '--no-home --bind /cluster' | ||
| } | ||
|
|
||
| } | ||
|
|
||
| engaging { | ||
| process { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| process bam2fastq { | ||
| tag "bam2fastq $sample" | ||
|
|
||
| errorStrategy 'retry' | ||
| maxRetries 3 | ||
|
|
||
| input: | ||
| tuple val(sample), path(reads) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: but should
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A quick one-liner explaining what each process file does would be helpful too. I can add this to my version of the pipeline. |
||
|
|
||
| output: | ||
| tuple val(sample), path("${sample}.fastq") | ||
|
|
||
| shell: | ||
|
|
||
| """ | ||
| echo $sample | ||
|
|
||
| samtools fastq -@ ${task.cpus} ${reads} > ${sample}.fastq | ||
| """ | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,15 @@ process kneaddata { | |
| time { workflow.profile == 'standard' ? null : time * task.attempt } | ||
| memory { workflow.profile == 'standard' ? null : memory * task.attempt } | ||
|
|
||
| errorStrategy 'retry' | ||
| maxRetries 3 | ||
| //errorStrategy 'retry' | ||
| //maxRetries 3 | ||
|
|
||
| input: | ||
| tuple val(sample), path(reads) | ||
| path human_genome | ||
|
|
||
| output: | ||
| tuple val(sample), path("${sample}_kneaddata_paired_{1,2}.fastq.gz") | ||
| path "${sample}_kneaddata_unmatched_{1,2}.fastq.gz" | ||
| val(sample), emit: sample | ||
| path("${sample}_kneaddata.fastq.gz"), emit: fastq | ||
| path "${sample}_kneaddata*.fastq.gz" , optional:true , emit: others | ||
| path "${sample}_kneaddata.log" , emit: log | ||
|
|
||
|
|
@@ -22,11 +21,11 @@ process kneaddata { | |
| """ | ||
| echo $sample | ||
|
|
||
| kneaddata --input ${reads[0]} --input ${reads[1]} \ | ||
| --reference-db $human_genome --output ./ \ | ||
| kneaddata --unpaired $reads \ | ||
| --reference-db ${params.human_genome} --output ./ \ | ||
| --processes ${task.cpus} --output-prefix ${sample}_kneaddata \ | ||
| --trimmomatic /opt/conda/share/trimmomatic | ||
| --trimmomatic /cluster/tufts/bonhamlab/shared/conda-envs/metaphlan_v4.2/.CondaPkg/.pixi/envs/default/share/trimmomatic | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting here that this path pointing to |
||
|
|
||
| gzip *.fastq | ||
| gzip ${sample}_kneaddata*.fastq | ||
| """ | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding here is that nextflow will first send the job in the
batchpartition, but if there is not available space in the queue, the job will be run preemptively. Is that correct?