Package: isONcorrect
isONcorrectisONcorrect is a tool for error-correcting Oxford Nanopore cDNA reads. It is designed to handle highly variable coverage and exon variation within reads and achieves about a 0.5-1% median error rate after correction. It leverages regions shared between reads from different isoforms achieve low error rates even for low abundant transcripts. Seepaperfor details.Update:Since v0.0.8, isONcorrect uses different default parameters compared to what was used in thepaper. The new parameters make isONcorrect 2-3 times faster and use 3-8 times less memory with only a small cost of increased median post-correction error rate. With the new parameter setting the correction accuracy is 98.5-99.3% instead of 98.9–99.6% on the data used in the paper. Current default uses--k 9 --w 20 --max_seqs 2000. To invoke settings used in paper, set parameters--k 9 --w 10 --max_seqs 1000.Processing and error correction of full-length ONT cDNA reads is achieved by the pipeline of runningpychopper-->isONclust-->isONcorrect. All these steps can be run in one go withthis script. See below for installation and usage.isONcorrect is distributed as a python package supported on Linux / OSX with python v>=3.4..Table of ContentsINSTALLATIONUsing condaUsing pipDownloading source from GitHubDependenciesTesting installationUSAGERunningOutputParallelization across nodesCREDITSLICENCEINSTALLATIONTypical install time on a desktop computer is about 5 minutes with conda for this software.Using condaConda is the preferred way to install isONcorrect.Create and activate a new environment called isoncorrectconda create -n isoncorrect python=3.9 pip 
conda activate isoncorrectInstall isONcorrect and its dependencyspoa.pip install isONcorrect
conda install -c bioconda spoaYou should now have 'isONcorrect' installed; try it:isONcorrect --helpUpon start/login to your server/computer you need to activate the conda environment "isonclust" to run isONcorrect as:conda activate isoncorrectYou probably want to installpychopperandisONclustin the isoncorrect environmment as well to run the complete correction pipeline if you haven't already. This can be done with:pip install isONclust
conda install -c bioconda "hmmer>=3.0"
conda install -c bioconda "pychopper>=2.0"You are now set to run thecorrection_pipeline. SeeUSAGE.DependenciesisONcorrect has the following dependencies (the three first are automatically installed withpip)edlibNumPyparasailspoaTesting installationYou can verify successul installation by running isONcorrect onthesetwo small datasets of 100 reads. Download the two datasets and put in a foldertest_datarun, e.g,isONcorrect --fastq test_data/0.fastq \
            --outfolder [output path]Expected runtime for this test data is about 15 seconds. The output will be found in[output path]/corrected_reads.fastqwhere the 100 reads have the same headers as in the original file, but with corrected sequence. Testing the paralleized version (by separate clusters) of isONcorrect can be done by running./run_isoncorrect --t 3 --fastq_folder test_data/ \
                  --outfolder [output path]This will perform correction on0.fastqand1.fastqin parallel. Expected runtime for this test data is about 15 seconds. The output will be found in[output path]/0/corrected_reads.fastqand[output path]/1/corrected_reads.fastqwhere the 100 reads in each separate cluster have the same headers as in the respective original files, but with corrected sequence.USAGERunningUsing correction_pipeline.shYou can simply run./correction_pipeline.sh <raw_reads.fq>  <outfolder>  <num_cores>which will perform the steps 1-5 below for you. Thecorrection_pipeline.shscript is available in this repositoryhere. Simply download the reposotory or the individualcorrection_pipeline.sh file.For a fastq file with raw ONT cDNA reads, the following pipeline is recommended:Produce full-length reads (withpychopper(a.k.a.cdna_classifier))Cluster the full length reads into genes/gene-families (isONclust)Make fastq files of each cluster (isONclust write_fastqcommand)Correct individual clusters (isONcorrect)Join reads back to a single fastq file (This is of course optional)ManuallyThe contents of thecorrection_pipeline.shis (roughly) provided below. If you want more individual control over the steps than what thecorrection_pipeline.shcan do for you (such as different parameters in each step), you can modify/remove arguments as needed incorrection_pipeline.shor in the below script.#!/bin/bash

# Pipeline to get high-quality full-length reads from ONT cDNA sequencing

# Set path to output and number of cores
root_out="outfolder"
cores=20

mkdir -p $root_out

cdna_classifier.py  raw_reads.fq $root_out/full_length.fq -t $cores 

isONclust  --t $cores  --ont --fastq $root_out/full_length.fq \
             --outfolder $root_out/clustering

isONclust write_fastq --N 1 --clusters $root_out/clustering/final_clusters.tsv \
                      --fastq $root_out/full_length.fq --outfolder  $root_out/clustering/fastq_files 

run_isoncorrect --t $cores  --fastq_folder $root_out/clustering/fastq_files  --outfolder $root_out/correction/ 

# OPTIONAL BELOW TO MERGE ALL CORRECTED READS INTO ONE FILE
touch $root_out/all_corrected_reads.fq
OUTFILES=$root_out"/correction/"*"/corrected_reads.fastq"
for f in $OUTFILES
do 
  cat $f >> $outfolder/all_corrected_reads.fq
doneisONcorrect does not need ONT reads to be full-length (i.e., produced bypychopper), but unless you have specific other goals, it is advised to run pychopper for any kind of downstream analysis to guarantee full-length reads.OutputThe output ofrun_isoncorrectis one file per cluster with identical headers to the original reads.Few large clustersFor some datasets, e.g. targeted data,isONclustcan produce highly uneven clusters, i.e., a few very large clusters and some/many small ones. In such cases, runtime can be reduced if the argument--split_wrt_batchesis specified torun_isoncorrect.Parallelization across nodesisONcorrect currently supports parallelization across cores on a node (parameter--t), but not across several nodes. There is a way to overcome this limitation if you have access to multiple nodes as follows. Therun_isoncorrectstep can be parallilized across n nodes by (in bash or other environment, e.g., snakemake) parallelizing the following commandsrun_isoncorrect --fastq_folder outfolder/clustering/fastq_files  --outfolder /outfolder/correction/ --split_mod n --residual 0
run_isoncorrect --fastq_folder outfolder/clustering/fastq_files  --outfolder /outfolder/correction/ --split_mod n --residual 1
run_isoncorrect --fastq_folder outfolder/clustering/fastq_files  --outfolder /outfolder/correction/ --split_mod n --residual 2
...
run_isoncorrect --fastq_folder outfolder/clustering/fastq_files  --outfolder /outfolder/correction/ --split_mod n --residual n-1Which tells isONcorrect to only work with distinct cluster IDs.CREDITSPlease cite [1] when using isONcorrect.Sahlin, K., Medvedev, P. Error correction enables use of Oxford Nanopore technology for reference-free transcriptome analysis. Nat Commun 12, 2 (2021).https://doi.org/10.1038/s41467-020-20340-8Link.LICENCEGPL v3.0, seeLICENSE.txt.