[Bioc-sig-seq] iteration on two Rle Views

Martin Morgan mtmorgan at fhcrc.org
Wed Feb 16 18:01:43 CET 2011


On 02/16/2011 06:13 AM, Michael Lawrence wrote:
> On Tue, Feb 15, 2011 at 5:01 PM, supat thongjuea
> <supat.thongjuea at gmail.com>wrote:
> 
>> Hi,
>>
>> I have two Rle views call chip.views and contr.views. I would like to speed
>> up the iteration for getting the coefficient values from the linear
>> regression model.
>> I used sapply for those two Views but it is quite slow to get  coefficient
>> value from around 10,000 Views. Do you have any suggestion how to speed up
>> this?.
>>
>>                    chip.cov <-coverage(chip.GRanges.uniq)
>>                    contr.cov<-coverage(contr.GRanges.uniq)
>>                    window.size=100000
>>                    step.size = window.size
>>                    ends <- seq(from=window.size,to=chr.size,by=step.size)
>>                    starts <-
>> seq(from=1,to=chr.size-window.size,by=step.size)
>>                    chip.views<-Views(chip.cov[[1]],starts,ends)
>>                    contr.views<-Views(contr.cov[[1]],starts,ends)
>>
>>                    factor<-sapply(1:length(chip.views),function(x)
>>
>> lsfit(as.integer(chip.views[[x]]),as.integer(contr.views[[x]]))$coefficients[[2]])
>>
>>
> Not sure about speeding this up, but for the sake of clarity anyway, you
> might want to use the viewApply() function instead of sapply here.

Supat -- you might try to profile your code to identify where the
slowness is; see ?Rprof. If it is actually in lsfit then perhaps a
little direct algebra on the two vectors (instead of lsfit) will more
efficiently calculate the coefficient you're interested in.

Martin

> 
> Michael
> 
> Best regards,
>> Supat Thongjuea
>>
>>        [[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
>>
> 
> 	[[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