C
Chris Lasher
Hello Pythonistas!
I'm looking for a way to duplicate entries in a symmetrical matrix
that's composed of genetic distances. For example, suppose I have a
matrix like the following:
A B C
A 0.000000 0.500000 1.000000
B 0.500000 0.000000 0.500000
C 1.000000 0.500000 0.000000
Say I want to duplicate entry B; the resulting matrix would look like:
A B B C
A 0.000000 0.500000 0.500000 1.000000
B 0.500000 0.000000 0.000000 0.500000
B 0.500000 0.000000 0.000000 0.500000
C 1.000000 0.500000 0.500000 0.000000
The cases I'd like to do this for are more complicated, naturally,
where I want to duplicate different entries different numbers of times.
I'm aware of Numeric, Numarray, and NumPy, though I've not used any of
them, but I am not sure if any of them possess a simple means to
duplicate entries in a matrix. I started writing code on my own but I
can see it is becoming exponentially more complex, and before I proceed
any further, I want to make sure I'm not reinventing any wheels. If
anyone here has any advice on how to manipulate matrices in this
manner, I'd _greatly_ appreciate it!
Thanks in advance,
Chris
I'm looking for a way to duplicate entries in a symmetrical matrix
that's composed of genetic distances. For example, suppose I have a
matrix like the following:
A B C
A 0.000000 0.500000 1.000000
B 0.500000 0.000000 0.500000
C 1.000000 0.500000 0.000000
Say I want to duplicate entry B; the resulting matrix would look like:
A B B C
A 0.000000 0.500000 0.500000 1.000000
B 0.500000 0.000000 0.000000 0.500000
B 0.500000 0.000000 0.000000 0.500000
C 1.000000 0.500000 0.500000 0.000000
The cases I'd like to do this for are more complicated, naturally,
where I want to duplicate different entries different numbers of times.
I'm aware of Numeric, Numarray, and NumPy, though I've not used any of
them, but I am not sure if any of them possess a simple means to
duplicate entries in a matrix. I started writing code on my own but I
can see it is becoming exponentially more complex, and before I proceed
any further, I want to make sure I'm not reinventing any wheels. If
anyone here has any advice on how to manipulate matrices in this
manner, I'd _greatly_ appreciate it!
Thanks in advance,
Chris