[R] plot xy data
David Winsemius
dwinsemius at comcast.net
Sat Nov 26 17:15:37 CET 2011
On Nov 25, 2011, at 11:27 PM, sutada Mungpakdee wrote:
> Hi,
>
> Has anyone know about how to get the correct plot?
>
> I have use this R script (as below), so I expect the plot is based
> on x axis, but the result was opposite. Any suggestion will be great.
You question doesn't make clear what you expected and what you are
seeing. I also do not see why you added library(IRanges) because I see
nothing from that package in the code. We cannot run it because the
data is not provided and you made not effort to construct a
data.frame that would match the attributes of the real "data". It
would be better of course to call your data something other than "dog".
>
> library(IRanges)
> data <-read.table(file="~/q20snpref/
> illusmp454merbed",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<-10001
> rangefrom<-0
> rangeto<-length(data[,"sca_position"])
> data.10kb<-runmed(data[,"coverage"],k=window)
> png(file="cov_10k.png",width=1000,height=1000)
> plot(x=data.
> 10kb
> [rangefrom
> :rangeto
> ],y
> =
> data
> [rangefrom
> :rangeto
> ,"sca_position
> "],pch=".",cex=1,xlab="depth",ylab="bp_position",type="p")
If you want to swap the roles of "data.10kb" (AKA "coverage") and
"sca_position" then just reverse the x and y assignments.
> dev.off()
>
> Best regards,
> Sutada
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list