Hi, I'm very beginner for R but I think it is a time to start as it is very useful.
I have a coverage read file (illusmp454merCbed) for whole genome ~ 450 Mbp. This is head of this file. Scaffold sca_position coverage Scaffold1 1 0 Scaffold1 2 0 Scaffold1 3 0 Scaffold1 4 0 Scaffold1 5 0 Scaffold1 6 0 Scaffold1 7 1 Scaffold1 8 3 Scaffold1 9 3 I would like to plot everage coverage for every 1 kbp for whole genome. May I use R as below? Should I use IRanges? data <-read.table(file="~/q20snpref/illusmp454merCbed",sep="\t",header=F) colnames(data)<-c("Scaffold","sca_position","coverage") depth<-mean(data[,"coverage']) #depth now has the mean (overall)coverage #set the bin-size window<-1001 rangefrom<-0 rangeto<-length(data[,"sca_position"]) data.1kb<-runmean(data[,"coverage"],k=window) png(file="cov_1k.png",width=400,height=1000) plot(x=data[rangefrom:rangeto,"sca_position"],y=data.1kb[rangefrom:rangeto],pch=".",cex1,xlab="bp position",ylab="depth",type="p") dev.off() I got these error. Error: unexpected symbol in: "rangefrom<-0 rangeto<-length(data[,"sca_position" > data.1kb<-runmed(data[,"coverage"],k=window) Error in as.integer(k) : cannot coerce type 'closure' to vector of type 'integer' > png(file="cov_1k.png",width=400,height=1000) > plot(x=data[rangefrom:rangeto,"sca_position"],y=data.1kb[rangefrom:rangeto],pch=".",cex1,xlab="bp > position",ylab="depth",type="p") Error in `[.data.frame`(data, rangefrom:rangeto, "sca_position") : object 'rangefrom' not found I thought that I have done thing wrong, any suggestion will be very helpful. Best regards, Sutada ______________________________________________ R-help@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.