R: AlignedXStringSet and QualityAlignedXStringSet objects
AlignedXStringSet-class
R Documentation
AlignedXStringSet and QualityAlignedXStringSet objects
Description
The AlignedXStringSet and QualityAlignedXStringSet classes are
containers for storing an aligned XStringSet.
Details
Before we define the notion of alignment, we introduce the notion of
"filled-with-gaps subsequence". A "filled-with-gaps subsequence" of
a string string1 is obtained by inserting 0 or any number of gaps in
a subsequence of s1. For example L-A–ND and A–N-D are
"filled-with-gaps subsequences" of LAND. An alignment between two strings
string1 and string2 results in two strings (align1 and align2) that have
the same length and are "filled-with-gaps subsequences" of string1 and string2.
For example, this is an alignment between LAND and LEAVES:
L-A
LEA
An alignment can be seen as a compact representation of one set of basic
operations that transforms string1 into align1. There are 3 different kinds
of basic operations: "insertions" (gaps in align1), "deletions" (gaps in
align2), "replacements".
The above alignment represents the following basic operations:
insert E at pos 2
insert V at pos 4
insert E at pos 5
replace by S at pos 6 (N is replaced by S)
delete at pos 7 (D is deleted)
Note that "insert X at pos i" means that all letters at a position >= i
are moved 1 place to the right before X is actually inserted.
There are many possible alignments between two given strings string1 and
string2 and a common problem is to find the one (or those ones) with the
highest score, i.e. with the lower total cost in terms of basic operations.
Accessor methods
In the code snippets below,
x is a AlignedXStringSet or QualityAlignedXStringSet object.
unaligned(x):
The original string.
aligned(x, degap = FALSE):
If degap = FALSE, the "filled-with-gaps subsequence" representing
the aligned substring. If degap = TRUE, the "gap-less subsequence"
representing the aligned substring.
start(x):
The start of the aligned substring.
end(x):
The end of the aligned substring.
width(x):
The width of the aligned substring, ignoring gaps.
indel(x):
The positions, in the form of an IRanges object, of the insertions or
deletions (depending on what x represents).
nindel(x):
A two-column matrix containing the length and sum of the widths for each of
the elements returned by indel.
length(x):
The length of the aligned(x).
nchar(x):
The nchar of the aligned(x).
alphabet(x):
Equivalent to alphabet(unaligned(x)).
as.character(x):
Converts aligned(x) to a character vector.
toString(x):
Equivalent to toString(as.character(x)).
Subsetting methods
x[i]:
Returns a new AlignedXStringSet or QualityAlignedXStringSet
object made of the selected elements.
rep(x, times):
Returns a new AlignedXStringSet or QualityAlignedXStringSet
object made of the repeated elements.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Biostrings)
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: XVector
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/Biostrings/AlignedXStringSet-class.Rd_%03d_medium.png", width=480, height=480)
> ### Name: AlignedXStringSet-class
> ### Title: AlignedXStringSet and QualityAlignedXStringSet objects
> ### Aliases: class:AlignedXStringSet0 AlignedXStringSet0-class
> ### AlignedXStringSet0 class:AlignedXStringSet AlignedXStringSet-class
> ### AlignedXStringSet class:QualityAlignedXStringSet
> ### QualityAlignedXStringSet-class QualityAlignedXStringSet unaligned
> ### unaligned,AlignedXStringSet0-method aligned
> ### aligned,AlignedXStringSet0-method start,AlignedXStringSet0-method
> ### end,AlignedXStringSet0-method width,AlignedXStringSet0-method indel
> ### indel,AlignedXStringSet0-method nindel
> ### nindel,AlignedXStringSet0-method length,AlignedXStringSet0-method
> ### nchar,AlignedXStringSet0-method seqtype,AlignedXStringSet0-method
> ### show,AlignedXStringSet0-method as.character,AlignedXStringSet0-method
> ### toString,AlignedXStringSet0-method [,AlignedXStringSet0-method
> ### [<-,AlignedXStringSet0-method rep,AlignedXStringSet0-method
> ### Keywords: methods classes
>
> ### ** Examples
>
> pattern <- AAString("LAND")
> subject <- AAString("LEAVES")
> nw1 <- pairwiseAlignment(pattern, subject, substitutionMatrix = "BLOSUM50", gapOpening = 3, gapExtension = 1)
> alignedPattern <- pattern(nw1)
> unaligned(alignedPattern)
A AAStringSet instance of length 1
width seq
[1] 4 LAND
> aligned(alignedPattern)
A AAStringSet instance of length 1
width seq
[1] 6 L-A-ND
> as.character(alignedPattern)
[1] "L-A-ND"
> nchar(alignedPattern)
[1] 6
>
>
>
>
>
> dev.off()
null device
1
>