自定义素食排序图
Customising vegan ordination plot
我有一个包含 100 个物种的数据集,因此很难绘制。所以我想挑选出这些物种的一个子集并将它们绘制在 RDA 图中。我一直在关注这个
guideline
代码如下所示:
## load vegan
require("vegan")
## load the Dune data
data(dune, dune.env)
## PCA of the Dune data
mod <- rda(dune, scale = TRUE)
## plot the PCA
plot(mod, scaling = 3)
## build the plot up via vegan methods
scl <- 3 ## scaling == 3
colvec <- c("red2", "green4", "mediumblue")
plot(mod, type = "n", scaling = scl)
with(dune.env, points(mod, display = "sites", col = colvec[Use],
scaling = scl, pch = 21, bg = colvec[Use]))
text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan")
with(dune.env, legend("topright", legend = levels(Use), bty = "n",
col = colvec, pch = 21, pt.bg = colvec))
这就是您最终得到的 plot。现在我真的很想从情节中删除一些物种,但不是分析。所以情节只显示像 Salrep、Viclat、Aloge 和 Poatri。
感谢您的帮助。
您在实际绘图时使用的函数有一个参数 select
(至少 text.cca()
和 points.cca()
。select
采用长度为 i
指示是否应绘制第 i
个事物,或要绘制的事物的(数字)索引。示例将变为:
## Load vegan
library("vegan")
## load the Dune data
data(dune, dune.env)
## PCA of the Dune data
mod <- rda(dune, scale = TRUE)
## plot the PCA
plot(mod, scaling = 3)
## build the plot up via vegan methods
scl <- 3 ## scaling == 3
colvec <- c("red2", "green4", "mediumblue")
## Show only these spp
sppwant <- c("Salirepe", "Vicilath", "Alopgeni", "Poatriv")
sel <- names(dune) %in% sppwant
## continue plotting
plot(mod, type = "n", scaling = scl)
with(dune.env, points(mod, display = "sites", col = colvec[Use],
scaling = scl, pch = 21, bg = colvec[Use]))
text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan",
select = sel)
with(dune.env, legend("topright", legend = levels(Use), bty = "n",
col = colvec, pch = 21, pt.bg = colvec))
这给你:
您还可以使用 goeveg
包中的 ordiselect()
函数:
https://CRAN.R-project.org/package=goeveg
它根据适合坐标轴的丰度 and/or 物种为排序图提供物种选择。
## Select ssp. with filter: 50% most abundant and 50% best fitting
library(goeveg)
sel <- ordiselect(dune, mod, ablim = 0.5, fitlim = 0.5)
sel # 12 species selected
函数的结果对象(包含所选物种的名称)可以放入 select
参数(如上所述)。
我有一个包含 100 个物种的数据集,因此很难绘制。所以我想挑选出这些物种的一个子集并将它们绘制在 RDA 图中。我一直在关注这个 guideline
代码如下所示:
## load vegan
require("vegan")
## load the Dune data
data(dune, dune.env)
## PCA of the Dune data
mod <- rda(dune, scale = TRUE)
## plot the PCA
plot(mod, scaling = 3)
## build the plot up via vegan methods
scl <- 3 ## scaling == 3
colvec <- c("red2", "green4", "mediumblue")
plot(mod, type = "n", scaling = scl)
with(dune.env, points(mod, display = "sites", col = colvec[Use],
scaling = scl, pch = 21, bg = colvec[Use]))
text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan")
with(dune.env, legend("topright", legend = levels(Use), bty = "n",
col = colvec, pch = 21, pt.bg = colvec))
这就是您最终得到的 plot。现在我真的很想从情节中删除一些物种,但不是分析。所以情节只显示像 Salrep、Viclat、Aloge 和 Poatri。
感谢您的帮助。
您在实际绘图时使用的函数有一个参数 select
(至少 text.cca()
和 points.cca()
。select
采用长度为 i
指示是否应绘制第 i
个事物,或要绘制的事物的(数字)索引。示例将变为:
## Load vegan
library("vegan")
## load the Dune data
data(dune, dune.env)
## PCA of the Dune data
mod <- rda(dune, scale = TRUE)
## plot the PCA
plot(mod, scaling = 3)
## build the plot up via vegan methods
scl <- 3 ## scaling == 3
colvec <- c("red2", "green4", "mediumblue")
## Show only these spp
sppwant <- c("Salirepe", "Vicilath", "Alopgeni", "Poatriv")
sel <- names(dune) %in% sppwant
## continue plotting
plot(mod, type = "n", scaling = scl)
with(dune.env, points(mod, display = "sites", col = colvec[Use],
scaling = scl, pch = 21, bg = colvec[Use]))
text(mod, display = "species", scaling = scl, cex = 0.8, col = "darkcyan",
select = sel)
with(dune.env, legend("topright", legend = levels(Use), bty = "n",
col = colvec, pch = 21, pt.bg = colvec))
这给你:
您还可以使用 goeveg
包中的 ordiselect()
函数:
https://CRAN.R-project.org/package=goeveg
它根据适合坐标轴的丰度 and/or 物种为排序图提供物种选择。
## Select ssp. with filter: 50% most abundant and 50% best fitting
library(goeveg)
sel <- ordiselect(dune, mod, ablim = 0.5, fitlim = 0.5)
sel # 12 species selected
函数的结果对象(包含所选物种的名称)可以放入 select
参数(如上所述)。