TITLE: Plasmid Sequence Analysis from Long Reads
AUTHORS: David A Eccles

[DESCRIPTION]
This protocol demonstrates how to assemble reads from plasmid DNA, and generate a circularised and non-repetitive consensus sequence.

For plasmid sample preparation for nanopore sequencing, see here. The most recent version of our rapid barcoding kit protocol at the time this protocol was written is attached below:

  
 
At the moment, this protocol uses Canu to de-novo assemble high-quality single-cut reads.

Input(s): 
demultiplexed fastq files (see protocol Demultiplexing Nanopore reads with LAST). I've noticed that the default demultiplexing carried out by Guppy and Dorado has some issues with chimeric reads, which can affect assembly.

Output(s):
Consensus sequence per barcode as a fasta file

[BEFORE_START]
When preparing plasmid DNA for sequencing, I follow one piece of advice that Dr. Divya Mirrington (ONT) gave me about pooling: create a pooled sample with volumes that you're  confident about, then remove an aliquot from that for adding the  remaining reagents [paraphrased]. I don't do any additional cleanup for  purified plasmid DNA; they tend to sequence very well on flow cells  without that cleanup.

My key requirement for plasmid  sequencing is a concentration of >20 ng/μl (ideally by qubit or  quantus). Concentrations over 100 ng/μl should be diluted down. If the  plasmids can be diluted down to all exactly the same concentration (but  at least 20 ng/μl), or they're all similar lengths, then that makes  creating an equimolar pool much easier.

When creating the pools, I  add at least 1 μl of the the sample that I need to add the least for  (might be more if the total volume is less than 11 μl), then add the  corresponding amount of other samples to create an equimolar pool. I  then take 11 μl from the pool to be used for rapid adapter addition.

If samples are equal concentration:
Add  amounts according to the length of the plasmid divided by the length of  the shortest plasmid. For example, if there are two plasmids, one with  length 3kb and another with length 35 kb, then add 1 μl of the 3kb  plasmid, and 35/3 = 11.7 μl of the 35kb plasmid.

If plasmids are roughly equal length (i.e. less than ~10% length difference between plasmids):​
Add  amounts according to the concentration of the highest-concentration  sample divided by the concentration of the plasmid. For example, if  there are three plasmids, one with concentration 50 ng/μl, one with  concentration 35 ng/μl, and one with concentration 20 ng/μl, then add 1  μl of the 50 ng/μl plasmid, 50/35 = 1.4 μl of the 35 ng/μl plasmid, and  2.5 μl of the 20 ng/μl plasmid. The total volume of this pool will be  less than 11 μl (1 + 1.4 + 2.5 = 4.9 μl), so in this case I would triple  these volumes (3 μl; 4.2 μl; 7.5 μl) to create a pool of > 11 μl.

If samples are different concentrations and different lengths:​
Make  the sample prep easier. Use multiple flow cells for different plasmid  length ranges. Dilute higher-concentration samples down to the  lowest-concentration samples. I don't recommend trying to do both  calculations at the same time to determine added volumes because there's  a much higher chance of getting added amounts wrong, leading to wasted  samples or wasted flow cells.

If you have a sufficiently-accurate pipetting robot, a sample sheet, and someone who is comfortable with equations:​
Pre-calculate amount to add assuming 12 μl total pool volume:
ratio = length / max(length) * max(conc) / conc​
volume = ratio * 12 / sum(ratio)

[That's my guess at the right equations; please let me know if there's an error]

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

If this has been done, 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: Read file preparation
1.1. If reads have been demultiplexed by MinKNOW (bearing in mind that there may be issues with chimeric reads), then the following approach should work to create the right input format:


 

SECTION: Read file preparation
2. Create a directory to store results files

 

SECTION: Read filitering
4. It is assumed that you have some prior knowledge of the plasmid length. If the length is unknown, it can be determined by looking at the L50 summary statistics produced from fastx-length.pl when run on a representative sample:

 

Example output:

 

In this case, the plasmid length is approximately 5kb, so a system variable is created containing that information, as well as a value half that length:

 

Filter out any reads that are less than half of the target read length, then from the remaining reads keep keep 100 of highest-quality reads. These reads are fragmented into 1.5kb pieces with 750bp overlap.
 

SECTION: Choice 1: mapping to a reference sequence
5. This protocol assumes the reference sequence has a name 'refName', and can be found at 'reference/refName.fa'. Change 'refName' here in the likely event that the sequence / file has a different name, then export the variable REFNAME to make subsequent steps easier.


 

SECTION: Choice 1: mapping to a reference sequence
6. Create a LAST index for the reference sequence:

 


SECTION: Choice 1: mapping to a reference sequence
7. Prepare a substitution matrix for barcode mapping. I recommend doing this by training LAST, and incorporating quality scores into the trained matrix:

 

Copy the last few lines from the output into a text file called `plasmid.mat`

Here is a matrix that I have created from plasmid reads called using the guppy super-accuracy basecaller, v5.0.13:

 
  

This matrix has a moderate penalty for opening gaps (i.e. insertions and deletions), and a lower penalty for inserting them. Insertions are slightly less likely than deletions. It has a higher penalty for A/G transition variants, and a similar penalty for C/T transition variants as other substitution penalties.
SECTION: Choice 1: mapping to a reference sequence
8. Map reads to the reference and convert to BAM format using maf-convert and samtools:

 

SECTION: Choice 1: mapping to a reference sequence
9. Split reads into forward and reverse-mapped sequences, and tally up base counts at each location:


 

SECTION: Choice 1: mapping to a reference sequence
10. Create a visualisation of the base-stomped output:

 

Example output (`results/BC02_stompPlot_reference_seq.png`):

 
 

SECTION: Choice 2: De-novo Canu Assembly
11. Run a Canu assembly on each read set, using default options:

 

SECTION: Choice 2: De-novo Canu Assembly
12. Trim the assembled contigs based on Canu's trim recommendations for the longest assembled contig:

 

SECTION: Downloading Bioinformatics Scripts
3. This protocol uses scripts that I have developed over the course of my bioinformatics work to simplify fastq and fasta file processing. They can be downloaded from my gitlab repository:

 

SECTION: Final Cleanup - Orientation and Rotation
13. If plasmid sequences contain a long polyA region, the assembled sequences can be oriented assuming that the longest homopolymer is this polyA region:

 

SECTION: Final Cleanup - Orientation and Rotation
14. The plasmid can then be oriented based on a known alignment sequence.

First the alignment sequence is stored in a file 'align_seq.fa', and indexed using lastdb:

 
Then the alignment sequence is used to determine the rotation of the plasmid: