Debs Majumdar
2013-Feb-26 21:04 UTC
[R] Adding markers and text for some data points after drawing a plot
Hi All, I have a data set of around 17,000 gene names and their lengths. E.g. gene kblength A3GALT2 14.333 AADACL3 12.609 AADACL4 22.532 ABCA4 128.312 ABCB10 42.114 ABCD3 100.287 ............ ......... and I was able to draw a reverse cumulative frequency plot using the following code: d <- read.table("gene_length_data.txt", header=T) attach(d) kblength.ecdf <-ecdf(kblength) r <-range(kblength) curve(1-kblength.ecdf(x), from=r[1], to=r[2], col="red", xlim=r) detach(d) Here's the link to the output: http://www.tiikoni.com/tis/view/?id=5c41810 I want to put markers and the corresponding gene names in the graph for a small list of 6 genes. i.e. say a hollow circle on the curve followed by the corresponding gene name. I am fighting with this but wasn't able to get a solution. Any help is appreciated. Thanks, Debs [[alternative HTML version deleted]]
Greg Snow
2013-Feb-26 21:40 UTC
[R] Adding markers and text for some data points after drawing a plot
What have you tried so far? The points function will add points to an existing graph (base) and the text function will add text to an existing graph. If those don't do what you need then give us some more details. On Tue, Feb 26, 2013 at 2:04 PM, Debs Majumdar <debs_stata@yahoo.com> wrote:> Hi All, > > I have a data set of around 17,000 gene names and their lengths. E.g. > > gene kblength > A3GALT2 14.333 > AADACL3 12.609 > AADACL4 22.532 > ABCA4 128.312 > ABCB10 42.114 > ABCD3 100.287 > ............ > ......... > > and I was able to draw a reverse cumulative frequency plot using the > following code: > d <- read.table("gene_length_data.txt", header=T) > attach(d) > kblength.ecdf <-ecdf(kblength) > r <-range(kblength) > curve(1-kblength.ecdf(x), from=r[1], to=r[2], col="red", xlim=r) > detach(d) > > Here's the link to the output: http://www.tiikoni.com/tis/view/?id=5c41810 > > I want to put markers and the corresponding gene names in the graph for a > small list of 6 genes. i.e. say a hollow circle on the curve followed by > the corresponding gene name. > > I am fighting with this but wasn't able to get a solution. > > Any help is appreciated. > > Thanks, > Debs > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > >-- Gregory (Greg) L. Snow Ph.D. 538280@gmail.com [[alternative HTML version deleted]]
David Winsemius
2013-Feb-26 21:54 UTC
[R] Adding markers and text for some data points after drawing a plot
On Feb 26, 2013, at 1:04 PM, Debs Majumdar wrote:> Hi All, > > I have a data set of around 17,000 gene names and their lengths. E.g. > > gene kblength > A3GALT2 14.333 > AADACL3 12.609 > AADACL4 22.532 > ABCA4 128.312 > ABCB10 42.114 > ABCD3 100.287 > ............ > ......... > > and I was able to draw a reverse cumulative frequency plot using the following code: > d <- read.table("gene_length_data.txt", header=T) > attach(d)Using 'attach' is a bad idea. In particular we have trouble keeping straight what is a column name or a first class object in your workspace.> kblength.ecdf <-ecdf(kblength) > r <-range(kblength) > curve(1-kblength.ecdf(x), from=r[1], to=r[2], col="red", xlim=r) > detach(d)> Here's the link to the output: http://www.tiikoni.com/tis/view/?id=5c41810 > > I want to put markersUse points()> and the corresponding gene names in the graph for a small list of 6 genes. i.e. say a hollow circle on the curve followed by the corresponding gene name.text(x= d[ which( d[['gene']]=="AADACL4"), 2], y= kblength.ecdf( d[ which( dat[['gene']]=="AADACL4"), 2]), "AADACL4")> > I am fighting with this but wasn't able to get a solution.> > Any help is appreciated. > > Thanks, > Debs > > [[alternative HTML version deleted]]Please learn to post in plain text. And please, please do read the fine Posting Guide. -- David Winsemius Alameda, CA, USA
Jim Lemon
2013-Feb-26 22:15 UTC
[R] Adding markers and text for some data points after drawing a plot
On 02/27/2013 08:04 AM, Debs Majumdar wrote:> Hi All, > > I have a data set of around 17,000 gene names and their lengths. E.g. > > gene kblength > A3GALT2 14.333 > AADACL3 12.609 > AADACL4 22.532 > ABCA4 128.312 > ABCB10 42.114 > ABCD3 100.287 > ............ > ......... > > and I was able to draw a reverse cumulative frequency plot using the following code: > d<- read.table("gene_length_data.txt", header=T) > attach(d) > kblength.ecdf<-ecdf(kblength) > r<-range(kblength) > curve(1-kblength.ecdf(x), from=r[1], to=r[2], col="red", xlim=r) > detach(d) > > Here's the link to the output: http://www.tiikoni.com/tis/view/?id=5c41810 > > I want to put markers and the corresponding gene names in the graph for a small list of 6 genes. i.e. say a hollow circle on the curve followed by the corresponding gene name. > > I am fighting with this but wasn't able to get a solution.Hi Debs, I think you can get what you want with this: kborder<-order(kblength) example_pos<-c(25,50,75,100,125) text(example_pos,kblength[kborder][example_pos], paste(gene[kborder][example_pos],kblength[kborder][example_pos], sep="\n")) Jim