TITLE: Species Molecular Barcode Analysis with Nanopore Sequence Data 
AUTHORS: Gideon Erkenswick, Mrinalini Watsa, Zane Libke, Pamela Sánchez-Vendizú, Stefan Prost

[DESCRIPTION]
End-to-end workflow to generate cleaned consensus sequences from multiplexed amplicons sequenced with Nanopore sequencing technology. Includes read basecalling, quality control, data filtering, read demultiplexing, consensus sequence generation, and a data summary. The workflow assumes that individual samples have been uniquely indexed to allow highly multiplexed sequencing runs. The demultiplexing code is annotated to indicate different demultiplexing strategies utilized in the study. This workflow was used in the publication "Decoding the Peruvian Amazon with in situ DNA barcoding of vertebrate and plant taxa", and the last section of the workflow consists of a custom R script that generates summary statistics specific to the publication. Overall, this workflow can be modified to suit multiple markers, and is applicable to teaching in a classroom setting with the accompanying docker image.

[BEFORE_START]
Software dependencies:

Please ensure the following are installed on your device. 

DOCKER (https://www.docker.com/)
DORADO (https://github.com/nanoporetech/dorado/)



[GUIDELINES]
This is not an automated bioinformatics workflow. To replicate the analyses with new data, carefully review and then carry out each step sequentially. Basic Linux command-line literacy is a prerequisite for using this pipeline.  All steps are performed inside freely available Docker containers, eliminating most software compatibility challenges. Take careful note of which Docker image is being used for each step.  Minor adjustments to input parameters and custom code sections is often necessary, especially pertaining to the section on "read demultiplexing".

Dorado basecaller will run most efficiently with a GPU (review software documentation)
Consider parallelizing NGSpeciesID consensus sequence formation and NCBI blast to decrease computational time

[STEPS]
SECTION: Prepare Working Environment
1. Create a working directory
SECTION: Basecalling Raw Sequence Data
5. 
 


This command will perform basecalling on all sequence files inside path/to/working/directory/1.all.pod5s\

Must select a basecalling model:
- Fast (fast)
- High Accurancy (hac) *RECOMMENDED FOR AMPLICON SEQUENCE DATA*
- Super high accuracy (sup) ** TOO SLOW FOR MOST SERVERS
 

SECTION: QC &amp; Filtering
7. Run Docker image for pycoQC and create summary plots for the basecalled reads
 
Exit Docker before next step
SECTION: Demultiplex Sequence Data
11. Demultiplexing is carried out in 1 or 2 parts, depending on the experimental design:

Part 1: separating reads based on an outer ONT index kit (usually added by a ligation reaction)

Part 2: separating reads based on an inner index (usually added by PCR).

If the design involved a dual-indexing strategy,   and then carry out Part 2. If not using a dual-indexing strategy, choose whichever part is relevant, either Part 1 or Part 2.

SECTION: Generate Consensus Sequence
14. Determine fragment size within each outer index group using NanoPlot

 

 
Remain in the same Docker image for next step
SECTION: Organizing Consensus Sequence and Metadata
16. Locate and remove any files that might be created that are totally empty.

Then, consolidate full paths to all consensus sequences generated; the path information is used to rename the sequences prior to comparing them with public reference records


 

 


Remain in the same Docker container for next step
SECTION: BLASTn Analysis
18. The first command will search for all matching records in NCBI GenBank, and may take hours to complete depending on the number of consensus sequences being analyzed. Consider adjusting the matching criteria and the output file according to preference.
 
See an example of the output to explore the results.


 


SECTION: Sequence Data Clean-Up
19. Use any desired software or program to merge the following into a single tab- or comma-delimited spreadsheet (one consensus sequence per row)

Consensus sequences
Sample metadata


 

 

SECTION: Summarizing Data
21. 
The following script is unique to the format of the data that was used in our publication. It will not work in a generic sense on other data sets, but is provided as a record of what was performed for this publication and can serve as a valuable example to related studies in the future.

 

SECTION: Prepare Working Environment
2. Run the Docker application from the command line or inside the Docker GUI and retrieve the required Docker images. The "pull" command will download images from the online Docker Hub repository to the local environment.
 

SECTION: Prepare Working Environment
3. Create sub-folders within the working directory
 

SECTION: Prepare Working Environment
4. Establish variables that will be used to simplify command line operations
 
Manually move all pod5 files into path/to/working/director/1.all.pod5s. This is also easily achieved with common command-line tools.



 

SECTION: Basecalling Raw Sequence Data
6. Create a summary file of basecalled data
 

SECTION: QC &amp; Filtering
8. Convert basecalled reads in the ".sam" file to a ".fastq" file
 
Remain in same Docker container for next step
SECTION: QC &amp; Filtering
9. Filter reads by quality and size criteria. Modify size constraints and quality based on the pycoQC results above and the region you want to target.
 
Remain in same Docker container for next step.


SECTION: QC &amp; Filtering
10. Calculate percentage recovery


 

Exit the Docker container before the next step
SECTION: Demultiplex Sequence Data
12. Part 1: Dumultiplexing outer ONT indices
 
Remain in same Docker container for next step
SECTION: Demultiplex Sequence Data
13. Part 2: Demultiplex the inner indices
 
Remain in same Docker container for next step
SECTION: Generate Consensus Sequence
15. After determining the target fragment size from plots produced in the prior step, run the following code block separately for each outer index. For each iteration of this code block, you will want to adjust all the sections highlighted in yellow in the the example image below. Don't worry, the code itself is in a command listed at the end of this step.

 


 


 


 
This process make take hours to complete, depending on the quantity of reads being analyzed. Suggest using 'tmux' so that the operation continues even if the the comman-line window is accidentally closed.

Remain in the same Docker container for next step
SECTION: Organizing Consensus Sequence and Metadata
17. Create a single fasta file with all consensus sequences, including any cases of more than one per sample. 


 

 


Remain in the same Docker container for the next step
SECTION: Demultiplex Sequence Data
12.1. Check demultiplexing success by counting the number of reads in the unclassified folder

 

 
Manually perform the following calculation with the data you obtain on the command line:

Percent recovery = 1 - ('unclassified_reads' / 'total number of reads')*100 = XX%

Remain in same Docker container for next step
SECTION: Demultiplex Sequence Data
13.1. Count outer index demultiplex success
 
Remain in same Docker container for next step
SECTION: Demultiplex Sequence Data
13.2. Count inner index demultiplex success

 
Exit Docker container for next step
SECTION: Sequence Data Clean-Up
20. Visually inspect the results and consider using the following tools, as needed
 MAFFT alignment tool to check sequence directionality and its place on a phylogenetic tree to locate potential contamination and lab indexing errors
cutadapt to remove PCR primer sites, which often introduce errors to the sequences.
SECTION: QC &amp; Filtering
9.1. OPTIONAL:

NanoFilt is being deprecated soon, so consider moving to chopper instead.


 
To run chopper, use this command.
Note: Please edit the Q score and minimum and maximum lengths to filter to. Also edit the output file name appropriately.