TITLE: Stranded Mapping from Oriented Long Reads
AUTHORS: David A Eccles

[DESCRIPTION]
This protocol demonstrates how to map strand-oriented long reads to a genome, and visualise them in a genome browser.
 
The general idea is to use minimap2 to create stranded BAM files, which are split for forward/reverse orientation then converted into BigWig format for display in a genome browser.

Input(s): 
stranded fastq files (see protocol Preparing Reads for Stranded Mapping)
a FASTA file containing the genome / sequence of interest.
 
Output(s):
Genome-mapped stranded BAM files
Genome-mapped stranded BigWig files

[BEFORE_START]
You will need access to the following free and open-source software program(s):
minimap2
samtools

And the following additional data file(s):
a FASTA file containing the genome / sequence of interest.

[STEPS]
SECTION: Orient Reads
1. Orient reads as per protocol Preparing Reads for Stranded Mapping.

If this has been done, then the following command should produce output without errors:
 
Example output:
 


SECTION: Index Preparation
2. Prepare genome index for spliced alignment
 
 

 


SECTION: Read Mapping
3. Map the long reads to the genome using minimap2, using samtools to covert to a sorted BAM format. This is where the reverse complementing done during demultiplexing gives a big saving of effort. As this BAM file is one of the main outputs, the run name is added to the file name.

 

 


SECTION: Creating BigWig Coverage Files
4.  
A bedGraph of coverage is created using samtools mpileup and mpileupDC.pl, excluding any skipped intronic sequence. When 'mpileupDC.pl' is provided with a single file, it will output a bedGraph file with a header line starting with '##'; this header line is removed. 

To simplify output naming in later steps, the run name is added to the file name.

The particular JBrowse plugin that I use for stranded display requires that the reverse strand have negative coverage values, so that file needs to be changed:
 
As an alternative, BEDTools can be used to generate coverage. The default options for BEDTools treat sequence deletions (which happen frequently in nanopore reads) as a drop in coverage, which can make exon hunting and coverage calculation more difficult. I submitted a pull request to add an additional ignoreD parameter to the command line to allow cDNA reads with split coverage across introns to ignore deletions when considering coverage; this request has now been incorporated into the main BEDtools repository (as of v2.30.0):
 


 

SECTION: Creating BigWig Coverage Files
5. Stranded bedgraph files are converted to bigwig. This requires BEDTools and a genome information file containing chromosome lengths (one for Mmus/mm10 is attached to this step). As this bigwig file is one of the main outputs, the run name is added to the file name.

 
 


SECTION: JBrowse Configuration
6. Each track should have its own JBrowse configuration section using the StrangedBigWig class and StrandedXYPlot type. BAM tracks can also be added. An example is shown here:


[tracks.BWCG004-4T1-BC04-both-track ] storeClass     = StrandedPlotPlugin/Store/SeqFeature/StrandedBigWig urlTemplate    = bw/mm2_called_CG004_BC04_vs_MmusG.bw category       = MinION - Coverage type           = StrandedPlotPlugin/View/Track/Wiggle/StrandedXYPlot key            = MinION minimap2 coverage from CG004-4T1-WT (combined strands) scale          = log scoreType      = maxScore autoscale      = global style.pos_color = darkred style.neg_color = darkgreen
I have written my own helper scripts to reduce the effort required to generate these track sections. This is specific to my use case, but may help others for adapting to their own use. It takes three command-line parameters: the base file name, the internal ID for use in the track definition, and the label that appears within JBrowse. I use it as follows:


 


  

SECTION: Sanity Check
7. If this has worked properly, then mapping human or mouse to the mitochondrial genome should show most expression appearing on the positive strand, with a small scattering of negative-strand expression, a bit like the Expected Results shown here.
 
If not, check for the following issues:
 
Tracks not displaying at all in JBrowse -- make sure track IDs inside square brackets are of the form [ tracks.<unique-id-without-dots>-track ]
JBrowse track is reflected in the X axis -- make sure that the reverse bedgraph file is orientated the correct way; it should be created with the '-f 0x10' flag (no capitalisation).
JBrowse track only shows one direction -- make sure that the reverse bedgraph file has negative values, and re-generate the bigwig file