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
15 changes: 0 additions & 15 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ jobs:
run: |
ln -s ~/kraken2_db_8 kraken2_db

- name: make sylph db # Needed so tests can run quickly
run: |
cd ~
if [ ! -d "gatekeeper_sylph_test_data" ]; then
mkdir gatekeeper_sylph_test_data
cp /mnt/portal-sp3dev-knowledge/sylph/gtdb-r220-c1000-dbv1.syldb gatekeeper_sylph_test_data
cp /mnt/portal-sp3dev-knowledge/sylph/virus_imgvr_c200_v0.3.0.syldb gatekeeper_sylph_test_data
cp /mnt/portal-sp3dev-knowledge/sylph/fungi-refseq-2024-07-25-c200-v0.3.syldb gatekeeper_sylph_test_data
cp /mnt/portal-sp3dev-knowledge/sylph/*.tsv* gatekeeper_sylph_test_data
fi

- name: symlink sylph db
run: |
ln -s ~/gatekeeper_sylph_test_data sylph_dbs

# Run pytest in container to use conda environment
- name: pytest in docker
run: |
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ kraken2_db*
results
report*.html

sylph_dbs

# Python
*__pycache__

Expand Down
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
## New

- Code for generating sylph databases has been altered to incorporate ani_groups (based on taxid). This is only set for groups, not singletons
- when making sylph databases the taxonomy tsv now have a header and gets the ani_group column
- code for making virus sylph db now filters for human viruses
- Remove Sylph

## 2.4.0

Expand Down
55 changes: 1 addition & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ This pipeline should be used to perform check quality and trimming in sequence d
* Nextflow (tested on version 23.04)
* dependencies in [env.yml](env.yml)
* Kraken2 [Standard dataset](https://benlangmead.github.io/aws-indexes/k2) (tested with Standard-8 from 2023/06/05).
* For sylph: pre-built indexes and associated metadata.

## Running Pipeline ##
Parameters:

- **input_dir** = A directory containing input fastq.gz files
- **seq_platform** = Sequencing platform `illumina` or `ont`
- **kraken2_db_path** = Path to the kraken2 dataset
- **workflow** = `sylph`, `flu`, or `myco`. `speciated` is deprecated.
- **workflow** = `flu`, or `myco`. `speciated` is deprecated.
- **mem_map** (Optional) = Use Kraken 2 memory mapping (requires preloading kraken2 db `cp -r <path_to_kraken2_db> /dev/shm`) `true` or `false`
- **publish_dir** (Optional) If set will output files to directory provided.
- **sylph_dbs** = Path to sylph database(s). See [here](https://github.com/bluenote-1577/sylph/wiki/Pre%E2%80%90built-databases)
- **sylph_db_taxonomy_files** = Path taxonomy file(s) for sylph db. Should be tsv (optionally gzipped)

See parameters with:
```bash
Expand Down Expand Up @@ -56,56 +53,6 @@ cp -r kraken_index /dev/shm/
kraken2 --db /dev/shm/kraken_index --memory-mapping ...
```

## Sylph

Sylph is a k-mer based classification system that processes all the reads in one go, rather than classifying per read.
It can accept multiple databases, so to incorporate fungi or viruses an extra database can be provided rather than needing to rebuild a single db.
To use multiple databases it is easiest to set it in the `nextflow.config`:
```bash
params {
sylph_dbs = ["knowledge_bucket/sylph/refseq_bacteria_2025-08-04/refseq_bacteria_db_c200.syldb",
"knowledge_bucket/sylph/refseq_fungi_2025-08-04/refseq_fungi_db_c200.syldb",
"knowledge_bucket/sylph/refseq_viral_2025-08-04/refseq_viral_db_c100.syldb"]
sylph_db_taxonomy_files = ["knowledge_bucket/sylph/refseq_bacteria_2025-08-04/taxonomy.tsv.gz",
"knowledge_bucket/sylph/refseq_fungi_2025-08-04/taxonomy.tsv.gz",
"knowledge_bucket/sylph/refseq_viral_2025-08-04/taxonomy.tsv.gz"]
}
```

The taxonomy file needs to fit the format required for [sylph-tax](https://sylph-docs.github.io/sylph-tax-custom-taxonomies/).
As such it must be a two column TSV where the first column if the name of the fasta file, and the second column is the taxonomy string.
From testing:
- Can add a header without causing issues
- Can add additional columns

The taxonomy format for sylph-tax is the same as provided in the downloads from [GTDB](https://data.gtdb.aau.ecogenomic.org/releases/release226/226.0/)

### Parameters
There are two parameters used in the Sylph process:
- `sylph_query_ani_threshold`: sets the minimum ani threshold from the query step. Sylph authors recommend 90.
- `sylph_profile_ani_threshold`: sets the minimum ani threshold from the profile step. Sylph authors recommend 95.

### Databases for use
Preference is to go with NCBI over GTDB as it is more familiar to clinical users (Though GTDB likely works better).
Likewise with viruses the focus should be on human pathogenic viruses rather than phages etc.

In the knowledge bucket there are a variety of sylph databates.
To use one in this pipeline requires the database itself plus a tsv with the taxonomy metadata.

See [sylph_references](sylph_references/README.md) for details of creating databases from RefSeq (NCBI).

Note: For database to be used in competitive mapping downstream it also requires a folder of the reference genomes to make a manifest from.
As such the pre-built Sylph dbs are less useful except for GTDB which matches certain releases.

### Data for tests
Sylph tests expect a folder `sylph_dbs` containing the sylph [pre-built databases](https://github.com/bluenote-1577/sylph/wiki/Pre%E2%80%90built-databases) for testing.
These are included in the knowledge bucket in the sylph directory. Specifically uses:
- `gtdb-r220-c1000-dbv1.syldb` and `gtdb_r220_metadata.tsv.gz`
- `virus_imgvr_c200_v0.3.0.syldb` and `virus_imgvr_4.1_metadata.tsv.gz`

The c1000 means that the k-mers are sampled every 1000bp making it smaller than c200, and so useful for testing.
The metadata/taxonomy file can be optionally gzipped.


## Development/Install
The python side of this repo forms a python project.
Expand Down
2 changes: 0 additions & 2 deletions env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,3 @@ dependencies:
- just=1.40.0
- bracken=2.9
- pytest=8.3.2
- sylph=0.8.0
- sylph-tax=1.1.2
40 changes: 5 additions & 35 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include { fastp } from './process/quality_check.nf'
include { kraken2 ; summarise_taxa ; bracken_summarise_taxa } from './process/kraken2.nf'
include { filter_myco ; filter_flu } from './process/filter_reads.nf'
include { has_enough_reads } from './process/has_enough_reads.nf'
include { sylph } from './process/sylph.nf'

// Parameters
params.input_paired_suffix = "*_{1,2}.fastq.gz"
Expand All @@ -15,8 +14,6 @@ params.gatekeeper_illumina_min_num_reads = 10000
params.gatekeeper_ont_min_num_reads = 1000
params.gatekeeper_confidence_threshold = 0.00
params.gatekeeper_taxa_summary_threshold = 0.5
params.sylph_query_ani_threshold = 90
params.sylph_profile_ani_threshold = 95

workflow {
if (params.help) {
Expand All @@ -27,12 +24,10 @@ workflow {

Parameters:
------------------------------------------------------------------------
--workflow workflow to run: speciate, myco, sylph, speciate_detailed
--workflow workflow to run: speciate, myco, speciate_detailed
--input_dir Path to directory containing input fastq files
--seq_platform sequencing platform: illumina or ont
--kraken2_db_path Path to the kraken dataset directory
--sylph_db Path to the sylph database
--sylph_db_taxonomy Path to the sylph database taxonomy metadata

Optional:
--mem_map If 'true' use memory mapping for kraken2. See README for details
Expand All @@ -43,12 +38,12 @@ workflow {
}

if (params.seq_platform == 'ont') {
input_files = Channel.fromPath("${params.input_dir}/${params.input_single_suffix}", checkIfExists: true)
input_files = channel.fromPath("${params.input_dir}/${params.input_single_suffix}", checkIfExists: true)
.ifEmpty { error("cannot find any reads matching ${params.input_single_suffix} in ${params.input_dir}") }
.map { it -> tuple(it.simpleName, it) }
}
else if (params.seq_platform == 'illumina') {
input_files = Channel.fromFilePairs(
input_files = channel.fromFilePairs(
"${params.input_dir}/${params.input_paired_suffix}",
flat: false,
checkIfExists: true,
Expand All @@ -57,12 +52,12 @@ workflow {
.ifEmpty { error("cannot find any reads matching ${params.input_paired_suffix} in ${params.input_dir}") }
}

kraken2_db_path = Channel.fromPath(params.kraken2_db_path).first()
kraken2_db_path = channel.fromPath(params.kraken2_db_path).first()

check_seq_platform(params.seq_platform, input_files)

if (params.workflow == 'speciate') {
log.info("Speciate workflow is deprecated, consider sylph instead")
log.info("Speciate workflow is deprecated, consider sylph instead within competitive mapping")
gatekeeper_speciate(input_files, kraken2_db_path, params.seq_platform)
}
else if (params.workflow == 'myco') {
Expand All @@ -71,9 +66,6 @@ workflow {
else if (params.workflow == 'flu') {
gatekeeper_flu(input_files, kraken2_db_path, params.seq_platform)
}
else if (params.workflow == 'sylph') {
gatekeeper_sylph(input_files, params.sylph_dbs, params.sylph_db_taxonomy_files, params.seq_platform)
}
else {
error("Invalid workflow: ${params.workflow}")
}
Expand Down Expand Up @@ -169,28 +161,6 @@ workflow gatekeeper_flu {
gatekeeper_report = filter_flu.out.gatekeeper_report_json
}

workflow gatekeeper_sylph {
take:
fastq_files
sylph_dbs
sylph_db_taxonomy_files
seq_platform

main:
sylph(
fastq_files,
sylph_dbs,
sylph_db_taxonomy_files,
seq_platform,
params.sylph_query_ani_threshold,
params.sylph_profile_ani_threshold,
)

emit:
sylph_query = sylph.out.sylph_query
sylph_report = sylph.out.sylph_report
taxonomy_report = sylph.out.taxonomy_report
}

def check_seq_platform(seq_platform, fastq_files) {
def seq_platforms = ['ont', 'illumina']
Expand Down
2 changes: 0 additions & 2 deletions minimal_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@ process/templates/filter_myco.sh
process/templates/filter_flu.sh
process/templates/run_fastp.sh
process/templates/run_kraken.sh
process/sylph.nf
process/templates/run_sylph.sh
36 changes: 0 additions & 36 deletions process/sylph.nf

This file was deleted.

34 changes: 0 additions & 34 deletions process/templates/run_sylph.sh

This file was deleted.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ version_files = [
"process/kraken2.nf",
"process/quality_check.nf",
"process/filter_reads.nf",
"process/sylph.nf",
]
14 changes: 0 additions & 14 deletions sylph_references/.gitignore

This file was deleted.

Loading
Loading