mulder4786 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks! I'm facing a conundrum that I cannot even begin to solve using my limited Perl knowledge.
I have multiple (~50) square correlation matrices that are very large (on the order of 1700 x 1700). A small portion of one might look like:
The matrices are overlapping for about 95% of the ~1700 row/column IDs. For those IDs that are missing in a matrix, I would like to print "0" placeholders. For example, given another matrix:rs12272511 rs7107801 rs11027752 rs12421837 rs12272511 1.0 -0.023 -0.511 -0.046 rs7107801 -0.023 1.0 0.040 0.233 rs11027752 0.494 0.514 1.0 0.501 rs12421837 -0.039 -0.040 0.021 1.0
As this second matrix is missing the ID "rs7107801", I would like to add this ID in with a value of "0":rs12272511 rs11027752 rs12421837 rs12272511 1.0 .844 .276 rs11027752 .267 1.0 -.980 rs12421837 -.876 .374 1.0
I will then hopefully be able to use the matrices with placeholders (all matrices will now have equal dimensions) in order to calculate weighted averages. The matrices are all space-delimited. Can someone point me in the right direction?rs12272511 rs7107801 rs11027752 rs12421837 rs12272511 1.0 0 .844 .276 rs7107801 0 0 0 0 rs11027752 .267 0 1.0 -.980 rs12421837 -.876 0 .374 1.0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: combining multiple matrices with placeholders if row and column values in one matrix do not exist in another
by BrowserUk (Patriarch) on Jan 14, 2016 at 02:29 UTC | |
by mulder4786 (Novice) on Jan 14, 2016 at 14:47 UTC | |
|
Re: combining multiple matrices with placeholders if row and column values in one matrix do not exist in another
by hdb (Monsignor) on Jan 14, 2016 at 08:29 UTC | |
|
Re: combining multiple matrices with placeholders if row and column values in one matrix do not exist in another
by Anonymous Monk on Jan 14, 2016 at 03:48 UTC | |
|
Re: combining multiple matrices with placeholders if row and column values in one matrix do not exist in another
by Anonymous Monk on Jan 14, 2016 at 02:10 UTC |