Importar os pacotes

library(rio)
library(dendextend)
## 
## ---------------------
## Welcome to dendextend version 1.17.1
## Type citation('dendextend') for how to cite the package.
## 
## Type browseVignettes(package = 'dendextend') for the package vignette.
## The github page is: https://github.com/talgalili/dendextend/
## 
## Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues
## You may ask questions at stackoverflow, use the r and dendextend tags: 
##   https://stackoverflow.com/questions/tagged/dendextend
## 
##  To suppress this message use:  suppressPackageStartupMessages(library(dendextend))
## ---------------------
## 
## Anexando pacote: 'dendextend'
## O seguinte objeto é mascarado por 'package:stats':
## 
##     cutree
library(pvclust)
## Registered S3 method overwritten by 'pvclust':
##   method       from      
##   text.pvclust dendextend
library(factoextra)
## Carregando pacotes exigidos: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa

importação damatriz de distância

setwd("C:/Users/hugo_/OneDrive/Documentos/Doutorado/Aulas métodos não convencionais/Avaliação/Géis SSR")

mat <- import("Distancia_R.xlsx")

rownames(mat) <- 1:15

mat <- as.dist(mat)

agrupamento hierárquico (UPGMA) e correlação cofenética

hc <- hclust(mat, method = "average")
biotools::mantelTest(cophenetic(hc), mat, graph = FALSE)
## 
##             Mantel's permutation test
## 
## Correlation: 0.7433397
## p-value: 0.001, based on 999 matrix permutations
## Alternative hypothesis: true correlation is greater than 0

dendograma com linha de corte (Mojena)

mojena <- (mean(hc$height) + sd(hc$height)*1.25)
plot(hc, ylab = "Distância", xlab = "")
abline(h = mojena, col = 'red')