[R] Plot two matrices and keeping the record of row names

Bansal, Vikas vikas.bansal at kcl.ac.uk
Mon Oct 31 23:16:26 CET 2011


Dear Peter,

Thanks for your reply.I am familiar with this solution but I was trying to make the plot user friendly.I have seen some plots,in which if we keep a cursor on any point of plot,it will automatically shows you the row names.Is it possible? I did not find anything related to this.

Thanking you,
Warm Regards
Vikas Bansal
Msc Bioinformatics
Kings College London
________________________________________
From: Peter Alspach [Peter.Alspach at plantandfood.co.nz]
Sent: 31 October 2011 22:08
To: Bansal, Vikas; r-help at r-project.org
Subject: RE: Plot two matrices and keeping the record of row names

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 ...{{dropped:15}}



More information about the R-help mailing list