metaMDS()
「ビーガン」パッケージを使用して、種のデータセットでこの序列分析を行いました。私は複数の次元を使用しているので、これらの次元のうち 3 つを 3D プロットに表示するとよいと思いました。「ビーガン」パッケージにはいくつかの 3D 機能がありますが、結果はあまり明確ではありません。この「クモ」をこのorglspider()
関数を使用して表示できます。私はむしろ「ordihull」のようなものを持っていますが、3D グラフとしてではありません。「alphashape3d」パッケージを使用すると、これを行うことができます。必要に応じて 3D シェイプを正確に描画できます。問題は、同じフレームにこれらの形状を 3 つプロットする必要があることです。私は試した"add=T"
しかし、これは機能しません。2 番目と 3 番目の形状の呼び出し方法を変更する必要があると思いますが、これを行う方法がわかりません。これまでに試したことの例を次に示します。
### Load the packages
require(vegan)
require(alphashape3d)
### Create some data
a <- c(0.5654292, 0.1960973, 0.0000000, 0.2536315, 0.1960973, 0.4658166, 0.3315565, 0.6865024, 0.7044823, 0.4385855)
b <- c(0.7093823, 0.2409255, 0.3269156, 0.0000000, 0.0000000, 0.3269156, 0.0000000, 0.0000000, 0.0000000, 0.4625978)
c <- c(0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.0000000, 0.1022538, 0.4618177, 0.0000000, 0.0000000, 0.0000000)
d <- c(0.00000000, 0.16692171, 0.00000000, 0.22649864, 0.09400543, 0.42456471, 0.79331157, 0.72986751, 0.93837435, 0.65106335)
loc <- c("U", "U", "U", "A", "A", "U", "A", "A", "A", "U")
data <- data.frame(a,b,c,d)
#### Run the mds analysis to obtain the points that should be plotted
mdsB <- metaMDS(data, distance = "bray", autotransform = FALSE, trace = 0,k=3)
### Split the points in the mds object up into two groups
mdsBA <- mdsB
mdsBU <- mdsB
mdsBA$points <- mdsBA$points[which(loc=='A'), ]
mdsBU$points <- mdsBU$points[which(loc=='U'), ]
### Create the 3d shape just like the ordihull function does for 2d shapes
ashape3d.A <- ashape3d(unique(as.matrix(mdsBA$points[,1:3])), alpha = 1.19)
ashape3d.U <- ashape3d(unique(as.matrix(mdsBU$points[,1:3])), alpha = 1.19)
### plot the first shape and try to add the second one.
plot(ashape3d.A,bycom=TRUE,tran=0.2,shininess=0, col="lightgoldenrod")
plot(ashape3d.U,bycom=TRUE,tran=0.2,shininess=0, col="lightgoldenrod", add=T)