[Bioc-sig-seq] subsetting a DNAStringSet

Martin Morgan mtmorgan at fhcrc.org
Mon Aug 23 23:55:26 CEST 2010

  On 8/23/2010 1:28 PM, Andrew Yee wrote:
> Take the following DNAStringSet foo as follows
> x<- DNAStringSet('AGAT')
> y<- DNAStringSet('GGGTTCC')
> z<- DNAStringSet('GGGCC')
> foo<- c(x,y,z)
> names(foo)<- c('x','y','z')
> I'm interested in creating a new DNAStringSet of just x and y.  How do I go
> about doing this?
> At first, I thought you could do something like
> c(foo['x'], foo['y'])
> but this generates an error message, "cannot subset a DNAStringSet by
> names."

you might do foo[match(c("x", "y"), names(foo))]; I suspect that the 
issue here is that row names of a data frame need to be unique, but not 
of a DNAStringSet, so one has to be explicit about handling duplicates.

   DNAStringSet(c(x="AAA", x="TTT"))

(the latter might suggest more efficient ways of constructing the 
object). Note that my 'match' solution only finds the first, and not 
all, matches.

> Thanks,
> Andrew
> 	[[alternative HTML version deleted]]
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing

More information about the Bioc-sig-sequencing mailing list