[R] how to work with long vectors

Martin Morgan mtmorgan at fhcrc.org
Fri Nov 5 17:45:49 CET 2010


On 11/05/2010 09:42 AM, Martin Morgan wrote:

> ## first time only
> source("http://bioconductor.org")

oops, source("http://bioconductor.org/biocLite.R")

> biocLite("IRanges")
> 
> ##
> library(IRanges)
> contigs = IRanges(start=1, width=matt$reads)
> cvg = coverage(contigs) ## an RLE summarizing coverage, from position 1
> as.vector(cvg[matt$reads]) / nrow(matt)  ## at the end of each contig
> 
> for a larger data set:
> 
>> matt=data.frame(reads=ceiling(as.integer(runif(3384766, 1, 100))))
>> contigs = IRanges(start=1, width=matt$reads)
>> system.time(cvg <- coverage(contigs))
>    user  system elapsed
>   5.145   0.050   5.202
> 
> Martin
> 
>>>>>
>>>>>
>>>>> Thanks so much!
>>>>>
>>>>>
>>>>> --
>>>>> Sincerely,
>>>>> Changbin
>>>>> --
>>>>>
>>>>>        [[alternative HTML version deleted]]
>>>>>
>>>>> ______________________________________________
>>>>> R-help at r-project.org mailing list
>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>> PLEASE do read the posting guide
>>>>> http://www.R-project.org/posting-guide.html
>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>>
>>>>>
>>>
>>>
>>> --
>>> Sincerely,
>>> Changbin
>>> --
>>>
>>> Changbin Du
>>> DOE Joint Genome Institute
>>> Bldg 400 Rm 457
>>> 2800 Mitchell Dr
>>> Walnut Creet, CA 94598
>>> Phone: 925-927-2856
>>>
>>>
>>>
>>
>>
> 
> 


-- 
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 R-help mailing list