I get the error as in the title, when I try to do betadisper on my dissimilarity matrix. When looking at my environment it clearly says 'dist'.
as.dist() doesn't help
#fhf is a phyloseq object
veganotu = function(physeq) {
require("vegan")
OTU = otu_table(physeq)
if (taxa_are_rows(OTU)) {
OTU = t(OTU)
}
return(as(OTU, "matrix"))
}
Group <- sample_names(fhf)
dissimilarity_matrix <- vegdist(veganotu(fhf), method="bray")
homogen <- betadisper(dissimilarity_matrix ~ Group)
anova(homogen)
I expect a result similar to this, but with other values:
Analysis of Variance Table
Response: Distances Df Sum Sq Mean Sq F value Pr(>F) Groups 5 0.021037 0.0042074 1.5524 0.252 Residuals 11 0.029813 0.0027103
Error message:
Error in betadisper(dissimilarity_matrix ~ Group) : distances 'd' must be a 'dist' object