Skip to content

Commit

Permalink
Merge pull request #1425 from nf-core/arm_3.16.1
Browse files Browse the repository at this point in the history
Add profile for ARM compatibility
  • Loading branch information
pinin4fjords authored Oct 23, 2024
2 parents 3671d59 + 424137a commit fb057c9
Show file tree
Hide file tree
Showing 19 changed files with 473 additions and 148 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [PR #1422](https://github.com/nf-core/rnaseq/pull/1422) - Bump lots of modules so that conda versions have ARM builds
- [PR #1423](https://github.com/nf-core/rnaseq/pull/1423) - Bump STAR version for version with ARM Conda build
- [PR #1424](https://github.com/nf-core/rnaseq/pull/1424) - Patch sortmerna to 4.3.7 for ARM compatibility
- [PR #1425](https://github.com/nf-core/rnaseq/pull/1425) - Add profile for ARM compatibility

## [[3.16.1](https://github.com/nf-core/rnaseq/releases/tag/3.16.1)] - 2024-10-16

Expand Down
274 changes: 274 additions & 0 deletions conf/arm.config

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ If you would like to reduce the number of reads used in the analysis, for exampl
## Alignment options

:::note
The `--aligner hisat2` option is not currently supported using ARM architecture ('-profile arm')
:::

By default, the pipeline uses [STAR](https://github.com/alexdobin/STAR) (i.e. `--aligner star_salmon`) to map the raw FastQ reads to the reference genome, project the alignments onto the transcriptome and to perform the downstream BAM-level quantification with [Salmon](https://salmon.readthedocs.io/en/latest/salmon.html). STAR is fast but requires a lot of memory to run, typically around 38GB for the Human GRCh37 reference genome. Since the [RSEM](https://github.com/deweylab/RSEM) (i.e. `--aligner star_rsem`) workflow in the pipeline also uses STAR you should use the [HISAT2](https://ccb.jhu.edu/software/hisat2/index.shtml) aligner (i.e. `--aligner hisat2`) if you have memory limitations.

You also have the option to pseudoalign and quantify your data directly with [Salmon](https://salmon.readthedocs.io/en/latest/salmon.html) or [Kallisto](https://pachterlab.github.io/kallisto/) by specifying `salmon` or `kallisto` to the `--pseudo_aligner` parameter. The selected pseudoaligner will then be run in addition to the standard alignment workflow defined by `--aligner`, mainly because it allows you to obtain QC metrics with respect to the genomic alignments. However, you can provide the `--skip_alignment` parameter if you would like to run Salmon or Kallisto in isolation. By default, the pipeline will use the genome fasta and gtf file to generate the transcripts fasta file, and then to build the Salmon index. You can override these parameters using the `--transcript_fasta` and `--salmon_index` parameters, respectively.
Expand Down Expand Up @@ -298,6 +302,10 @@ By default, the input GTF file will be filtered to ensure that sequence names co

## Contamination screening options

:::note
The `--contaminant_screening` option is not currently available using ARM architecture ('-profile arm')
:::

The pipeline provides the option to scan unaligned reads for contamination from other species using [Kraken2](https://ccb.jhu.edu/software/kraken2/), with the possibility of applying corrections from [Bracken](https://ccb.jhu.edu/software/bracken/). Since running Bracken is not computationally expensive, we recommend always using it to refine the abundance estimates generated by Kraken2.

It is important to note that the accuracy of Kraken2 is [highly dependent on the database](https://doi.org/10.1099/mgen.0.000949) used. Specifically, it is [crucial](https://doi.org/10.1128/mbio.01607-23) to ensure that the host genome is included in the database. If you are particularly concerned about certain contaminants, it may be beneficial to use a smaller, more focused database containing primarily those contaminants instead of the full standard database. Various pre-built databases [are available for download](https://benlangmead.github.io/aws-indexes/k2), and instructions for building a custom database can be found in the [Kraken2 documentation](https://github.com/DerrickWood/kraken2/blob/master/docs/MANUAL.markdown). Additionally, genomes of contaminants detected in previous sequencing experiments are available on the [OpenContami website](https://openlooper.hgc.jp/opencontami/help/help_oct.php).
Expand Down Expand Up @@ -356,6 +364,26 @@ genome: 'GRCh37'

You can also generate such `YAML`/`JSON` files via [nf-core/launch](https://nf-co.re/launch).

### Running on Linux ARM architectures

:::warning
Please note that the ARM profile is experimental. It is expected to function correctly in all cases unless explicitly indicated otherwise—currently, exceptions include the use of the hisat2 aligner and contaminant screening via kraken2. However, because testing is presently conducted manually, we cannot guarantee its reliability.
:::

The pipeline can be executed in an ARM compatible mode by specifying the ARM profile, for example:

```bash
nextflow run \
nf-core/rnaseq \
--input <SAMPLESHEET> \
--outdir <OUTDIR> \
--gtf <GTF> \
--fasta <GENOME FASTA> \
-profile docker,arm
```

This will use ARM-compatible containers, and apply a small number of overrides to Conda definitions to support ARM operations.

### Updating the pipeline

When you run the above command, Nextflow automatically pulls the pipeline code from GitHub and stores it as a cached version. When running the pipeline after this, it will always use the cached version if available - even if the pipeline has been updated since. To make sure that you're running the latest version of the pipeline, make sure that you regularly update the cached version of the pipeline:
Expand Down Expand Up @@ -420,6 +448,8 @@ If `-profile` is not specified, the pipeline will run locally and expect all sof
- A generic configuration profile to enable [Wave](https://seqera.io/wave/) containers. Use together with one of the above (requires Nextflow ` 24.03.0-edge` or later).
- `conda`
- A generic configuration profile to be used with [Conda](https://conda.io/docs/). Please only use Conda as a last resort i.e. when it's not possible to run the pipeline with Docker, Singularity, Podman, Shifter, Charliecloud, or Apptainer.
- `arm`
- A configuration profile that will set `docker.runOptions` appropriately for ARM architectures, and apply overrides supplying ARM-compatible containers and Conda environments. See [Running on Linux ARM architectures](#running-on-linux-arm-architectures).

### `-resume`

Expand Down
4 changes: 2 additions & 2 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
},
"trimgalore": {
"branch": "master",
"git_sha": "49f4e50534fe4b64101e62ea41d5dc43b1324358",
"git_sha": "8c5eeedd45e295fc9a4f164631da6a8b37e6b9c6",
"installed_by": ["fastq_fastqc_umitools_trimgalore"]
},
"tximeta/tximport": {
Expand Down Expand Up @@ -333,7 +333,7 @@
},
"fastq_fastqc_umitools_trimgalore": {
"branch": "master",
"git_sha": "49f4e50534fe4b64101e62ea41d5dc43b1324358",
"git_sha": "8c5eeedd45e295fc9a4f164631da6a8b37e6b9c6",
"installed_by": ["fastq_qc_trim_filter_setstrandedness", "subworkflows"]
},
"fastq_qc_trim_filter_setstrandedness": {
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/trimgalore/environment.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions modules/nf-core/trimgalore/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions modules/nf-core/trimgalore/tests/main.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ profiles {
}
arm {
docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
includeConfig 'conf/arm.config'
}
singularity {
singularity.enabled = true
Expand Down
75 changes: 47 additions & 28 deletions subworkflows/local/align_star/nextflow.config
Original file line number Diff line number Diff line change
@@ -1,36 +1,55 @@
def generateStarAlignArgs(save_unaligned, contaminant_screening, extra_star_align_args) {
def argsToMap = { String args ->
args.split(/\s(?=--)/).collectEntries {
def parts = it.trim().split(/\s+/, 2)
[(parts[0]): parts.size() > 1 ? parts[1] : '']
}
}

def base_args = """
--quantMode TranscriptomeSAM
--twopassMode Basic
--outSAMtype BAM Unsorted
--readFilesCommand zcat
--runRNGseed 0
--outFilterMultimapNmax 20
--alignSJDBoverhangMin 1
--outSAMattributes NH HI AS NM MD
--outSAMstrandField intronMotif
""".trim()

if (save_unaligned || contaminant_screening) {
base_args += "\n--outReadsUnmapped Fastx"
}

def final_args_map = argsToMap(base_args) + (extra_star_align_args ? argsToMap(extra_star_align_args) : [:])
final_args_map.collect { key, value -> "${key} ${value}".trim() }.join(' ')
}

if (!params.skip_alignment && params.aligner == 'star_salmon') {
process {
withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' {
ext.args = {
// Function to convert argument strings into a map
def argsToMap = { String args ->
args.split("\\s(?=--)").collectEntries {
def parts = it.trim().split(/\s+/, 2)
[(parts.first()): parts.last()]
}
}

// Initialize the map with preconfigured values
def preset_args_map = argsToMap("""
--quantMode TranscriptomeSAM
--twopassMode Basic
--outSAMtype BAM Unsorted
--readFilesCommand zcat
--runRNGseed 0
--outFilterMultimapNmax 20
--alignSJDBoverhangMin 1
--outSAMattributes NH HI AS NM MD
--quantTranscriptomeSAMoutput BanSingleEnd
--outSAMstrandField intronMotif
${params.save_unaligned || params.contaminant_screening ? '--outReadsUnmapped Fastx' : ''}
""".trim())

// Consolidate the extra arguments
def final_args_map = preset_args_map + (params.extra_star_align_args ? argsToMap(params.extra_star_align_args) : [:])
// We have to condition this, because the args are slightly different between the latest STAR and the one compatible with iGenomes

// Convert the map back to a list and then to a single string
final_args_map.collect { key, value -> "${key} ${value}" }.join(' ').trim()
withName: '.*:ALIGN_STAR:STAR_ALIGN' {
ext.args = {
generateStarAlignArgs(
params.save_unaligned,
params.contaminant_screening,
(params.extra_star_align_args ?: '') + ' --quantTranscriptomeSAMoutput BanSingleEnd'
)
}
}
withName: '.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' {
ext.args = {
generateStarAlignArgs(
params.save_unaligned,
params.contaminant_screening,
(params.extra_star_align_args ?: '') + ' --quantTranscriptomeBan Singleend'
)
}
}
withName: '.*:ALIGN_STAR:STAR_ALIGN|.*:ALIGN_STAR:STAR_ALIGN_IGENOMES' {

publishDir = [
[
Expand Down
Loading

0 comments on commit fb057c9

Please sign in to comment.