Learn R Programming

SeqAlignR (version 0.1.1)

plot.alignment: Plot Alignment Matrix

Description

Produces a plot displaying the alignment matrix of seq1 and seq2.

Usage

# S3 method for alignment
plot(x, ...)

Value

Plot of the alignment matrix.

Arguments

x

Object of class alignment (see align_sequences).

...

Additional parameters to be passed to the plot() function.

Details

The first sequence (seq1) is represented by the columns and the second sequence (seq2) is represented by the rows. The first column and first row are left bank, meaning a gap. Each cell in the matrix displays the score. The subtitle states the match, mismatch and gap penalty d used in the algorithm. A mismatch is shown by the red arrows, a match by the blue arrows, and a gap by the green arrows. The alignment(s) with the highest score are highlighted with thick gray borders.

References

The implementation is inspired by the visualization (code) by Kamil Slowikowski (ORCID).

Examples

Run this code
seq1 <- "GCATGCG"
seq2 <- "GATTACA"
# Run the Needleman-Wunsch algorithm
alignment1 <- align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1)
# Plot the matrix
plot(alignment1)

Run the code above in your browser using DataLab