Title: | Sequence Alignment and Visualization Tool |
---|---|
Description: | Computes the optimal alignment of two character sequences. Visualizes the result of the alignment in a matrix plot. Needleman, Saul B.; Wunsch, Christian D. (1970) "A general method applicable to the search for similarities in the amino acid sequence of two proteins" <doi:10.1016/0022-2836(70)90057-4>. |
Authors: | Leonard Persson Norblad [aut, cre] , Kamil Slowikowski [ctb] |
Maintainer: | Leonard Persson Norblad <[email protected]> |
License: | GPL-3 |
Version: | 0.1.1 |
Built: | 2024-11-04 06:22:55 UTC |
Source: | CRAN |
Performs sequence alignment on two sequences by a user specified alignment method. As of now, only the Needleman-Wunsch algorithm is supported.
align_sequences(seq1, seq2, d, mismatch, match, method = "needleman")
align_sequences(seq1, seq2, d, mismatch, match, method = "needleman")
seq1 |
First sequence to align. |
seq2 |
Second sequence to align. |
d |
Gap penalty, should be negative. |
mismatch |
Mismatch penalty, should be negative. |
match |
Match score, should be positive. |
method |
Name of alignment algorithm. Currently only supports "needleman". |
Object of class alignment
representing the alignment result.
This object can be utilized with the plot.alignment
function to visualize
the alignment matrix and the print.alignment
function to display alignments
in the console.
For more details on the Needleman-Wunsch algorithm, see the wikipedia page.
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1)
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1)
Produces a plot displaying the alignment matrix of seq1
and seq2
.
## S3 method for class 'alignment' plot(x, ...)
## S3 method for class 'alignment' plot(x, ...)
x |
Object of class |
... |
Additional parameters to be passed to the |
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.
Plot of the alignment matrix.
The implementation is inspired by the visualization (code) by Kamil Slowikowski (ORCID).
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)
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)
Prints the alignments between seq1
and seq2
with the highest score.
## S3 method for class 'alignment' print(x, ...)
## S3 method for class 'alignment' print(x, ...)
x |
Object of class |
... |
Additional parameters to be passed to the |
The printed message includes the alignment score. This function may display multiple alignments, as alignments with the same score are possible.
Console print of alignments.
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm alignment1 <- align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1) # Print the alignments print(alignment1)
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm alignment1 <- align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1) # Print the alignments print(alignment1)
Sequence alignment and visualization tool designed to enhance understanding of sequence alignment algorithms, such as the Needleman-Wunsch algorithm. Through detailed matrix plot visualizations with arrows illustrating the path of different alignments, users can gain insights into how these algorithms score and identify optimal alignments between two sequences.
Install the SeqAlignR package from CRAN using:
install.packages("SeqAlignR")
Load the SeqAlignR package into your R session:
library(SeqAlignR)
Explore the documentation for align_sequences
or see the example below:
?align_sequences
Leonard Persson Norblad [email protected] (ORCID)
The graphics in the package were inspired by this code by Kamil Slowikowski (ORCID).
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm alignment1 <- align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1, method="needleman") # Print the alignments print(alignment1) # Plot the matrix plot(alignment1)
seq1 <- "GCATGCG" seq2 <- "GATTACA" # Run the Needleman-Wunsch algorithm alignment1 <- align_sequences(seq1, seq2, d = -1, mismatch = -1, match = 1, method="needleman") # Print the alignments print(alignment1) # Plot the matrix plot(alignment1)