Displaying 2 results from an estimated 2 matches for "cover_per".
2010 Nov 04
4
how to work with long vectors
...5.1129.trim_69.fastq.19621832.sub.sorted.bam.clone.depth",
sep="\t", skip=0, header=F,fill=T) #
dim(matt)
[1] 3384766 2
matt_plot<-function(matt, outputfile) {
names(matt)<-c("id","reads")
cover<-matt$reads
#calculate the cumulative coverage.
+ cover_per<-function (data) {
+ output<-numeric(0)
+ for (i in data) {
+ x<-(100*sum(ifelse(data >= i, 1, 0))/length(data))
+ output<-c(output, x)
+ }
+ return(output)
+ }
result<-cover_per(cover)
Thanks so much!
--
Sincerely,
Changbin
--
[[alter...
2010 Nov 01
2
how to save this result in a vector
HI, Dear R community,
I have the following codes to calculate the commulative coverage. I want to
save the output in a vector, How to do this?
test<-seq(10, 342, by=2)
#cover is a vector
cover_per<-function (cover) {
for (i in min(cover):max(cover)) {print(100*sum(ifelse(cover >= i, 1,
0))/length(cover))}
}
result<-cover_per(test)
> result
NULL
Can anyone help me this this?
--
Sincerely,
Changbin
--
[[alternative HTML version deleted]]