According to the documentation (
width(x): A vector of non-negative integers containing the number of
letters for each element in
x. Note that
also defined for a character vector with no NAs and is
NULL or a character vector of the same length as
containing a short user-provided description or comment for
each element in
x. These are the only data in an
XStringSet object that can safely be changed by the user. All
the other data are immutable! As a general recommendation,
the user should never try to modify an object by accessing
its slots directly.
as.character(x, use.names=TRUE): Converts
x to a character vector
of the same length as
use.names argument controls
whether or not
names(x) should be propagated to the names
of the returned vector.
This should be enough for you to create a
dss2df <- function(dss) data.frame(width=width(dss), seq=as.character(dss), names=names(dss))
Also, if you have a huge
DNAStringSet, perhaps you do not want to convert all the sequences to characters; storing sequences as characters supposedly is less efficient. For plotting it might be sufficient to have just widths.