我有 33 个包含微生物群落数据的样本。
我已经使用 full_join 命令将所有 33 个样本合并到一个数据帧中。数据框看起来像这样:
Samp1 Samp2 Samp3 Samp4
species1 0.1 8 0 2
species2 9 0.02 0 1
species3 0.3 1 1 0.1
species4 5 3 0.4 2
非常大:33 列,54,454 行。我需要制作一个距离矩阵来查看列(样本)基于它们的丰度值(列值)的相似程度,这些值基于每个样本中的物种观察结果。从那里(如果我曾经到达那里)我想做 k 意味着聚类。这在 R 中可行吗?我试过了(有相应的错误代码):
fviz_nbclust(samples, kmeans, method = "wss") + geom_vline(xintercept = 3, linetype = 2):
Error in do_one(nmeth) : NA/NaN/Inf in foreign function call (arg 1)
In addition: Warning messages:
1: In stats::dist(x) : NAs introduced by coercion
2: In storage.mode(x) <- "double" : NAs introduced by coercion
以及:
mat <- dist(samptest, method = "euclidean"):
Error in FUN(left, right) : non-numeric argument to binary operator
谢谢