Test an sq
object for presence of
empty sequences.
is_empty_sq(x)
# S3 method for sq
is_empty_sq(x)
[sq
]
An object this function is applied to.
A logical vector of the same length as input sq
, indicating
whether elements are empty sequences (of length 0).
This function allows identification of empty sequences (that have
length 0) represented by the NULL sq
values in the sq object. It
returns a logical value for every element of the sq
object -
TRUE
if its value is NULL sq
and FALSE
otherwise.
NULL sq
values may be introduced as a result of
remove_ambiguous
and remove_na
functions. The
former replaces sequences containing ambiguous elements with NULL sq
values, whereas the latter replaces sequences with NA
values with
NULL sq
.
Functions that clean sequences:
remove_ambiguous()
,
remove_na()
# Creating an object to work on:
sq_dna_ext <- sq(c("ACGATTAGACG", "", "GACGANTCCAGNTAC"),
alphabet = "dna_ext")
# Testing for presence of empty sequences:
is_empty_sq(sq_dna_ext)
#> [1] FALSE TRUE FALSE
# Testing for presence of empty sequences after cleaning - sequence
# containing ambiguous elements is replaced by NULL sq:
sq_dna_bsc <- remove_ambiguous(sq_dna_ext)
is_empty_sq(sq_dna_bsc)
#> [1] FALSE TRUE TRUE
# Testing for presence of empty sequences after using bite and removing NA.
# Extracting letters from first to fifteenth - NA introduced:
bitten_sq <- bite(sq_dna_ext, 1:15)
#> Warning: some sequences are subsetted with index bigger than length - NA introduced
# Removing NA:
rm_bitten_sq <- remove_na(bitten_sq)
# Testing for presence of empty sequences:
is_empty_sq(rm_bitten_sq)
#> [1] TRUE TRUE FALSE