Nanopore: quality assessment
Overview
Teaching: 15 min
Exercises: 15 minQuestions
How can I perform quality assessment of ONT data?
Objectives
Assess the quality of reads.
Generate summary metrics.
Software for quality assessment
In this part of the module, we’ll look at software applications that can be used to assess the quality of data from ONT sequencing runs. We’ll be focussing on two pieces of software: FastQC and NanoPlot.
- FastQC (you’ve already seen this): generic tool for assessing the quality of next generation sequencing data.
- NanoPlot: quality assessment software specifically built for ONT data.
Reminder; .bam file location
tree bam-unaligned
bam-unaligned/
└── NO_MISSV2_P2I
└── P2I_96
└── 20260413_1636_P2I-00014-B_PBK98658_853a956f
└── bam_pass
├── barcode01
│ └── PBK98658_pass_barcode01_853a956f_57f83f46_0.bam
├── barcode02
│ └── PBK98658_pass_barcode02_853a956f_57f83f46_0.bam
├── barcode03
│ └── PBK98658_pass_barcode03_853a956f_57f83f46_0.bam
.
.
.
└── unclassified
└── PBK98658_pass_unclassified_853a956f_57f83f46_0.bam
NanoPlot
Let’s use the NanoPlot software to assess the quality of our unaligned .bam data. We can run NanoPlot
interactively (i.e., we don’t need to submit it as a slurm job), and it wil produce an HTML-based report
that can be viewed in a browser.
Specify a .bam file to run NanoPlot on (PLEASE: use TAB COMPLETE to move down through the directories):
BAMFILE=bam-unaligned/NO_MISSV2_P2I/P2I_96/20260413_1636_P2I-00014-B_PBK98658_853a956f/bam_pass/barcode01/PBK98658_pass_barcode01_853a956f_57f83f46_0.bam
Running Nanoplot
Load the NanoPlot module:
module load NanoPlot
Run NanoPlot on a single .bam file:
NanoPlot -o nanoplot_fastmodel/barcode01 \
-p bacteria_fastmodel_barcode01_ \
--ubam $BAMFILE
Command syntax:
NanoPlot: run the NanoPlot command (note that the capital N and P are required).-o nnanoplot_fastmodel/barcode01: folder for output (-o) to be written.-p bacteria_fastmodel_barcode01_: prefix (-p) to be appended to start of each filename in the output folder.--ubam $BAMFILE: the unaligned bam (ubam) file to process with NanoPlot.
Let’s check what output was generated:
ls -1 nanoplot_fastmodel/barcode01
bacteria_fastmodel_barcode01_LengthvsQualityScatterPlot_dot.html
bacteria_fastmodel_barcode01_LengthvsQualityScatterPlot_dot.png
bacteria_fastmodel_barcode01_LengthvsQualityScatterPlot_kde.html
bacteria_fastmodel_barcode01_LengthvsQualityScatterPlot_kde.png
bacteria_fastmodel_barcode01_NanoPlot_20261113_1235.log
bacteria_fastmodel_barcode01_NanoPlot-report.html
bacteria_fastmodel_barcode01_NanoStats.txt
bacteria_fastmodel_barcode01_Non_weightedHistogramReadlength.html
bacteria_fastmodel_barcode01_Non_weightedHistogramReadlength.png
bacteria_fastmodel_barcode01_Non_weightedLogTransformed_HistogramReadlength.html
bacteria_fastmodel_barcode01_Non_weightedLogTransformed_HistogramReadlength.png
bacteria_fastmodel_barcode01_WeightedHistogramReadlength.html
bacteria_fastmodel_barcode01_WeightedHistogramReadlength.png
bacteria_fastmodel_barcode01_WeightedLogTransformed_HistogramReadlength.html
bacteria_fastmodel_barcode01_WeightedLogTransformed_HistogramReadlength.png
bacteria_fastmodel_barcode01_Yield_By_Length.html
bacteria_fastmodel_barcode01_Yield_By_Length.png
The file that we are interested in is the HTML report: bacteria_fastmodel_barcode01_NanoPlot-report.html
To view this in your browser:
- Use the file browser (left panel of Jupyter window) to navigate to the
nanoplot_fastmodel/barcode01folder. - Control-click (Mac) or right-click (Windows/Linux) on the “bacteria_fastmodel_barcode01_NanoPlot-report.html” file and choose “Open in New Browser Tab”.
- The report should now be displayed in a new tab in your browser.
Processing multiple .bam files
Nanoplot doesn’t have a built-in mechanism for processing multiple .bam files and keeping the output separate for each.
If you give it multiple .bam files (e.g., via Nanoplot --ubam *.bam) it will combine all of the results into a
single report.
In order to process each of the .bam files separately, you can use a loop:
FOLDER=bam-unaligned/NO_MISSV2_P2I/P2I_96/20260413_1636_P2I-00014-B_PBK98658_853a956f/bam_pass/
for i in barcode02 barcode03 unclassified
do
NanoPlot -o nanoplot_fastmodel/$i \
-p bacteria_fastmodel_$i_ \
--ubam $FOLDER/$i/*.bam
done
Once this has completed, we can check to see what has been created:
ls -1 nanoplot_fastmodel
barcode01
barcode02
barcode03
unclassified
There is now one folder of Nanoplot output for each barcoded sample.
FastQC
Load the FastQC module:
module load FastQC
Make a folder for the FastQC output to written to:
mkdir fastqc_fastmodel
Unlike Nanoplot, FastQC can handle multiple .bam files at once (so a command like his will work: fastqc -t 4 -o fastqc_fastmodel $FOLDER/*/*.bam).
BUT, because we’ve also got all of the .bam files from the other barcodes (and we don’t want to run FastQC for these empty files), can can use
the same approach as above.
Let’s re-use the $FOLDER variable we created.
Reminder:
tree $FOLDER
bam-unaligned/NO_MISSV2_P2I/P2I_96/20260413_1636_P2I-00014-B_PBK98658_853a956f/bam_pass/
├── barcode01
│ ├── PBK98658_pass_barcode01_853a956f_57f83f46_0.bam
│ └── PBK98658_pass_barcode01_853a956f_57f83f46_0.bam.bai
├── barcode02
│ ├── PBK98658_pass_barcode02_853a956f_57f83f46_0.bam
│ └── PBK98658_pass_barcode02_853a956f_57f83f46_0.bam.bai
├── barcode03
│ ├── PBK98658_pass_barcode03_853a956f_57f83f46_0.bam
│ └── PBK98658_pass_barcode03_853a956f_57f83f46_0.bam.bai
.
.
.
└── unclassified
├── PBK98658_pass_unclassified_853a956f_57f83f46_0.bam
└── PBK98658_pass_unclassified_853a956f_57f83f46_0.bam.bai
Fun fact - Nanoplot created a .bai (bam index) file for us when it processed the data.
Run FastQC on our data:
for i in barcode01 barcode02 barcode03 unclassified
do
fastqc -t 4 -o fastqc_fastmodel $FOLDER/$i/*.bam
done
Command syntax:
fastqc: run thefastqccommand-t 4: use four cpus to make it go faster (the-tis for “threads”).-o fastqc_fastmodel: specify output folder.$FOLDER/*/*.bam: data files to analyse (all bam files in all directories under $FOLDER).
Check the output:
ls -1 fastqc_fastmodel
PBK98658_pass_barcode01_853a956f_57f83f46_0_fastqc.html
PBK98658_pass_barcode01_853a956f_57f83f46_0_fastqc.zip
PBK98658_pass_barcode02_853a956f_57f83f46_0_fastqc.html
PBK98658_pass_barcode02_853a956f_57f83f46_0_fastqc.zip
PBK98658_pass_barcode03_853a956f_57f83f46_0_fastqc.html
PBK98658_pass_barcode03_853a956f_57f83f46_0_fastqc.zip
PBK98658_pass_unclassified_853a956f_57f83f46_0_fastqc.html
PBK98658_pass_unclassified_853a956f_57f83f46_0_fastqc.zip
As we did with the NanoPlot output, we can view the HTML report in the browser:
- Use the file browser (left panel of Jupyter window) to navigate to the
fastqc_fastmodelfolder. - Control-click (Mac) or right-click (Windows/Linux) on the “PBK98658_pass_barcode01_853a956f_57f83f46_0_fastqc.html” file and choose “Open in New Browser Tab”.
- The report should now be displayed in a new tab in your browser.
Key Points
FastQC and NanoPlot provide pre-formatted reports on run characteristics and read quality.