Supplement 1. R functions used for the analysis.
收藏DataCite Commons2020-09-03 更新2024-07-25 收录
下载链接:
https://wiley.figshare.com/articles/dataset/Supplement_1_R_functions_used_for_the_analysis_/3531572
下载链接
链接失效反馈官方服务:
资源简介:
File List <i><b>All files at once</b></i> supplement_functions.zip <i><b>Function list</b></i> confint.r intasymm.r intereven.r mgen.r mlik.r netstats.r plotmat.r quant2bin.r sortmatr.r sortmatrext.r Description <b>Main functions</b> This supplement contains R functions used for the analyses presented in the main text. Main functions are plotmat, which draws plots of the interaction matrices (Fig. 1); netstats, which calculates aggregate network statistics (Fig. 2); and mlik, which calculates multinomial likelihood and AIC (Fig. 3). Other functions are either called by these main functions to perform operations, or do other related operations. An example of the use of these functions is available in the bipartite package of R (Dormann et al., 2008) (type ?vazquez.example in the R console after installing and uploading the bipartite package). <b>Function descriptions</b> confint -- Confidence intervals of a vector or matrix of simulated values. Used by netstats to calculate 95% confidence intervals of simulated aggregate network statistics. intasymm -- Interaction strength asymmetry, calculated following Vázquez et al. (2007). intereven -- Interaction evenness, calculated following Tylianakis et al. (2007). mgen -- Matrix generating algorithm used by netstats to generate simulated interaction matrices according to a given probability matrix. mlik -- Calculation of multinomial likelihood and AIC according to a given probability matrix. Usage: mlik(imatr, m.p, par), where imatr is the observed interaction matrix, m.p is the probability matrix, and par is the number of parameters used to calculate AIC. netstats -- Aggregate network statistics: connectance, nestedness, interaction evenness and mean interaction strength asymmetry for each group in the network. Usage: netstats(imatr, randomize=TRUE, iter=1000, pmatr=NULL), where imatr is the observed interaction matrix and pmatr is the probability matrix used for generating predicted matrices. The R package bipartite (Dormann et al. 2008) is required by netstats to calculate nestedness. plotmat -- Graphic function to plot interaction matrices as in Fig. 1. Usage: plotmat(imatr, xlabel="PLANTS", ylabel="POLLINATORS", cexmin=0.2, cexmax=2, sortm=TRUE, sqroot=TRUE), where imatr is the interaction matrix to be plotted, xlabel and ylabel are the texts for the <i>x</i> and <i>y</i> axes, cexmin and cexmax are the minimum and maximum sizes of circles representing pairwise interactions, sortm indicates whether matrix should be sorted (sortm=TRUE) or left in the original order (sortm=FALSE), and sqroot indicates whether interaction frequencies (matrix cells) are to be plotted in untransformed or square-root transformed. quant2bin -- Transformation of quantitative matrix into binary. Used by netstats to calculate connectance. sortmatr -- Matrix sorting algorithm used by plotmat. The matrix is sorted according to row and column totals, so that nestedness can be visualized. sortmatrext -- Matrix sorting algorithm used as an alternative to sortmatr. Here, the matrix is sorted according to external vectors instead of row and column totals.
文件列表 **一次性获取全部文件**:supplement_functions.zip;**函数列表**:confint.r、intasymm.r、intereven.r、mgen.r、mlik.r、netstats.r、plotmat.r、quant2bin.r、sortmatr.r、sortmatrext.r
### 说明
#### 主函数
本补充包包含用于正文中所述分析的R语言函数。核心主函数包括:plotmat,用于绘制相互作用矩阵的可视化图(对应图1);netstats,用于计算聚合网络统计量(对应图2);以及mlik,用于计算多项式似然值与赤池信息准则(AIC)(对应图3)。其余函数要么由这些主函数调用以执行具体运算,要么用于实现其他相关功能。
可在R语言的bipartite包(Dormann等,2008年)中查看这些函数的使用示例:安装并加载该包后,在R控制台中输入`?vazquez.example`即可获取相关示例。
#### 函数说明
1. **confint**:用于计算模拟值构成的向量或矩阵的置信区间。由netstats调用,以计算模拟聚合网络统计量的95%置信区间。
2. **intasymm**:相互作用强度不对称性,计算方法遵循Vázquez等(2007年)的研究范式。
3. **intereven**:相互作用均匀度,计算方法遵循Tylianakis等(2007年)的研究范式。
4. **mgen**:矩阵生成算法,由netstats调用,用于根据给定的概率矩阵生成模拟相互作用矩阵。
5. **mlik**:基于给定概率矩阵计算多项式似然值与赤池信息准则(AIC)。使用格式为`mlik(imatr, m.p, par)`,其中`imatr`为观测相互作用矩阵,`m.p`为概率矩阵,`par`为计算AIC时所用的参数个数。
6. **netstats**:聚合网络统计量计算函数,可计算网络中各分组的连接度、嵌套性、相互作用均匀度及平均相互作用强度不对称性。使用格式为`netstats(imatr, randomize=TRUE, iter=1000, pmatr=NULL)`,其中`imatr`为观测相互作用矩阵,`pmatr`为生成预测矩阵所用的概率矩阵。netstats计算嵌套性时需依赖R语言的bipartite包(Dormann等,2008年)。
7. **plotmat**:相互作用矩阵可视化函数,可实现如图1所示的绘图效果。使用格式为`plotmat(imatr, xlabel="PLANTS", ylabel="POLLINATORS", cexmin=0.2, cexmax=2, sortm=TRUE, sqroot=TRUE)`,其中`imatr`为待绘制的相互作用矩阵,`xlabel`与`ylabel`分别为*x*轴与*y*轴的标注文本,`cexmin`与`cexmax`分别代表表征两两相互作用的圆形标记的最小与最大尺寸,`sortm`用于指定是否对矩阵进行排序(`sortm=TRUE`为排序,`sortm=FALSE`则保留原始顺序),`sqroot`用于指定相互作用频率(矩阵单元格数值)的可视化方式:若为`TRUE`则采用平方根转换,若为`FALSE`则使用原始数值(默认采用平方根转换)。
8. **quant2bin**:将定量矩阵转换为二值矩阵的函数,由netstats调用以计算连接度。
9. **sortmatr**:plotmat所用的矩阵排序算法,该算法基于行列总和对矩阵进行排序,以便可视化嵌套性结构。
10. **sortmatrext**:作为sortmatr替代方案的矩阵排序算法,该算法基于外部向量而非行列总和对矩阵进行排序。
提供机构:
Wiley
创建时间:
2016-08-05



