Hi, I have a DNAStringSet list and I would like to convert it in a character vector but as.character does not work because it gives me a vector of "<S4 object of class \"DNAStringSet\">".
Could you help me?
Thank you.
Riccardo
Hi, I have a DNAStringSet list and I would like to convert it in a character vector but as.character does not work because it gives me a vector of "<S4 object of class \"DNAStringSet\">".
Could you help me?
Thank you.
Riccardo
I guess you have something like
a = DNAStringSet(c("AAA", "TTT")) b = DNAStringSet(c("GGG", "CCC")) dsl = DNAStringSetList(a, b)
which displays as
> dsl DNAStringSetList of length 2 [[1]] AAA TTT [[2]] GGG CCC
You could unlist this and coerce
> as.character(unlist(dsl)) [1] "AAA" "TTT" "GGG" "CCC"
but that removes the grouping of DNA strings. Another option is to coerce to a CharacterList, which behaves like a plain-old-list where each element is a character vector.
> cl = as(dsl, "CharacterList") > cl CharacterList of length 2 [[1]] AAA TTT [[2]] GGG CCC
Or make this into a plain-old-list
> as.list(cl) [[1]] [1] "AAA" "TTT" [[2]] [1] "GGG" "CCC"
But I guess the question is, why do you want to do this? Maybe the step is unnecessary.
Thank you! I want to do this because I have to do a merge between two data frame, in one of them there is a column with character values and in the other table there is another column with DNAStringSet values.
Riccardo
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Provide a short example, maybe using the DNAStringSetList I created, to illustrate what you want to do. Add the example by editing your original question.
In the future, use 'ADD COMMENT' if you are commenting on an answer someone has provided.