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
In reply to combining multiple matrices with placeholders if row and column values in one matrix do not exist in another by mulder4786
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |