==.sq {tidysq} | R Documentation |
Compare sq objects
Description
Compares input sq
object with either
another sq
object or character
vector.
Usage
## S3 method for class 'sq'
e1 == e2
Arguments
e1 |
[ |
e2 |
[ |
Details
`==`
compares compatible object for equality of their respective
sequences. Objects are considered compatible, when either both have same
length or one of them is a scalar value (i.e. a vector of length 1).
Moreover, not every e1
sq type can be compared to any e2
sq
type.
To see which types are compatible, see Details of
sq-concatenate
.
`==`
returns logical vector, where each element describes whether
elements at position n
of both e1
and e2
are equal in
meaning (that is, they may be represented differently, but their biological
interpretation must be identical). If one of compared objects is a scalar,
then said logical vector describes comparison for each element of the other,
longer vector.
Value
A logical
vector indicating on which positions these
objects are equal.
See Also
Functions from utility module:
get_sq_lengths()
,
is.sq()
,
sqconcatenate
,
sqextract
Examples
# Creating objects to work on:
sq_dna_1 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT"),
alphabet = "dna_bsc")
sq_dna_2 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT"),
alphabet = "dna_bsc")
sq_dna_3 <- sq(c("ACTGCTG", "CTTAGA", "GGAA"),
alphabet = "dna_bsc")
sq_dna_4 <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "GTNANN"),
alphabet = "dna_ext")
sq_ami_1 <- sq(c("ACTGCTG", "NIKAAR", "CCCT", "CTGAATGT"),
alphabet = "ami_bsc")
sq_unt <- sq(c("AHSNLVSCTK$SH%&VS", "YQTVKA&#BSKJGY",
"CCCT", "AVYI#VSV&*DVGDJCFA"))
# Comparing sq object with an object of the same length:
sq_dna_1 == sq_dna_2
sq_dna_1 == c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT")
# Cannot compare sq objects of different lengths:
## Not run:
sq_dna_1 == sq_dna_3
sq_dna_1 == c("AAA", "CCC")
## End(Not run)
# Unless comparing sq object with scalar value:
sq_dna_1 == "CTTAGA"
# It's possible to compare basic and extended types:
sq_dna_1 == sq_dna_4
# Mixing DNA, RNA and amino acid types throws an error, however:
## Not run:
sq_dna_1 == sq_ami_1
## End(Not run)
# On the other hand, unt sq is acceptable everywhere:
sq_dna_1 == sq_unt
sq_dna_4 == sq_unt
sq_ami_1 == sq_unt