[R] Plot two matrices and keeping the record of row names
Peter Alspach
Peter.Alspach at plantandfood.co.nz
Mon Oct 31 23:08:53 CET 2011
Tena koe Vikas
If I understand you correctly, you could generate a character matrix the elements of which are the row.names and col.names of x1 pasted together (perhaps with : as a separator). Then the upper.tri of this will give you the associations.
HTH ...
Peter Alspach
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Bansal, Vikas
> Sent: Tuesday, 1 November 2011 10:46 a.m.
> To: r-help at r-project.org
> Subject: [R] Plot two matrices and keeping the record of row names
>
>
>
> Dear all,
> I am having this trouble and posted this query before.Can you please
> help me.
> I have two matrices- x1 and y1 with same row names and column
> names(actually the names of the patients).
>
> x1
>
> a b c d e
> a 1.0000000 0.4730679 0.6226994 0.6036036 0.6433333
> b 0.4730679 1.0000000 0.6227273 0.6303855 0.5730858
> c 0.6226994 0.6227273 1.0000000 0.7290503 0.6900585
> d 0.6036036 0.6303855 0.7290503 1.0000000 0.7096774
> e 0.6433333 0.5730858 0.6900585 0.7096774 1.0000000
>
>
> y1
> <UrlBlockedError.aspx>
>
> a b c d e
> a 1.0000000 0.00 0.5000000 0.00 0.3333333
> b 0.0000000 1.00 0.0000000 0.25 0.0000000
> c 0.5000000 0.00 1.0000000 0.00 0.1666667
> d 0.0000000 0.25 0.0000000 1.00 0.0000000
> e 0.3333333 0.00 0.1666667 0.00 1.0000000
>
>
>
> basically these two matrices are the similarity matrices between the
> patients. x1 is genotypically and y1 is phenotypically.
> Now I want to generate a plot to see which patients have high
> similarity genotypically as well as phenotypically. So I am using
>
> plot(x1[upper.tri(x1)],y1[upper.tri(y1)]) #taking only
> the upper triangle of matrices as other half is same.
>
> The plot is coming fine.But I am loosing the row names,therefore I have
> no idea which patients are on the top right corner of the plot.
>
> Can you please help me.I will be very thankful to you.
>
>
> Thanking you,
> Warm Regards
> Vikas Bansal
> Msc Bioinformatics
> Kings College London
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
The contents of this e-mail are confidential and may be subject to legal privilege.
If you are not the intended recipient you must not use, disseminate, distribute or
reproduce all or any part of this e-mail or attachments. If you have received this
e-mail in error, please notify the sender and delete all material pertaining to this
e-mail. Any opinion or views expressed in this e-mail are those of the individual
sender and may not represent those of The New Zealand Institute for Plant and
Food Research Limited.
More information about the R-help
mailing list