Skip to content

Commit

Permalink
Merge pull request #112 from mhoban/zotu_identity
Browse files Browse the repository at this point in the history
Add `--zotu-identity` parameter for zOTU table generation step
  • Loading branch information
mhoban authored Oct 18, 2024
2 parents 46e4f36 + 8bebe25 commit d9b695c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ These options control how (and by what tool) sequences are denoised and zOTUs ar
<small>**`--denoiser [tool/path]`**</small>: Sets the tool used for denoising & chimera removal. Accepted options: 'usearch', 'usearch32', 'vsearch', path to 64-bit usearch executable (default: vsearch)
<small>**`--min-abundance [num]`**</small>: Minimum sequence abundance for zOTU determination; sequences with abundances below the specified threshold will be discarded during the denoising process (default: 8)
<small>**`--alpha [num]`**</small>: Alpha parameter passed to the UNOISE3 algorithm (see the [unoise2 paper for more info](https://doi.org/10.1101/081257)) (default: 2.0)
<small>**`--zotu-identity [num]`**</small>: Fractional pairwise identity used to match raw reads to zOTUs, equivalent to `vsearch` `--id`/`usearch` `-id` parameters (default: 0.97)
<small>**`--usearch`**</small>: Alias for `--denoiser usearch`

### zOTU curation using LULU
Expand Down
1 change: 1 addition & 0 deletions lib/helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class helper {
--alpha [num] Sets the alpha parameter for the UNOISE3 algorithm (default: ${params.alpha})
--min-abundance [num] Minimum sequence abundance for zOTU determination; sequences below threshold will be discarded
(default: ${params.minAbundance})
--zotu-identity [num] Fractional identity (0–1) for zOTU search (default: 0.97)
--usearch shortcut for --denoiser usearch
LULU zOTU curation:
Expand Down
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ params.usearch = false
params.denoiser = params.usearch ? 'usearch' : 'vsearch'
params.minAbundance = 8
params.alpha = 2.0
params.zotuIdentity = 0.97
try {
params.execDenoiser = new File(params.denoiser).canExecute()
} catch (Exception e) {
Expand Down
33 changes: 26 additions & 7 deletions rainbow_bridge.nf
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ process dereplicate {
output:
tuple val(id), path("${id}_unique.fasta"), path("${id}_zotus.fasta"), path("zotu_table.tsv"), emit: result
path 'settings.txt'
path 'zotu_map.tsv'

script:
if (params.denoiser == "vsearch") {
Expand All @@ -423,10 +424,24 @@ process dereplicate {
# 3. get rid of chimeras
# 4. match original sequences to zotus by 97% identity
if [ -s "${relabeled_merged}" ]; then
vsearch --threads ${task.cpus} --fastq_qmax ${params.maxQuality} --derep_fulllength ${relabeled_merged} --sizeout --output "${id}_unique.fasta"
vsearch --threads ${task.cpus} --fastq_qmax ${params.maxQuality} --cluster_unoise "${id}_unique.fasta" --centroids "${id}_centroids.fasta" --minsize ${params.minAbundance} --unoise_alpha ${params.alpha}
vsearch --threads ${task.cpus} --fastq_qmax ${params.maxQuality} --uchime3_denovo "${id}_centroids.fasta" --nonchimeras "${id}_zotus.fasta" --relabel Zotu
vsearch --threads ${task.cpus} --fastq_qmax ${params.maxQuality} --usearch_global ${relabeled_merged} --db "${id}_zotus.fasta" --id 0.97 --otutabout zotu_table.tsv
vsearch \
--threads ${task.cpus} --fastq_qmax ${params.maxQuality} \
--derep_fulllength ${relabeled_merged} --sizeout \
--output "${id}_unique.fasta"
vsearch \
--threads ${task.cpus} --fastq_qmax ${params.maxQuality} \
--cluster_unoise "${id}_unique.fasta" --centroids "${id}_centroids.fasta" \
--minsize ${params.minAbundance} --unoise_alpha ${params.alpha}
vsearch \
--threads ${task.cpus} --fastq_qmax ${params.maxQuality} \
--uchime3_denovo "${id}_centroids.fasta" --nonchimeras "${id}_zotus.fasta" \
--relabel Zotu
vsearch \
--threads ${task.cpus} --fastq_qmax ${params.maxQuality} \
--usearch_global ${relabeled_merged} --db "${id}_zotus.fasta" \
--id ${params.zotuIdentity} --otutabout zotu_table.tsv \
--userout zotu_map.tsv --userfields "query+target" \
--top_hits_only
else
>&2 echo "Merged FASTA is empty. Did your PCR primers match anything?"
exit 1
Expand All @@ -442,9 +457,13 @@ process dereplicate {
# 2. run denoising & chimera removal
# 3. generate zotu table
if [ -s "${relabeled_merged}" ]; then
${denoiser} -fastx_uniques ${relabeled_merged} -sizeout -fastaout "${id}_unique.fasta"
${denoiser} -unoise3 "${id}_unique.fasta" -zotus "${id}_zotus.fasta" -tabbedout "${id}_unique_unoise3.txt" -minsize ${params.minAbundance} -unoise_alpha ${params.alpha}
${denoiser} -otutab ${relabeled_merged} -zotus ${id}_zotus.fasta -otutabout zotu_table.tsv -mapout zmap.txt
${denoiser} -fastx_uniques ${relabeled_merged} \
-sizeout -fastaout "${id}_unique.fasta"
${denoiser} -unoise3 "${id}_unique.fasta" -zotus "${id}_zotus.fasta" \
-tabbedout "${id}_unique_unoise3.txt" -minsize ${params.minAbundance} \
-unoise_alpha ${params.alpha}
${denoiser} -otutab ${relabeled_merged} -id ${params.zotuIdentity} \
-zotus ${id}_zotus.fasta -otutabout zotu_table.tsv -mapout zotu_map.tsv
else
>&2 echo "Merged FASTA is empty. Did your PCR primers match anything?"
exit 1
Expand Down

0 comments on commit d9b695c

Please sign in to comment.