Question

I am using R to cluster a matrix which I have named 'tissuedata'. I have a hclust object which was generated using the following code:

    TissueDist<-dist(tissuedata, method="euclidean")
    TissueClust<-hclust(TissueDist, method='complete')

Now I want to print out the row names from TissueClust while preserving the order of the clustered rows. Any suggestions?

Here is an example of what the 'tissuedata' matrix could contain:

                                          Brain      Bone    Breast      Lung Ovary  Pancreas      HeLa
    17271422_17271984_ENSG00000026025 -3.266758  0.000000 -3.215719 -5.248721     0 -2.891329 -3.718194
    17272608_17272709_ENSG00000026025 -4.304518 -4.560667 -3.359868  0.000000     0 -3.108627 -4.227678
    17272632_17272709_ENSG00000026025 -4.188425 -4.444906 -3.243362  0.000000     0 -2.992122 -4.111259
    17272649_17272709_ENSG00000026025 -3.984628 -4.338187 -3.104413  0.000000     0 -2.791452 -3.828157
    17275586_17275681_ENSG00000026025 -3.278478 -3.932706 -2.903414 -4.480172     0 -2.781268 -3.423038
    17276692_17276817_ENSG00000026025 -3.355184 -4.351640 -3.009279  0.000000     0 -3.231431 -4.194499
    17276692_17276850_ENSG00000026025 -3.456211 -4.453457 -3.110306  0.000000     0 -3.332458 -4.294992
    17277845_17277888_ENSG00000026025 -3.842749 -4.195861 -2.661506  0.000000     0 -2.373369 -3.436403
    17277845_17277908_ENSG00000026025 -4.005683 -4.358526 -2.824233  0.000000    -1 -2.536096 -3.599131
Was it helpful?

Solution

I am not sure if I understood the question right.....

# $labels gives orginal ordering form matrix
TissueClust$labels

# $order gives the permutation of the original observations
# see ?hclust detail section
TissueClust$order

# not sure, but are you looking for this?
TissueClust$labels[c(TissueClust$order)]

hth

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top