TITLE: Preparing Reads for Stranded Mapping
AUTHORS: David A Eccles

[DESCRIPTION]
This protocol is for preparing long reads for stranded mapping, as an intermediate step for additional protocols:
Aligning strand-oriented sequences to a transcriptome for transcript / gene counting
Aligning strand-oriented sequences to a genome for confirmatory QC
 
Input(s): demultiplexed fastq files (see protocol Demultiplexing Nanopore reads with LAST), adapter file (containing strand-sensitive adapter sequences)
 
Output(s): oriented read files, as gzipped fastq files

[STEPS]
SECTION: Barcode Demultiplexing
1. Demultiplex reads as per protocol Demultiplexing Nanopore reads with LAST.

I usually inspect the barcode_counts.txt file, and delete any barcodes that I'm not interested in:
 

If demultiplexing has been done correctly, then the following command should produce output without errors:
 
Example output:
 
If the barcode_counts.txt file is missing, the output will look like this:
 
If one or more of the barcode-demultiplexed files are missing, the output will look something like this:
 

SECTION: Index Preparation
2. Prepare and index a FASTA file containing adapter sequences (see attached FASTA file).

  

Create a shell variable containing this file name:

 

SECTION: Index Preparation
4. Prepare a substitution matrix for adapter mapping. Mapping seems to work better when Q values are included:

 

  

A matrix like this can be generated by the following command, which runs last-train on the first 10,000 reads from the full read dataset:
 

[note: it is also fine to use the same matrix as used for demultiplexing]
SECTION: Index Preparation
3. Prepare the LAST index for the adapter file. Newer versions of LAST (v1409+) include a new seeding scheme, '-uRY4' [and other related RYX schemes], which improves mapping accuracy and reduces polyA matches; low-complexity regions are also converted to lower case with '-R01'. This will generate seven additional files of the form <index name>.XXX:

 

SECTION: Orienting Reads
5. Use LAST in split mode, using the pre-defined substitution matrix to map the reads. In this example, it is distributed over 10 processing threads (-P 10). In this case it's important that the direction of mapping is also recorded, so the cut command selects three fields (query name [7], target name [2], mapping direction [10]):


 

SECTION: Orienting Reads
6. The adapter assignments are filtered through uniq in order to catch (and exclude) any reads with the strand-switch primer matching multiple times. To unpack the uniq pipe a little bit more, it skips the first field (adapter name), then matches up to 36 characters, retaining only lines that don't match any others. This catches a few more chimeric reads that were missed by the unique barcode filter in the previous protocol.

Reads are filtered into two groups (and one group-by-omission) based on the mapped direction of the strand-switch primer, then reverse-complemented (if necessary) to match the orientation of the original RNA strand. I use my fastx-fetch.pl and fastx-rc.pl scripts for this.

 

 

 



SECTION: Orienting Reads
7. Forward and reverse-oriented sequences are combined together to form a single group of RNA-oriented reads.

 

SECTION: Downstream Workflows
8. Following on from here, the oriented reads can be mapped to a genome (e.g. for visual confirmation of mapping), or to a transcriptome (e.g. for read counting):

Stranded Mapping from Oriented Long Reads
Stranded Transcript Count Table Generation from Long Reads