我正在使用物种覆盖率数据和环境数据通过VEGAN软件包在2D和3D图中绘制NMDS。我可以根据地点绘制NMDS,但是当我尝试通过NMDS绘制时
" species scores not available
Error in order(x) : argument 1 is not a vector"
错误弹出。我也尝试使用warscores=T
,但是问题仍然存在。我有以下数据类型:
物种数据。我还尝试使用ordihull按处理对数据进行分组,但也不会绘制多边形。
即使我可以绘制NMDS却没有物种评分,我也可以进行物种丰富化。以下是物种数据
Row Labels Acalypha gracilens Acalypha virginica Acer rubrum Acer saccharum Adiantum pedatum Ageratina altissima Agrimonia rostellata Amelanchier arborea Amphicarpa bracteata Anemone virginiana Antennaria parlinii Antenoron virginiana Aralia spinosa Arisaema dracontium Arisaema triphyllum Asimina triloba Asplenium platyneuron Athyrium filix-femina Botrypus virginianus
2014PL1 0 0 0 3.5 0 0 0 0 15.5 0 0 0 0 0 0 0 0 0 0
2014PL10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2014PL11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2014PL12 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2014PL13 0 0 0 0 0 0 0 0 3.5 0 0 0 0 0 0 0 0 0 0
2014PL14 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2014PL15 0 0 0 0 0 0 0 0 15.5 0 0 0 0 0 0 0 0 0 0
2014PL16 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0
2014PL17 0 0 0 15.5 0 0 0 0 0.5 0 0 0 0 0 0 0 0 0 0
2014PL18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
2014PL19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3.5 0 0 0
2014PL2 0 0 0 3.5 0 0 0 0.5 3.5 0 0 0 0 0 0 0 0 0 0
2014PL20 0 0 0 3.5 0 0 0 0 0 0 0 0 0 0 0 63 0 15.5 0
环境数据看起来像
Treatment elevation slope_per AspectDir PPT TMEAN TMIN TMAX sprichness shanentrop invsimpson
2014PL1 Burn First 181 56 North 1070 13 7 18 6 4.00621539 3.2647854
2014PL10 Thin First 170 21 Southwest 1070 13 7 18 11 3.596290814 3.212736502
2014PL11 Burn First 181 11 North 1070 13 7 18 5 2.733395222 2.081998115
2014PL12 Control West 159 14 Southwest 1070 13 7 18 3 1.919417872 1.592798768
2014PL13 Control West 168 16 South 1070 13 7 18 17 7.633877547 6.004748813
2014PL14 Control East 168 26 Northeast 1070 13 7 18 11 4.062814017 2.995957554
2014PL15 Control East 180 8 Northeast 1070 13 7 18 13 6.689341767 5.228200972
2014PL16 Burn First 170 46 Southwest 1070 13 7 18 9 2.711557879 1.755060729
2014PL17 Thin First 176 26 South 1070 13 7 18 7 2.621677069 2.050662739
代码:
## Import species data and environmental data##
comm <- read.table("species.csv",header=TRUE, row.names=1, sep=",")
singleton_Comm<- comm[,colSums(comm>0)>1, drop=F]
#comm_wis_trans<-wisconsin(singleton_Comm)
dm_matrix<-vegdist(singleton_Comm)
#Generate stress values for 1-4 dimensional NMDS and make scree plot
ord1d<-metaMDS(dm_matrix, distance = "bray", k = 1,wascores=TRUE, trymax = 100)
#print(ord1d$stress)
ord2d <- metaMDS(dm_matrix, distance = "bray", k = 2,wascores=TRUE, trymax = 100)
#print(ord2d$stress)
ord3d <- metaMDS(dm_matrix, distance = "bray", k = 3,wascores=TRUE, trymax = 100)
#print(ord3d$stress)
ord4d <- metaMDS(dm_matrix, distance = "bray", k = 4,wascores=TRUE, trymax = 100)
#print(ord4d$stress)
#stress<-c(ord1d$stress, ord2d$stress, ord3d$stress, ord4d$stress)
#plot(stress, xlab = "Number of Dimensions", ylab = "Stress")
stress<-c(ord1d$stress, ord2d$stress, ord3d$stress, ord4d$stress)
##Plotting stress of different ordination##
par(mfrow=c(2,2))
stressplot(ord1d)
stressplot(ord2d)
stressplot(ord3d)
plot(stress, xlab = "Number of Dimensions", ylab = "Stress")
##Importing the Environment Variables##
environment <- read.table("environment.csv",header=TRUE, row.names=1, sep=",")
env<-data.frame(environemnt[1:11])
##Vector fitting environment variables and richness index with 3rd ordination because only 3rd ord has less than0.2 stress##
vectors1 <- envfit(ord2d, env, na.rm = TRUE, permu = 999, choices = 1:2)
vectors <- envfit(ord3d, env, na.rm = TRUE, permu = 999, choices = 1:3)
#Plotting NMDS using 2D species score and sites
ordiplot(ord2d, choices = c(1, 2), type="points", display = "sites", xlim = c(-0.5,0.7), ylim = c(-0.5,0.5),
cex = 0.7)
ordiplot(ord2d, choices = c(1, 2), type="points", display = "species", xlim = c(-0.5,0.7), ylim = c(-0.5,0.5),
cex = 0.7)
#fitting ordihull
ordihull(ord2d,groups=env$Treatment,draw="polygon",col="red",label=T)
#Plotting using 3D
ord3dplotyear <- ordirgl(ord3d, display = "sites", choices = 1:3, col = c(rep("red"), rep("orange"), rep("yellow"), rep("green")))
ord3dplotyear <- ordirgl(ord3d, display = "species", choices = 1:3, col = c(rep("red"), rep("orange"), rep("yellow"), rep("green")))
ordihull(ord2d,groups=treatment,draw="polygon",col="red",label=T)
我期望NMDS图显示物种得分和处理,物种得分和海拔等