I have a distance matrix in this form, "_M" being the Mock genes and "_W" being the Wild_type genes. Now the distance matrix shows the distance between each and every gene (Even between mock genes)
ENSG00000186340_M ENSG00000198176_M ENSG00000198742_M ENSG00000204217_M ENSG00000204490_M ENSG00000205250_M ENSG00000243709_M
ENSG00000005339_M 410.1728383 36.10055 83.36385 218.3354 410.770123 277.2033 410.770123
ENSG00000011465_M 0.7504737 409.56151 327.54562 191.2074 1.295231 132.5045 1.295231
ENSG00000039319_M 82.3574833 173.95419 256.39415 390.8659 582.936553 449.1682 582.936553
ENSG00000005339_W ENSG00000011465_W ENSG00000039319_W ENSG00000049323_W ENSG00000055130_W ENSG00000067560_W ENSG00000067900_W
ENSG00000005339_M 221.9562 409.7261224 117.04727 405.669658 193.75271 43.45059 179.09973
ENSG00000011465_M 559.6470 0.6048307 524.45115 3.819013 592.46519 431.00051 588.15446
ENSG00000039319_M 216.2970 581.8796708 57.54276 577.848465 97.77784 163.35507 36.63868
. What I want out of this distance matrix is the distance between all same genes but between Mock and Wild type. For example I want to extract just the sub-matrix.
ENSG00000005339_W ENSG00000011465_W ENSG00000039319_W ENSG00000049323_W ENSG00000055130_W ENSG00000067560_W ENSG00000067900_W
ENSG00000005339_M 221.9562 409.7261224 117.04727 405.669658 193.75271 43.45059 179.09973
ENSG00000011465_M 559.6470 0.6048307 524.45115 3.819013 592.46519 431.00051 588.15446
ENSG00000039319_M 216.2970 581.8796708 57.54276 577.848465 97.77784 163.35507 36.63868
If you could see the gene name is same except for _M or _W at the end of the gene name.How can I extract the sub matrix from my distance matrix?