[R] Help on comparing two matrices

Steve Lianoglou mailinglist.honeypot at gmail.com
Mon Aug 24 00:09:11 CEST 2009


On Sun, Aug 23, 2009 at 4:14 PM, Michael Kogan<michael.kogan at gmx.net> wrote:
> Thanks for all the replies!
> Steve: I don't know whether my suggestion is a good one. I'm quite new to
> programming, have absolutely no experience and this was the only one I could
> think of. :-) I'm not sure whether I'm able to put your tips into practice,
> unfortunately I had no time for much reading today but I'll dive into it
> tomorrow.

Ok, yeah. I'm not sure what the best way to do this myself, I would at
first see if one could reduce these matrices by some principled manner
and then do a comparison, which might jump to:

> Ted: Wow, that's heavy reading. In fact the matrices that I need to compare
> are incidence matrices so I suppose it's exactly the thing I need, but I
> don't know if I have the basics knowledge to understand this paper within
> the next months.

Ted's sol'n. I haven't read the paper, but its title gives me an idea.
Perhaps you can assume the two matrices you are comparing are
adjacency matrices for a graph then use the igraph library to do a
graph isomorphism test between the two graphs represented by your
adjacency matrices and see if they are the same.

This is probably not the most efficient (computationally) way to do
it, but it might be the quickest way out coding-wise.

I see your original example isn't using square matrices, and an
adjacency matrix has to be square. Maybe you can pad your matrices
with zero rows or columns (depending on what's deficient) as an easy
way out.

Just an idea.

Of course, if David's solution is what you need, then no need to
bother with any of this.


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list