Re: [R] how to work with long vectors

2010-11-05 Thread Changbin Du
HI, Phil, I used the following codes and run it overnight for 15 hours, this morning, I stopped it. It seems it is still not efficient.

Re: [R] how to work with long vectors

2010-11-05 Thread Martin Morgan
On 11/05/2010 09:13 AM, Changbin Du wrote: HI, Phil, I used the following codes and run it overnight for 15 hours, this morning, I stopped it. It seems it is still not efficient.

Re: [R] how to work with long vectors

2010-11-05 Thread Martin Morgan
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,

Re: [R] how to work with long vectors

2010-11-05 Thread Changbin Du
Thanks Martin! I will try it and will let your guys know how it goes. On Fri, Nov 5, 2010 at 9:42 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 11/05/2010 09:13 AM, Changbin Du wrote: HI, Phil, I used the following codes and run it overnight for 15 hours, this morning, I stopped it.

Re: [R] how to work with long vectors

2010-11-05 Thread William Dunlap
wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Changbin Du Sent: Friday, November 05, 2010 9:14 AM To: Phil Spector Cc: r-help@r-project.org Subject: Re: [R] how to work with long vectors HI, Phil, I used

Re: [R] how to work with long vectors

2010-11-05 Thread Changbin Du
05, 2010 9:14 AM To: Phil Spector Cc: r-help@r-project.org Subject: Re: [R] how to work with long vectors HI, Phil, I used the following codes and run it overnight for 15 hours, this morning, I stopped it. It seems it is still not efficient. matt-read.table(/house/groupdirs

Re: [R] how to work with long vectors

2010-11-05 Thread William Dunlap
Of William Dunlap Sent: Friday, November 05, 2010 9:58 AM To: Changbin Du Cc: r-help@r-project.org Subject: Re: [R] how to work with long vectors The following cover_per_3 uses sorting to solve the problem more quickly. It still has room for improvement. cover_per_3 - function (data

[R] how to work with long vectors

2010-11-04 Thread Changbin Du
HI, Dear R community, I have one data set like this, What I want to do is to calculate the cumulative coverage. The following codes works for small data set (#rows = 100), but when feed the whole data set, it still running after 24 hours. Can someone give some suggestions for long vector? id

Re: [R] how to work with long vectors

2010-11-04 Thread jim holtman
Is this what you want: x id reads 1 Contig79:1 4 2 Contig79:2 8 3 Contig79:313 4 Contig79:414 5 Contig79:517 6 Contig79:620 7 Contig79:725 8 Contig79:827 9 Contig79:932 10 Contig79:1033 11 Contig79:1134 x$percent -

Re: [R] how to work with long vectors

2010-11-04 Thread Henrique Dallazuanna
Try this: rev(100 * cumsum(matt$reads 1) / length(matt$reads) ) On Thu, Nov 4, 2010 at 1:46 PM, Changbin Du changb...@gmail.com wrote: HI, Dear R community, I have one data set like this, What I want to do is to calculate the cumulative coverage. The following codes works for small data

Re: [R] how to work with long vectors

2010-11-04 Thread Changbin Du
Thanks, Jim! This is not what I want, What I want is calculate the percentage of reads bigger or equal to that reads in each position.MY output is like the following: for row 1, all the reads is = 4, so the cover_per is 100, for row 2, 99 % reads =4, so the cover_per is 99. head(final)

Re: [R] how to work with long vectors

2010-11-04 Thread Changbin Du
HI, Henrique, Thanks for the great help! I compared the output from your codes: te-rev(100 * cumsum(matt$reads 1) / length(matt$reads) ) te [1] 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 [19] 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65

Re: [R] how to work with long vectors

2010-11-04 Thread Martin Morgan
On 11/04/2010 09:45 AM, Changbin Du wrote: Thanks, Jim! This is not what I want, What I want is calculate the percentage of reads bigger or equal to that reads in each position.MY output is like the following: Hi Changbin -- I might be repeating myself, but the Bioconductor packages

Re: [R] how to work with long vectors

2010-11-04 Thread Changbin Du
Thanks Martin, I will try this. On Thu, Nov 4, 2010 at 10:06 AM, Martin Morgan mtmor...@fhcrc.org wrote: On 11/04/2010 09:45 AM, Changbin Du wrote: Thanks, Jim! This is not what I want, What I want is calculate the percentage of reads bigger or equal to that reads in each position.MY

Re: [R] how to work with long vectors

2010-11-04 Thread Phil Spector
Changbin - Does 100 * sapply(matt$reads,function(x)sum(matt$reads = x))/length(matt$reads) give what you want? By the way, if you want to use a loop (there's nothing wrong with that), then try to avoid the most common mistake that people make with loops in R: having your result grow

Re: [R] how to work with long vectors

2010-11-04 Thread Changbin Du
Thanks Phil, that is great! I WILL try this and let you know how it goes. On Thu, Nov 4, 2010 at 10:16 AM, Phil Spector spec...@stat.berkeley.eduwrote: Changbin - Does 100 * sapply(matt$reads,function(x)sum(matt$reads = x))/length(matt$reads) give what you want? By the way, if