[Bioc-sig-seq] how to sort reads by ids

Martin Morgan mtmorgan at fhcrc.org
Sun Sep 18 22:10:24 CEST 2011


On 09/18/2011 10:10 AM, wang peter wrote:
> thx
> i know how to sort reads by ids
>
>
> rm(list=ls())#
> fastqfile="query.fastq"
> library(ShortRead)
> reads<- readFastq(fastqfile);#
> ids<- as.character(id(reads)); #
> ids<- sort(ids, method = "sh", index.return=TRUE)

   idx = order(id(reads))
   reads[idx]

Advanced: sort / order / rank are tricky on character() vectors; they 
obey LOCALE collation order Sys.getlocale(). Use Sys.setlocale(locale="C")

Martin


> reads<-reads[ids$ix]
>
> 	[[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


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioc-sig-sequencing mailing list