Your code does not work because Tag is not numeric. You need to exclude Tag
from the data frame df and instead assign it as rownames. Also, dist
requires a numeric matrix, not data frame.

df = as.matrix(data.frame(Healthy, Tumour, Metastasis))
or
df = cbind(Healthy, Tumour, Metastasis)

rownames(df) = Tag

Then continue as in your code.

Peter



On Thu, Mar 26, 2020 at 8:10 AM Luigi Marongiu <marongiu.lu...@gmail.com>
wrote:

> Dear all,
> I have built a hierarchical clustering on some data as follows:
> ```
> Tag = c(
>   "YP_008603282", "NP_054035",    "BAA00606",     "NP_054034",
>  "NP_054033",
>   "AAC17846" ,    "NP_054036",    "YP_073767" ,   "BAQ20411",     "P52455")
> Healthy = c(
>   12.15540751,  2.33103008,  1.46924258,  0.26274009,  0.95217008,
>   -0.08197491,  0.09038259, -0.08197491, -0.25433241, -0.08197491)
> Tumour = c(
>   12.51939026,  1.20983671,  0.61459705,  0.61459705,  0.81301027,
>   0.21777061,  -0.17905583, -0.17905583, -0.17905583,  0.01935739)
> Metastasis = c(
>   12.55328882,  1.04722513,  1.04722513,  0.70881149,  0.37039785,
>   0.20119103, 0.20119103,    0.20119103,  0.20119103,  0.03198422)
> df = data.frame(Tag, Healthy, Tumour, Metastasis, stringsAsFactors = FALSE)
> d <- dist(df, method = "euclidean")
> hc1 <- hclust(d, method = "complete" )
> plot(hc1)
> ```
>
> Is there a way to add the Tag column instead of the numbers to the leaves
> of the dendrogram?
> Thank you
>
> --
> Best regards,
> Luigi
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to