[R] my first R program

kannaiah at bsd.uchicago.edu kannaiah at bsd.uchicago.edu
Tue May 23 19:58:41 CEST 2006


I have attached a graph image of what i am trying to plot.
The x-axis in the image(rs*), would correspond to the position column in my
first file. The ticks are not equidistant but are placed based on their
proportionate distance from the eachother.
So, the horizontal line i need to draw would be for example:
from file 2:
col1 =1 corresponds to position 120(in file1)
col2 = 2 (position 134)
p-value = 0.45 (p-val on y-axis, actually i will be plotting the -log10 of p-val)

so i am trying to draw a line from positions 120 to 134 on x-axis at their
corresponding p-value(0.45) on y-axis

What i have done so far:
1) read the files into a data frame object:
   mpos = read.table("file 1", header=TRUE)
   snpem = read.table("file 2", header=TRUE)
2) snpem[4] = -log10(snpem[3])
3) i tried some of the suggestions that i got from people here...
   so trying to map the position col(first file) to the col1 and col2 didnt work

   position = mpos[2]
   col1 = snpem[1]
   so, now when i did position[col1], it was giving an error

Thanks for the help..

-kiran


 
 



Quoting Albyn Jones <jones at reed.edu>:

> I'm not sure I understand what you are trying to do exactly, but
> "to associate the col1 and col2 with their corresponding position values"
> looks like
> 
>      (position[col1], position[col2])
> 
> so you _might_ want something like
> 
>    
> plot(position[col1],pval,xlim=c(110,175),ylim=c(0,1),type="n",xlab="Position")
>     segments(position[col1],pval, position[col2],pval)
>     abline(h=.5)
> 
> regards
> 
> albyn
> 
> 
> Quoting kannaiah at bsd.uchicago.edu:
> 
> > Hello,
> >
> > This is my first attempt at using R. Still trying to figure out and 
> > understand
> > how to work with data frames.
> > I am trying to plot the following data(example). Some experimental data i
> am
> > trying to plot here.
> >
> > 1) i have 2 files
> > 2) First File:
> > 	Number	Position
> > 	  1	120
> > 	  2	134
> > 	  3	156
> > 	  4	169
> >          5	203
> > 3) Second File:
> > 	Col1 	Col2	p-val
> > 	1	2 	0.45
> > 	1	2	0.56
> > 	2	3	0.56
> > 	2	3	0.68
> > 	2	3	0.88
> > 	3	4	0.76
> > 	3	5	0.79
> > 	3	5	0.92
> >
> > I am trying to plot this with "position" as x-axis and "p-val" as the
> y-axis.
> > The col1 and col2 in the second file correspond to the number column in
> first
> > file.
> >
> > I am having trouble to figure out how to associate the col1 and col2 with
> > their corresponding position values
> >
> > The x-axis should start with 120 as that is the min value and next values
> > should be spaced proportionally away from the
> > first. I tried using the percentage method to place them...but couldnt
> > completely get it correct.
> >
> > so it would look like :
> > 	|   |        |    |          |
> > 	120 134      156  169        203
> >
> > Hopefully i explained it correctly.
> >
> > i would like to plot the p-value as horizontal lines drawn between the
> col1
> > and col2 values (ie: positions)
> > So, the plot will have as many horizontal lines as the rows in the 
> > second file.
> > And ONE reference horizontal line passing thru the plot at p-val=0.5, to
> see
> > what values lie below that and what above it.
> >
> >
> > I have made some progress in plotting the horizontal axis, but having
> trouble
> > bringing all the data together.Not sure yet how to
> > manipulate them using the data frames:(
> >
> > Any suggestions and tips will be greatly appreciated.
> >
> > Thank you
> > -Kiran
> >
> >
> >
> >
> > -------------------------------------------------
> > This email is intended only for the use of the individual
> or...{{dropped}}
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> >
> 
> 
> 
> 
> 
> 
> 





-------------------------------------------------
This email is intended only for the use of the individual or entity to which
it is addressed and may contain information that is privileged and
confidential.  If the reader of this email message is not the intended
recipient, you are hereby notified that any dissemination, distribution, or
copying of this communication is prohibited.  If you have received this email
in error, please notify the sender and destroy/delete all copies of the
transmittal.  Thank you.
-------------------------------------------------


More information about the R-help mailing list