Confirming Carbapenemase Connectivity and Plasmid Junctions with Minimap2 and Samtools
Hello. This module focuses on a crucial distinction in plasmid genomics: an assembly can claim that a carbapenemase cassette, plasmid backbone, or chromosome–plasmid boundary is connected, but long reads can test whether individual DNA molecules actually support that connection.
In this lesson, you will map Oxford Nanopore reads back to a hybrid assembly with minimap2, create an indexed BAM file with samtools, and inspect reads at a carbapenemase locus or suspected plasmid junction. The central skill is not merely finding reads that touch a region: it is deciding whether a read genuinely bridges two informative flanks of a proposed junction.
What question does spanning-read analysis answer?
A hybrid assembly represents a best reconstruction of the DNA molecules in an isolate. It may contain:
- a complete chromosome;
- one or more complete circular plasmids;
- a carbapenemase locus embedded within a plasmid backbone;
- a mobile cassette bounded by insertion sequences;
- a suspected plasmid–chromosome integration;
- unresolved repeat-linked contigs.
Assemblers infer these structures from overlaps among reads. This becomes difficult when the locus contains repeated sequence, such as multiple copies of an insertion sequence, a transposon, or tandem antimicrobial-resistance genes. A long read can be extremely useful because it may begin in a unique sequence on one side of a repeat, pass through the repeat or carbapenemase cassette, and continue into a different unique sequence on the other side.
That is the logic of a spanning read.
Suppose your assembly proposes this local structure:
unique plasmid flank | IS | carbapenemase gene | transposon sequence | unique plasmid flank
A read that covers only the carbapenemase gene establishes that the gene sequence exists. It does not establish where that gene sits. A read that contains substantial sequence from both unique flanks, with the complete intervening cassette in between, supports the claimed connectivity.
This distinction matters for CPE from drains, sinks, showers, or toilets. If an environmental Enterobacter or Citrobacter isolate and a patient isolate contain the same carbapenemase gene, that alone is weak evidence of shared transmission. If both contain a closely related, long-read-supported plasmid structure carrying that gene in the same genomic context, the evidence becomes substantially stronger. Direction of transfer still requires spatial, temporal, host-genome, and sampling evidence, but a structurally validated plasmid is the foundation.
Three kinds of junctions to test
“Junction” can mean several related things. Be explicit in your analysis notes about which one you are testing.
| Junction type | Question | Strong long-read observation |
|---|---|---|
| Internal assembly junction | Does the carbapenemase cassette connect to the proposed left and right plasmid or chromosomal flanks? | One read aligns continuously across the junction, including informative sequence on both sides. |
| Circular plasmid end-to-end junction | Is a linear representation of a circular plasmid supported as circular? | Reads cross the artificial join created by placing the last base of the contig beside the first base. |
| Plasmid–chromosome junction | Is a plasmid-like region integrated into the chromosome rather than separate? | Reads bridge from unique chromosomal sequence into the plasmid-like region at each boundary. |
A long-read alignment overlapping a junction is only a candidate. It becomes useful evidence only after you check its alignment quality, continuity, placement, and flanking context.
The mapping evidence in a BAM file
A reference is the sequence you map reads against. Here, the reference is normally your polished hybrid assembly FASTA, containing chromosome and plasmid contigs. The query sequences are the original ONT reads in FASTQ format.
minimap2 finds plausible placements of each long read on the assembly. samtools converts, sorts, indexes, filters, and inspects the resulting alignments.
The usual working file is a coordinate-sorted BAM file:
- SAM is a tab-delimited text representation of alignments.
- BAM is the compressed binary equivalent, better for storage and rapid querying.
- A BAM index allows a tool to retrieve reads at, for example,
plasmid_1:42000-46000without scanning the entire file.
Before applying commands, take a focused look at how SAM records encode an alignment.
An introduction to SAM and BAM files - EPI2ME Labs
Read the relevant parts of An introduction to SAM and BAM files from EPI2ME Labs. It provides the vocabulary needed to distinguish a continuous long-read alignment from a misleading secondary or split alignment.
In “SAM Files”, read from the file-format introduction, paying particular attention to QNAME, FLAG, RNAME, POS, MAPQ, and CIGAR. In “What the flag?”, read the primary-alignment definition, then use the flag table to identify secondary (256) and supplementary (2048) records. In “CIGAR, anyone?”, read the CIGAR explanation; focus on why M means “aligned,” not necessarily identical, and what clipping means. Finally, in “Creating a SAM/BAM file via Alignment” and “Compressing, sorting, indexing with Samtools”, follow the minimap2 setup and the BAM-processing rationale. The final section, “Select alignments that overlap a given region,” shows the contig:start-end region-query convention used below.
The SAM fields you will inspect most often
Each alignment record has required fields. For junction investigation, these are the practical essentials:
| Field | Meaning for junction analysis |
|---|---|
| QNAME | Read identifier. Use it to recognise whether several records come from the same physical read. |
| FLAG | Encodes alignment status, including reverse orientation, secondary alignment, and supplementary alignment. |
| RNAME | Assembly contig to which the read maps. |
| POS | Leftmost one-based position of the alignment on that contig. |
| MAPQ | Mapper’s confidence in the placement. Low MAPQ often reflects repeated or shared sequence. |
| CIGAR | Compact description of how the read aligns, including aligned sequence, insertions, deletions, and clipping. |
| SA tag | Optional tag listing other alignments of the same read. It is particularly relevant for split or supplementary alignments. |
A CIGAR string such as 12000M is encouraging: it describes one long contiguous alignment, though it does not say every base matches. A CIGAR string such as 7000M3000S means that only 7 kb of the read aligned at that location and 3 kb was soft-clipped. The clipped sequence may be low quality, unrepresented in the assembly, or aligned elsewhere in a supplementary record.
A supplementary alignment is not automatically an artefact. It can reveal a real rearrangement, integration, or assembly error. However, it is weaker evidence for a proposed uninterrupted assembly path than a single high-quality alignment bridging the same region. Inspect it rather than silently treating it as confirmation.
Map the ONT reads to the hybrid assembly
Use the same ONT read set that contributed to the assembly, after any filtering you recorded during long-read QC. Mapping a different sequencing run can still be informative, but it changes the question: you are then validating reproducibility or checking for a structural change, not directly validating the reads used to construct the assembly.
A minimal reproducible Conda or Mamba environment is:
mamba create -n plasmid-spanning -c conda-forge -c bioconda \
minimap2 samtools
mamba activate plasmid-spanning
Record tool versions in your project log:
minimap2 --version
samtools --version
Map ONT reads to the polished hybrid assembly, sort the alignments by reference coordinate, and create an index:
minimap2 -t 8 -ax map-ont \
sample.polypolish.fasta \
sample.ont.fastq.gz \
| samtools sort -@ 8 -o sample.ont_to_hybrid.bam
samtools index sample.ont_to_hybrid.bam
samtools quickcheck -v sample.ont_to_hybrid.bam
What each component does
-t 8asks minimap2 to use eight threads. Adjust this to available compute resources.-arequests SAM alignment output. Without it, minimap2 produces PAF, which is useful for some applications but is not the usual input for samtools-based read inspection.-x map-ontselects minimap2’s ONT long-read mapping preset.sample.polypolish.fastais the assembly reference. In this workflow, it should be the final version you intend to interpret, not a pre-polishing draft.sample.ont.fastq.gzcontains the ONT reads.samtools sortwrites a coordinate-sorted BAM directly, avoiding a large intermediate SAM file.samtools indexcreatessample.ont_to_hybrid.bam.bai, enabling region-based queries.samtools quickcheck -vreports serious BAM truncation or structural problems. Silence generally means it found no problem.
Do not add --secondary=no at this validation stage. Secondary alignments are informative precisely because repeats and homologous plasmid sequence can produce ambiguous placements. You may later filter them for a clean candidate-read list, but first you should know whether ambiguity exists.
Initial checks: did mapping behave plausibly?
samtools flagstat sample.ont_to_hybrid.bam
samtools idxstats sample.ont_to_hybrid.bam
samtools coverage sample.ont_to_hybrid.bam
These commands provide complementary summaries:
flagstatcounts mapped and unmapped records and reports secondary/supplementary alignments.idxstatsreports mapped records per assembly contig; an unexpectedly unsupported plasmid contig deserves scrutiny.coverageprovides breadth and depth summaries by contig.
These are context checks, not connectivity tests. Uniform depth across a plasmid supports its presence in the sequenced DNA, but coverage alone cannot prove that a carbapenemase cassette sits on that plasmid or that the plasmid is circular.
If a putative plasmid has little or no read support, possible explanations include an assembly artefact, a contaminating low-abundance sequence, an incorrect read file, a naming mix-up, or a real plasmid lost between DNA preparations. Resolve those basic issues before interpreting a junction.
Define the exact claim before querying reads
A reproducible junction analysis starts with a coordinate-defined claim. Avoid notes such as “looked around bla gene.” Instead, record:
-
Assembly file and version
For example, the Polypolish output and its checksum. -
Contig name and length
For example,plasmid_3, 112,438 bp. -
Feature coordinates and orientation
Such as the carbapenemase gene, flanking insertion sequences, and nearest unique backbone genes. -
Proposed junction coordinate
For an internal join, this is the boundary between the two sequences whose adjacency you wish to validate. -
Required flanking evidence
Decide what counts as informative sequence. A practical starting point is several hundred bases to 1 kb of non-repetitive sequence on each side, adjusted for read length and locus complexity.
The phrase unique flank is important. Consider an IS26 copy next to a carbapenemase gene. A read containing only IS26 plus the gene may map to several locations or even several plasmids. In contrast, a read anchored in a distinctive plasmid backbone gene, crossing IS26, and continuing into the carbapenemase cassette provides a more specific molecular connection.
Use an annotation GFF, AMR result, or sequence search to locate the gene first. Suppose the proposed carbapenemase-cassette boundary lies near position 45,000 on plasmid_3. Inspect a window wide enough to include both flanks:
samtools view -h \
sample.ont_to_hybrid.bam \
"plasmid_3:43000-47000" \
> plasmid_3.carbapenemase_window.sam
This retrieves all alignments that overlap the specified region. It does not guarantee that every retrieved read spans it. Open the SAM file in a wide terminal view or inspect individual records, concentrating on:
- QNAME;
- FLAG;
- POS;
- MAPQ;
- CIGAR;
- optional
SA:Z:tags.
For a cleaner first pass containing mapped primary alignments, excluding unmapped, secondary, and supplementary records:
samtools view -h -F 2308 \
sample.ont_to_hybrid.bam \
"plasmid_3:43000-47000" \
> plasmid_3.carbapenemase_primary.sam
Here, :
- : unmapped;
- : secondary;
- : supplementary.
This filter is useful for finding simple, continuous candidates. It must be paired with a separate review of supplementary alignments:
samtools view -h -f 2048 \
sample.ont_to_hybrid.bam \
"plasmid_3:43000-47000" \
> plasmid_3.carbapenemase_supplementary.sam
A high-quality primary alignment extending across both flanks is the cleanest support. Supplementary records may instead show that a read transitions to another contig, suggesting a structural discrepancy, a repeat-mediated ambiguity, or a genuine integration/rearrangement not represented correctly by the assembly.
Decide whether a read truly spans an internal carbapenemase-region junction
For an internal junction at coordinate , a read should satisfy all of the following before you call it supporting evidence:
-
It maps across rather than merely ending or beginning nearby.
-
It has substantial aligned sequence on both sides.
If your predefined flank requirement is 500 bp, the alignment should begin at or before and extend to or beyond . -
The flanks are informative.
They should not both be copies of a ubiquitous insertion sequence, transposase, or repeated resistance-gene segment. -
The alignment is structurally coherent.
Prefer a continuous primary alignment. If there is clipping or supplementary mapping, investigate whether it has a biological explanation. -
The placement is credible.
Consider MAPQ, the presence of secondary alignments, and whether the same sequence occurs elsewhere in the assembly.
The aligned end coordinate cannot be read directly from POS alone. It is determined from POS and the CIGAR string. CIGAR operations that consume reference positions—such as M, =, X, D, and N—advance the reference coordinate. Insertions and clipping consume read sequence but do not advance along the reference.
For example, if a read begins at 43,700 and has a near-continuous alignment of 5000M, it extends to approximately 48,699 on the reference. It comfortably spans a proposed junction at 45,000. If it begins at 44,700 and has 250M4000S, it overlaps the window but supports only 250 aligned bases past its start; it does not establish connectivity through the whole locus.
How to interpret MAPQ without turning it into a rigid cutoff
MAPQ is the mapper’s assessment of how uniquely and confidently the read was placed. A high MAPQ is reassuring, but it is not a direct measure of base accuracy. Low MAPQ often occurs when a long read contains a repeated element that matches multiple plasmids, multiple parts of one plasmid, or both chromosome and plasmid sequence.
For a carbapenemase cassette surrounded by repeats:
- High MAPQ plus unique flanks is strong mapping evidence.
- Low MAPQ but an alignment visibly anchored in long unique flanks may still be useful; inspect competing alignments before discarding it.
- Low MAPQ with sequence confined to a mobile repeat or AMR cassette is not reliable evidence of a specific location.
- Many secondary alignments signal that the assembly contains sequence too similar for unambiguous placement.
Avoid a rule such as “MAPQ 60 proves the junction” or “MAPQ below 20 means false.” The question is whether the entire molecular path is distinguishable from alternatives.
Test whether a plasmid is circular
Circular plasmids must be written as linear FASTA sequences, with an arbitrary first base and last base. Therefore, an assembler may report a contig as circular, but a useful validation question remains: do raw ONT reads cross the represented end-to-end boundary?
A method used in plasmid genomics is to create a doubled version of the proposed plasmid sequence:
original plasmid sequence + identical original plasmid sequence
The join at the original contig length is an artificial representation of the circular end-to-end junction. A real read from a circular plasmid that crosses the original FASTA break can map continuously across that central join.
The following study describes that same underlying principle.
Read the short “Plasmid detection and annotation” subsection of this hospital-genomics study. It illustrates why long reads are mapped to an end-to-end fused plasmid sequence when testing proposed circular plasmids.
In “Plasmid detection and annotation,” read from the circularity-validation method. Focus on the reasoning, not the specific plasmIDent software: contig ends are fused, Nanopore reads are mapped across that artificial fusion site, and continuous support is interpreted as evidence compatible with circularity.
Create a doubled plasmid reference
First extract the contig of interest from the assembly. Replace plasmid_3 with the exact FASTA contig name:
samtools faidx sample.polypolish.fasta plasmid_3 > plasmid_3.fa
One transparent way to double the extracted sequence uses Biopython:
python - <<'PY'
from Bio import SeqIO
record = next(SeqIO.parse("plasmid_3.fa", "fasta"))
sequence = str(record.seq)
print(f">{record.id}_doubled")
print(sequence + sequence)
PY
Save that output as plasmid_3.doubled.fa. Index the original extracted plasmid to obtain its length:
samtools faidx plasmid_3.fa
cat plasmid_3.fa.fai
If the original plasmid length is , the central artificial junction in the doubled reference is at coordinate . Map the same ONT reads to the doubled sequence:
minimap2 -t 8 -ax map-ont \
plasmid_3.doubled.fa \
sample.ont.fastq.gz \
| samtools sort -@ 8 -o sample.ont_to_plasmid_3_doubled.bam
samtools index sample.ont_to_plasmid_3_doubled.bam
Now inspect a window around the central junction. For a plasmid of length 112,438 bp, a 2 kb window centred on the junction would be:
samtools view -h \
sample.ont_to_plasmid_3_doubled.bam \
"plasmid_3_doubled:111438-113438" \
> plasmid_3.circular_junction.sam
A read that aligns continuously through the central junction, with convincing sequence on both sides, supports circularity. Record its QNAME, aligned coordinates, MAPQ, CIGAR, and how many bases it contributes on either side.
Important circularity caveats
Circular-junction support can be compelling, but do not overstate it.
- Several independent spanning reads are preferable to one read, especially where coverage permits.
- No spanning read is not proof of linearity. Low coverage, short reads relative to the plasmid, or read-length filtering may simply leave no read that crosses the arbitrary break.
- A read mapping across the doubled junction must be specific. Highly repetitive plasmids or near-identical plasmids can produce ambiguous alignments.
- Continuous coverage around a circular plasmid is not itself junction evidence. It shows that the sequence is represented in the data; an individual read crossing the artificial fusion is the direct test.
Test a suspected plasmid–chromosome integration
A carbapenemase-bearing region may be integrated into the chromosome, particularly when transposons or insertion sequences mediate mobilisation. The essential question is not “does the chromosome contain carbapenemase sequence?” but “does a single DNA molecule connect chromosomal flank, mobile element, and plasmid-like sequence at the proposed boundaries?”
Suppose annotation and sequence comparison identify a plasmid-like segment inserted into a chromosomal contig. Define two boundaries:
- the left chromosome–insert boundary;
- the insert–right chromosome boundary.
For each boundary, query a window that includes unique chromosomal sequence and sequence within the putative insertion:
samtools view -h \
sample.ont_to_hybrid.bam \
"chromosome:2540000-2544000" \
> left_integration_boundary.sam
samtools view -h \
sample.ont_to_hybrid.bam \
"chromosome:2618000-2622000" \
> right_integration_boundary.sam
The exact coordinates are illustrative; use your own assembly and annotation. A robust integration interpretation requires support at both boundaries. A single read that touches an insertion sequence at one side is insufficient, because that sequence may occur on a separate plasmid or elsewhere in the chromosome.
The possible evidence patterns are worth distinguishing:
| Observation | Interpretation |
|---|---|
| Multiple reads bridge both boundaries with unique chromosomal anchors | Strong support for the integrated configuration in this isolate. |
| Reads support plasmid sequence and chromosome sequence separately, but none bridges either boundary | Integration remains unresolved; the plasmid may be separate, or coverage may be inadequate. |
| Reads bridge one boundary but not the other | Could indicate incomplete assembly, a repeat-mediated ambiguity, or insufficient evidence; do not call a complete integration. |
| Reads have split mappings between a chromosome and a plasmid contig | Investigate carefully. This may be an integration signal, assembly break, chimeric read, or repeated mobile element. |
| The claimed plasmid–chromosome junction has only low-MAPQ repeat-derived alignments | The location is unresolved; report the mobile element or cassette, not a definite integration site. |
This is particularly important in Enterobacter cloacae complex and Citrobacter genomes, where plasmids, transposons, and repeated insertion sequences can create deceptively plausible assembly paths.
A compact evidence workflow for every locus
Use the following sequence whenever you validate a carbapenemase-bearing structure.
-
Specify the structural claim.
State whether you are testing an internal cassette junction, circular plasmid junction, or chromosome–plasmid integration boundary. -
Identify informative flanks.
Locate unique backbone or chromosomal sequence on each side. Do not rely solely on the carbapenemase gene or an insertion sequence. -
Map raw ONT reads to the final assembly.
Useminimap2 -ax map-ont, followed by sorted and indexed BAM generation. -
Check contig-level support.
Useflagstat,idxstats, andcoverageto identify obviously unsupported or anomalous contigs. -
Retrieve reads overlapping a coordinate window.
Usesamtools viewwithcontig:start-end. -
Inspect primary alignments for continuous bridging.
Check the aligned start, CIGAR, endpoint, MAPQ, and flanking sequence context. -
Inspect secondary and supplementary records.
Treat them as diagnostic evidence of ambiguity or structural discordance, not as noise to hide. -
Record a conclusion calibrated to the evidence.
Use language such as “supported by three independent long reads spanning unique flanks,” “consistent with circularity but limited by low coverage,” or “unresolved because all supporting alignments are repeat-associated.”
A useful per-junction record contains:
| Field | Example |
|---|---|
| Isolate | ENV_sink_042 |
| Assembly version | Autocycler plus Polypolish, final |
| Structure tested | Carbapenemase cassette insertion in plasmid backbone |
| Reference contig and interval | plasmid_3:43000-47000 |
| Left and right flanks | replication-backbone region; conjugation-associated region |
| Candidate spanning reads | Read IDs and orientations |
| Alignment evidence | MAPQ, CIGAR, aligned span, primary or supplementary status |
| Ambiguities | IS26 copies at three assembly locations |
| Conclusion | Supported / consistent but unresolved / not supported |
| Next corroborating evidence | Assembly graph, short-read depth, alternate assembly, comparative plasmid alignment |
What spanning reads can—and cannot—establish
Spanning-read analysis is powerful because it returns to the physical sequencing molecules. But it still has limits.
It can provide direct support that:
- a carbapenemase cassette connects to a particular plasmid backbone;
- a proposed plasmid circular junction is represented by reads;
- a plasmid-like region is integrated at a specified chromosomal position;
- an assembly join lacks long-read support and should be reviewed.
It cannot, by itself, establish that:
- the plasmid transferred from the environment to a patient rather than in the opposite direction;
- the plasmid is autonomously conjugative;
- the detected carbapenemase is expressed;
- all copies of a repeated cassette have been reconstructed correctly;
- an unsupported junction is definitely wrong.
In particular, do not use long-read junction support alone to decide between one and three tandem carbapenemase copies. Repeats require a combined assessment of short-read depth, long reads anchored in unique flanks, repeat-junction support, and the assembly graph. That focused comparison is the next step in this module.
Key takeaways
A hybrid assembly is a hypothesis about molecular structure; long-read mapping tests that hypothesis at specific, biologically meaningful boundaries. For a carbapenemase-region claim, seek reads that bridge the full region from informative left flank to informative right flank—not merely reads that contain the resistance gene.
Use minimap2 with the ONT preset to map raw reads to the final assembly, then use sorted, indexed BAM files and samtools view to inspect locus-specific alignments. Evaluate QNAME, FLAG, MAPQ, CIGAR, alignment span, flanking uniqueness, and supplementary records together. For circular plasmids, map reads to a doubled plasmid reference and inspect the artificial central end-to-end fusion.
Next, you will apply this reasoning to the particularly challenging situation in which a Unicycler assembly reports one carbapenemase copy while an Autocycler assembly reports three tandem copies.
Can't find a good explanation? Sign up and we'll make it for you
Sign up