find points on a graph

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

find points on a graph

EvaMarie
Hey guys, Can anyone help?

I did a correspondance analysis and made a plot.

I also have a specific list of nodes that i want to find in my plot and want to either color the nodes that appear in my list differently, or put some kind of border around that group of nodes...

Would anyone know how to do this?

Also, would this post be more relevant here or in the bioconductor forum?
Reply | Threaded
Open this post in threaded view
|

Re: find points on a graph

Milan Bouchet-Valat
Le mercredi 07 mars 2012 à 01:40 -0800, aoife a écrit :
> Hey guys, Can anyone help?
>
> I did a correspondance analysis and made a plot.
>
> I also have a specific list of nodes that i want to find in my plot and want
> to either color the nodes that appear in my list differently, or put some
> kind of border around that group of nodes...
>
> Would anyone know how to do this?
Not if you don't tell us what package and function you used for this CA.
Can you provide a small reproducible example?

Regards

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: find points on a graph

EvaMarie
Many thanks for your reply.

Yes absolutely. So this is a small example:

> library(ca)
> table <- read.table("test", header=TRUE)
> table
      codon1 codon2 codon3
gene1    4.0      7     11
gene2    7.0    222      8
gene3    0.2      3      8
> ca_analysis <- ca(table)
> plot <- plot(ca_analysis)

and then i took a screen shot of the plot i can see.



so now for example i have a seperate file with 2 gene names:
gene2
gene3

and i want to find these two genes/nodes on the graph, and either highlight them a different color, or draw a border/shade them in some way. basically highlight them in any way?

is this any more helpful to explain what i mean?

Aoife

Reply | Threaded
Open this post in threaded view
|

Re: find points on a graph

David Carlson
You did not provide reproducible data since you didn't give us the "test"
file or any values for gene4 and gene5. You should read the posting
guideline (particularly the use of dput) and the documentation for package
ca.

I'm assuming that you want to plot supplementary rows (as described in the
ca documentation). Using your values, making some up for gene4 and gene5,
and combining them with the original data, you want the following:

table <- structure(c(4, 7, 0.2, 3, .1, 7, 222, 3, 10, 5, 11,
    8, 8, 10, 7), .Dim = c(5L, 3L), .Dimnames = list(c("gene1",
    "gene2", "gene3", "gene4", "gene5"), c("codon1", "codon2",
    "codon3")))
Library(ca)
plot(ca(table, suprow=c(4, 5)))

This uses the first 3 rows for the correspondence analysis and then plots
rows 4 and 5 in that space using an open circle.

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


> -----Original Message-----
> From: [hidden email] [mailto:r-help-bounces@r-
> project.org] On Behalf Of aoife
> Sent: Wednesday, March 07, 2012 6:03 AM
> To: [hidden email]
> Subject: Re: [R] find points on a graph
>
> Many thanks for your reply.
>
> Yes absolutely. So this is a small example:
>
> > library(ca)
> > table <- read.table("test", header=TRUE)
> > table
>       codon1 codon2 codon3
> gene1    4.0      7     11
> gene2    7.0    222      8
> gene3    0.2      3      8
> > ca_analysis <- ca(table)
> > plot <- plot(ca_analysis)
>
> and then i took a screen shot of the plot i can see.
>
> http://r.789695.n4.nabble.com/file/n4453046/Screen_shot_2012-03-
> 07_at_12.00.44.png
>
> so now for example i have a seperate file with 2 gene names:
> gene2
> gene3
>
> and i want to find these two genes/nodes on the graph, and either
> highlight
> them a different color, or draw a border/shade them in some way.
> basically
> highlight them in any way?
>
> is this any more helpful to explain what i mean?
>
> Aoife
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/find-
> points-on-a-graph-tp4452746p4453046.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: find points on a graph

EvaMarie
Thank you. I really appreciate the help.

May i ask two questions.

In the example below:

table <- structure(c(4, 7, 0.2, 3, .1, 7, 222, 3, 10, 5, 11,
    8, 8, 10, 7), .Dim = c(5L, 3L), .Dimnames = list(c("gene1",
    "gene2", "gene3", "gene4", "gene5"), c("codon1", "codon2",
    "codon3")))
Library(ca)
plot(ca(table, suprow=c(4, 5)))

i get an output plot like this:



is it possible to add in code somewhere so that the nodes of interest are not open circles, but are encompassed by a  shading on them, similar to this:




And my second question, in this line of the code here:
plot(ca(table, suprow=c(4, 5)))

is it possible to edit "suprow=c(4, 5)" to say "suprow=c(the genes that are in a certain file)", i.e rather than manually type each gene in, get the code to read in a file?

When i try move "gene 4" and "gene 5" to a seperate file, and try to read it in, i get:

> plot <- ca(table,suprow=c(file))
Error in sort.int(x, na.last = na.last, decreasing = decreasing, ...) :
  'x' must be atomic

Many thanks for your time.
Reply | Threaded
Open this post in threaded view
|

Re: find points on a graph

EvaMarie
May i please update my question, and I understand now something that i did not yesterday.

In this example:

table <- structure(c(4, 7, 0.2, 3, .1, 7, 222, 3, 10, 5, 11,
    8, 8, 10, 7), .Dim = c(5L, 3L), .Dimnames = list(c("gene1",
    "gene2", "gene3", "gene4", "gene5"), c("codon1", "codon2",
    "codon3")))

Library(ca)

> list <-scan("test_list", what=list(gene=""))      ### where test_list is a file containing the words  "gene4", "gene5"

plot(ca(table, suprow=c(4, 5)))

Question 1: is it possible to change:

plot(ca(table, suprow=c(4, 5)))

to either:

plot(ca(table, suprow=c(0-100))  ## e.g. a range of numbers (i have about 100 rows that i need to highlight, so i'd rather not do manually)

or:

plot(ca(table, suprow=c(test_list))) ### where i've given it a file with list of nodes, and R can find the rows that these nodes are on and highlight these.
 
And then my second question is the same as previous regarding the plot output, is it possible to shade rather than have open circles.

Many thanks.