Online Resources for Many-To-Many Mapping of Phenotype to Performance and the F-Array

Online Resources for Many-To-Many Mapping of Phenotype to Performance and the F-Array

Online Resources for “Many-to-many mapping of phenotype to performance and the F-array”. Evolutionary Biology.

Philip J. Bergmann1 and Eric J. McElroy2

1 Corresponding Author.Department of Biology, Clark University, 950 Main Street, Worcester, MA 01610. E-mail: . Phone: 1-508-793-7553. Fax: 1-508-793-7174

2Department of Biology, College of Charleston, 58 Coming Street, Charleston, SC 29424. E-mail: .

Table of Contents:

1. Phylogenetic tree of species included in analyses

2. F-matrices for all species

3. Tolerances among size and phylogeny adjusted phenotypic traits

4. R code for functions fmat, farray, and mantel

5. Usage manual for R functions

The dataset used in this study is available at datadryad.org.

1.Phylogenetic tree of species included in analyses

Cophosaurustexanus (Ctx)

Holbrookiamaculata (Hma)

Callisaurusdraconoides (Cdr)

Phrynosomamcallii (Pma)

Phrynosomaplatyrhinos (Ppl)

Utastansburiana (Uta)

Sceloporusjarrovii (Sja)

Sceloporusvirgatus (Svi)

Newick format of the phylogeny, with relative branch lengths:

((((Ctx:0.02566,Hma:0.02566):0.03223,Cdr:0.05789):0.03078,(Pma:0.02686,Ppl:0.02686):0.06181):0.06419,(Uta:0.12439,(Sja:0.05703,Svi:0.05703):0.06736):0.02847):0.1;

2. F-matrices for all species

The F-matrix is bounded by a box and bold values have an effect size >0.5. Underlined values are grand sums, with that for columns before the backslashand that for rows after.

CallisaurusdraconoidesCophosaurustexanus

R2 / 0.987 / 0.991 / R2 / 0.821 / 0.927
vel / accel / rsum / rvar / vel / accel / rsum / rvar
SVL / -1.253 / -1.686 / -2.939 / 0.093 / SVL / 0.645 / 0.071 / 0.716 / 0.165
rFLL / -0.774 / -0.887 / -1.662 / 0.006 / rFLL / -0.315 / -1.069 / -1.384 / 0.284
rThigh / 0.835 / 0.323 / 1.158 / 0.131 / rThigh / 0.202 / -1.991 / -1.789 / 2.404
rCrus / 2.199 / 1.899 / 4.098 / 0.045 / rCrus / 0.455 / 3.731 / 4.186 / 5.365
rFoot / -1.646 / -1.471 / -3.117 / 0.015 / rFoot / -0.764 / -1.594 / -2.358 / 0.344
rDigit / -0.322 / -0.237 / -0.558 / 0.004 / rDigit / -0.566 / 1.194 / 0.628 / 1.548
csum / 7.029 / 6.503 / 13.53\13.53 / csum / 2.947 / 9.649 / 12.60\11.06
cvar / 0.456 / 0.502 / cvar / 0.044 / 1.495
traits / 5 / 4 / traits / 3 / 5

HolbrookiamaculataPhrynosomamcallii

R2 / 0.586 / 0.735 / R2 / 0.307 / 0.738
vel / accel / rsum / rvar / vel / accel / rsum / rvar
SVL / 0.363 / -0.385 / -0.023 / 0.280 / SVL / -0.546 / -0.223 / -0.770 / 0.052
rFLL / 0.909 / -0.019 / 0.891 / 0.431 / rFLL / -0.360 / 1.012 / 0.651 / 0.941
rThigh / 0.030 / -0.285 / -0.255 / 0.050 / rThigh / -0.287 / 0.473 / 0.186 / 0.289
rCrus / -0.298 / 0.731 / 0.433 / 0.530 / rCrus / 0.646 / -0.852 / -0.207 / 1.122
rFoot / -0.131 / -0.519 / -0.649 / 0.075 / rFoot / -0.297 / -0.302 / -0.599 / 0.000
rDigit / -1.031 / -0.857 / -1.887 / 0.015 / rDigit / -0.172 / -0.117 / -0.289 / 0.002
csum / 2.762 / 2.796 / 5.56\4.14 / csum / 2.309 / 2.979 / 5.29\2.70
cvar / 0.171 / 0.093 / cvar / 0.031 / 0.130
traits / 2 / 3 / traits / 2 / 2

PhrynosomaplatyrhinosSceloporusjarrovii

R2 / 0.518 / 0.666 / R2 / 0.489 / 0.520
vel / accel / rsum / rvar / vel / accel / rsum / rvar
SVL / 0.070 / 0.155 / 0.225 / 0.004 / SVL / 0.131 / 0.121 / 0.252 / 0.000
rFLL / -0.551 / -0.185 / -0.737 / 0.067 / rFLL / 0.011 / -0.140 / -0.129 / 0.011
rThigh / 0.112 / 0.473 / 0.586 / 0.065 / rThigh / 0.313 / -0.328 / -0.015 / 0.205
rCrus / -0.169 / -0.264 / -0.433 / 0.005 / rCrus / -0.055 / -0.222 / -0.277 / 0.014
rFoot / 0.020 / -0.004 / 0.017 / 0.000 / rFoot / 0.106 / 0.111 / 0.217 / 0.000
rDigit / 0.477 / 0.753 / 1.230 / 0.038 / rDigit / -0.513 / -0.328 / -0.841 / 0.017
csum / 1.400 / 1.834 / 3.23\3.23 / csum / 1.129 / 1.250 / 2.38\1.73
cvar / 0.050 / 0.072 / cvar / 0.036 / 0.010
traits / 1 / 1 / traits / 1 / 0

SceloporusvirgatusUtastansburiana

R2 / 0.515 / 0.383 / R2 / 0.740 / 0.304
vel / accel / rsum / rvar / vel / accel / rsum / rvar
SVL / 0.237 / 0.204 / 0.441 / 0.001 / SVL / -0.031 / 0.168 / 0.137 / 0.020
rFLL / -0.229 / -0.331 / -0.560 / 0.005 / rFLL / 1.482 / 0.289 / 1.770 / 0.712
rThigh / -0.415 / 0.319 / -0.096 / 0.270 / rThigh / -0.066 / -0.041 / -0.106 / 0.000
rCrus / -0.263 / -0.426 / -0.689 / 0.013 / rCrus / -0.583 / -0.601 / -1.184 / 0.000
rFoot / -0.425 / -0.233 / -0.658 / 0.018 / rFoot / -0.292 / -0.413 / -0.705 / 0.007
rDigit / 0.741 / -0.106 / 0.635 / 0.358 / rDigit / -0.576 / 0.185 / -0.391 / 0.289
csum / 2.310 / 1.620 / 3.93\3.08 / csum / 3.030 / 1.696 / 4.73\4.29
cvar / 0.038 / 0.013 / cvar / 0.285 / 0.040
traits / 1 / 0 / traits / 3 / 1

3. Tolerances and correlations among size- and phylogeny-adjusted phenotypic traits

Tolerance values for size- and phylogeny-adjusted phenotypic traits for each species examined. Tolerance values are a measure of the proportion of independent variation in a variable, given the set of variables. Low tolerance values indicate little independent variation in the phenotypic trait. Tolerance <0.1 are in bold. Also included is the number of pairwise correlations among the six phenotypic traits that are > 0.7.

Ca.dra. / Co.tex. / H.mac. / P.mca. / P.pla. / S.jar. / S.vir. / U.sta.
SVL / 0.205 / 0.118 / 0.470 / 0.381 / 0.386 / 0.372 / 0.334 / 0.503
rFLL / 0.058 / 0.007 / 0.197 / 0.297 / 0.488 / 0.035 / 0.579 / 0.192
rThigh / 0.046 / 0.033 / 0.855 / 0.270 / 0.378 / 0.291 / 0.180 / 0.444
rCrus / 0.014 / 0.005 / 0.163 / 0.160 / 0.178 / 0.035 / 0.122 / 0.218
rFoot / 0.102 / 0.048 / 0.433 / 0.557 / 0.651 / 0.338 / 0.753 / 0.665
rDigit / 0.278 / 0.025 / 0.500 / 0.480 / 0.452 / 0.107 / 0.272 / 0.475
R > 0.7 / 3 / 2 / 1 / 1 / 1 / 1 / 2 / 1

Pearson Correlation matrices among size- and phylogeny-adjusted phenotypic traits for each species. Correlations are presented in the lower triangle and p-values in the upper. Correlations >0.7 are in bold. The species for which each matrix is presented is abbreviated in the upper left corner.

Ca.dra. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.86 / 0.11 / 0.42 / 0.89 / 0.76
rFLL / -0.07 / 0.55 / 0.02 / 0.15 / 0.12
rFem / 0.61 / 0.25 / 0.03 / 0.15 / 0.98
rTib / 0.33 / 0.77 / 0.75 / 0.02 / 0.24
rFoot / -0.06 / 0.56 / 0.56 / 0.78 / 0.41
rToe / -0.13 / 0.59 / -0.01 / 0.47 / 0.34
Co.tex. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.59 / 0.99 / 0.72 / 0.74 / 0.30
rFLL / -0.22 / 0.07 / 0.03 / 0.68 / 0.45
rFem / 0.00 / 0.67 / 0.04 / 0.79 / 0.59
rTib / -0.15 / 0.77 / 0.74 / 0.18 / 0.70
rFoot / -0.14 / 0.18 / -0.11 / 0.52 / 0.23
rToe / 0.42 / 0.31 / 0.23 / -0.16 / -0.48
H.mac. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.70 / 0.73 / 0.38 / 0.63 / 0.81
rFLL / -0.12 / 0.72 / 0.01 / 0.04 / 0.02
rFem / -0.11 / 0.11 / 0.61 / 0.95 / 0.76
rTib / 0.27 / 0.71 / 0.16 / 0.02 / 0.17
rFoot / -0.15 / 0.58 / -0.02 / 0.65 / 0.35
rToe / 0.08 / 0.65 / -0.09 / 0.40 / 0.28
P.mca. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.70 / 0.93 / 0.98 / 0.70 / 0.16
rFLL / -0.11 / 0.11 / <0.01 / 0.68 / 0.82
rFem / -0.03 / 0.45 / 0.01 / 0.98 / 0.98
rTib / 0.01 / 0.77 / 0.65 / 0.84 / 0.81
rFoot / -0.11 / -0.12 / 0.01 / -0.06 / 0.05
rToe / -0.40 / 0.07 / -0.01 / 0.07 / -0.53
P.pla. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.44 / 0.65 / 0.01 / 0.72 / 0.50
rFLL / -0.24 / 0.22 / 0.08 / 0.87 / 0.39
rFem / -0.15 / 0.39 / 0.16 / 0.81 / 0.34
rTib / -0.71 / 0.52 / 0.43 / 0.63 / 0.60
rFoot / 0.12 / 0.05 / 0.08 / -0.15 / 0.15
rToe / 0.22 / 0.28 / -0.30 / -0.17 / 0.44
S.jar. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.98 / 0.39 / 0.99 / 0.99 / 0.62
rFLL / -0.01 / 0.02 / 0.01 / 0.93 / 0.86
rFem / 0.29 / 0.67 / 0.25 / 0.87 / 0.81
rTib / 0.01 / 0.73 / 0.38 / 0.27 / 0.57
rFoot / 0.00 / -0.03 / -0.06 / -0.36 / 0.04
rToe / 0.17 / 0.06 / -0.08 / 0.19 / -0.62
S.vir. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.67 / 0.06 / 0.02 / 0.42 / 0.38
rFLL / 0.13 / 0.88 / 0.86 / 0.39 / 0.23
rFem / -0.51 / 0.04 / <0.01 / 0.83 / 0.00
rTib / -0.60 / 0.05 / 0.73 / 0.93 / 0.02
rFoot / 0.24 / 0.25 / 0.06 / 0.02 / 0.82
rToe / -0.26 / 0.34 / 0.73 / 0.60 / 0.07
U.sta. / LSVL / rFLL / rFem / rTib / rFoot / rToe
LSVL / 0.06 / 0.97 / 0.21 / 0.67 / 0.97
rFLL / 0.51 / 0.16 / <0.01 / 0.13 / 0.02
rFem / -0.01 / 0.40 / 0.01 / 0.46 / 0.38
rTib / 0.36 / 0.79 / 0.64 / 0.37 / 0.07
rFoot / 0.13 / 0.43 / 0.22 / 0.26 / 0.12
rToe / 0.01 / 0.60 / 0.26 / 0.50 / 0.44

4. R code for functions fmat, farray, and mantel

fmat function

# This function produces an intraspecific F-matrix for x phenotypic traits and y performance traits

# using multiple regression.

# It also runs a number of calculations to help interpret the F-matrix.

fmat <- function(pheno,perf) {

# pheno should be a data frame containing only phenotypic vars in columns, where rows are individuals.

# perf should be a data frame with performance traits in columns, rows are individuals.

# Calculate how many phenotypic and performance traits there are.

npheno <- length(pheno)

nperf <- length(perf)

perf_pheno <- cbind(perf,pheno)

# Scale all of the perf and pheno variables to mean zero and SD 1 so that regression gives standardized coeffs.

perf_pheno <- as.data.frame(scale(perf_pheno))

attach(perf_pheno)

# Do a multiple regression on each perf variable using all pheno variables, place coefficients

# and r-squares into objects.

mreg_coefs <- NULL

mreg_rsq <- rep(NA,nperf)

for (i in 1:nperf) {

frm <- as.formula(paste(names(perf)[i],paste(" ~ ",paste(names(pheno),collapse= "+"))))

mreg_coefs[[i]] <- summary(lm(frm))$coefficients

mreg_rsq[i] <- summary(lm(frm))$r.squared

}

names(mreg_coefs) <- names(perf)

names(mreg_rsq) <- names(perf)

detach()

# Combine multiple regression slopes into an F-matrix, omitting the intercepts and label variables.

F <- NULL

for (i in 1:nperf) {

F <- cbind(F,mreg_coefs[[i]][2:(npheno+1),1])

}

colnames(F) <- names(perf)

# Calculate row and col sums, row var, col var of abs values, FTF and FFT matrices

Fabs <- abs(F)

rsum <- apply(F,1,sum)

csum <- apply(Fabs,2,sum)

rvar <- apply(F,1,var)

cvar <- apply(Fabs,2,var)

FTF <- (t(F)) %*% F

FFT <- F %*% (t(F))

rstats <- rbind(rsum,rvar)

cstats <- rbind(csum,cvar)

rgsum <- sum(abs(rsum))

cgsum <- sum(abs(csum))

gsum <- c(rgsum,cgsum)

names(gsum) <- c("row","col")

# Combine all the results into a list

results <- list(mreg_coefs,mreg_rsq,F,FTF,FFT,rstats,cstats,gsum)

names(results)<-c("mregs","rsq","F","FTF","FFT","row.stats","col.stats","grand.sum")

results

}

farray function

# This function takes an interspecific dataset of phenotype and performances, calculates an F-matrix

# and associated specifics or each species, and then assembles this into an F-array, calcualting an

# eVCV matrix for each performance measure and comparing pairwaise the eVCV matrices using modified

# mantel tests that include the diagonal.

# Input is a vector identifying each observation to species, a data frame with phenotypic traits

# where each row corresponds to an individual belonging to one of the species identified in species,

# perf is a similar data frame with performance traits, tree is a phylogeny relating all the species,

# and s is the number of randomizations for the mantel tests, by default 10000.

farray <- function(species,pheno,perf,tree,s=10000) {

# calcualte the number of phenotypic traits, number of performance traits and number of species

nspp <- length(levels(species))

npheno <- length(pheno)

nperf <- length(perf)

# Combine species identifiers with the phenotypic and the performance data

pheno_sp <- cbind(species,pheno)

perf_sp <- cbind(species, perf)

# Create a 3D array of dimensions to fit the f-matrices of all species

far3d <- rep(NA,npheno*nperf*nspp)

dim(far3d) <- c(npheno,nperf,nspp)

# Calculate an F-matrix for each species as well as all associated stats, also output the f-matrix

# for each species into the 3D array.

spp_fmats <- NULL

for (i in 1:length(levels(species))) {

spp = levels(species)[i]

temp <- fmat(pheno_sp[species==spp,2:(npheno+1)],perf_sp[species==spp,2:(nperf+1)])

spp_fmats[[i]] <- temp

far3d[,,i] <- temp[[3]]}

names(spp_fmats) <- levels(species)

# Add labels to the far3d object, the interspecific F-array

dimnames(far3d) <- list(NULL,NULL,levels(species))

colnames(far3d) <- colnames(perf_sp[,2:(nperf+1)])

rownames(far3d) <- colnames(pheno_sp[,2:(npheno+1)])

# Produce an object with the F-array decomposed into a matrix for each performance trait

perf_coefs <- NULL

for (i in 1:nperf) {

perf_coefs[[i]] <- t(far3d[,i,])}

names(perf_coefs) <- colnames(perf_sp[,2:(nperf+1)])

# Calculate the eVCV matrix for each performance trait

eVCV <- NULL

for (i in 1:nperf) {

eVCV[[i]] <- ratematrix(tree,perf_coefs[[i]])}

names(eVCV) <- colnames(perf_sp[,2:(nperf+1)])

# Calculate a modified Mantel test with s permutations for each pairwise combo of eVCV matrices

mantel_out <- NULL

for (i in 1:(length(eVCV)-1)) {

for (j in (i+1):length(eVCV)) {

mantel_temp <- mantel(eVCV[[i]],eVCV[[j]],s,type="d_s")

mantel_temp <- c(names(perf_coefs)[i],names(perf_coefs)[j],mantel_temp)

mantel_out <- rbind(mantel_out,mantel_temp)}}

rownames(mantel_out)<-NULL

if (nrow(mantel_out)==1)

{mantel_out <- mantel_out} else

{mantel_out <- cbind(as.factor(mantel_out[,1]),as.factor(mantel_out[,2]),as.data.frame(mantel_out[,3:7]))

colnames(mantel_out)<-c("v1","v2","R","p","ncol","nrow","nreps")}

# Compile results

results <- list(spp_fmats,perf_coefs,eVCV,mantel_out)

names(results) <- c("spp_fmats","perf_coefs","eVCV","mantel")

results

}

mantel function

# This function does a classical Mantel test, comparing the lower triangle of two matrices, a modified version of the Mantel test,

# where input is a symmetrical matrix and the diagonal is informative, a modified version similar to the previous, but where

# the cells of the diagonal are randomized separately from those of the off-diagonal, and a modified mantel test where the

# entire matrix is informative and can be square or rectangular. The test uses the lower triangle, lower triangle and

# diagonal, or whole matrix to calculate a pearson correlation, then randomizes the first matrix s times to calculate a p-value.

# x_mat and y_mat are input matrices, s is number of randomizations, type is the type of mantel

# tri is just one triangle, diag is a triangle with an informative diagonal, d_s is when diagonal is informative

# but randomized separately from the off diagonal, and whole is when the whole matrix is informative

mantel <- function(x_mat,y_mat,s,type=c("tri","diag","d_s","whole")) {

# Calculate the number of rows and columns in your matrices

nrow <- dim(x_mat)[1]

ncol <- dim(x_mat)[2]

# Linearize the two matrices into vectors, containing the appropriate parts of the matrices

x_lin <- NULL

y_lin <- NULL

if (type=="tri") {

for (i in (1:ncol-1)) {

temp <- x_mat[(i+1):ncol,i]

x_lin <- c(x_lin,temp)}

x_lin_all <- x_lin

for (i in (1:ncol-1)) {

temp <- y_mat[(i+1):ncol,i]

y_lin <- c(y_lin,temp)}

y_lin_all <- y_lin

}

if (type=="diag"){

for (i in 1:ncol) {

temp <- x_mat[i:ncol,i]

x_lin <- c(x_lin,temp)}

x_lin_all <- x_lin

for (i in 1:ncol) {

temp <- y_mat[i:ncol,i]

y_lin <- c(y_lin,temp)}

y_lin_all <- y_lin

}

if (type=="d_s"){

x_diag_lin <- rep(NA,ncol)

y_diag_lin <- rep(NA,ncol)

for (i in (1:ncol-1)) {

temp <- x_mat[(i+1):ncol,i]

x_lin <- c(x_lin,temp)}

for (i in 1:ncol) {

x_diag_lin[i] <- x_mat[i,i]}

x_lin_all <- NULL

x_lin_all <- c(x_lin,x_diag_lin)

for (i in (1:ncol-1)) {

temp <- y_mat[(i+1):ncol,i]

y_lin <- c(y_lin,temp)}

for (i in 1:ncol) {

y_diag_lin[i] <- y_mat[i,i]}

y_lin_all <- NULL

y_lin_all <- c(y_lin,y_diag_lin)

}

if (type=="whole") {

for (i in 1:ncol) {

temp <- x_mat[,i]

x_lin <- c(x_lin,temp)}

x_lin_all <- x_lin

for (i in 1:ncol) {

temp <- y_mat[,i]

y_lin <- c(y_lin,temp)}

y_lin_all <- y_lin

}

# Calculate the Mantel test statistic as the pearson correlation between the two linearized matrices

mantel_stat <- cor(x_lin_all,y_lin_all,method="pearson")

# Permute the linearized x matrix s times to give randomized data pairs, if type is d_s, then the diagonals and off diagonals

# are randomized separately. For all other types of test all entries are fully randomized.

if (type=="d_s"){

rnd_off_diags <- rep(NA,length(x_lin)*s)

dim(rnd_off_diags) <- c(length(x_lin),s)

rnd_diags <- rep(NA,length(x_diag_lin)*s)

dim(rnd_diags) <- c(length(x_diag_lin),s)

for (i in 1:s) {

rnd_off_diags[,i] <- sample(x_lin,length(x_lin),replace=FALSE)

rnd_diags[,i] <- sample(x_diag_lin,length(x_diag_lin),replace=FALSE)

}

rand_xlin <- rbind(rnd_off_diags,rnd_diags)

}

else {

rand_xlin <- rep(NA,length(x_lin_all)*s)

dim(rand_xlin) <- c(length(x_lin_all),s)

for (i in 1:s) {

rand_xlin[,i] <- sample(x_lin_all,length(x_lin_all),replace=FALSE)}

}

# Calculatepearson correlations for each randomized dataset and output into the null distribution vector

null_dist <- NULL

for (i in 1:s) {

null_dist[i] <- cor(rand_xlin[,i],y_lin_all,method="pearson")}

# Calculate the p-value of the mantel_stat given the null distribution using a 2-tailed test

null_median <- median(null_dist)

if (mantel_statnull_median)

{pval <- 2*(sum(null_distmantel_stat) / length(null_dist))} else

{pval <- 2*(sum(null_distmantel_stat) / length(null_dist))}

# Compile results

results <- c(mantel_stat,pval,ncol,nrow,s)

names(results) <- c("R","p","ncol","nrow","nreps")

results

}

5. Usage manual for R functions

fmatF-matrix calculator

Description

Calculates an F-matrix for a dataset containing multiple phenotypic traits and multiple performance measures, using standardized partial coefficients from multiple regression to fill the cells of the F-matrix. The function also calculates the FFT and FTF matrices, sums of rows and columns, variance of rows and columns. Column sum and variance is calculated from absolute values of F-matrix cells. Finally, the column and row absolute grand sumsfor the matrix are calculated. Input data will generally be trait and performance values for individuals, or for species, as phylogenetically-independent values.

Usage

fmat(pheno, perf)

Arguments

phenoA dataframe containing all of the phenotypic traits as columns

perfA dataframe containing all of the performance measures as columns

Values

Returns a list of matrices, with the matrices containing, in order:

1. Multiple regression coefficients and standard errors. One matrix of results per performance measure.

2. R square values for the multiple regression models.

3. The F-matrix, filled with standardized partial regression coefficients.

3. The FTF matrix.

4. The FFT matrix.

5. Sums and variances for each row.

6. Sums and variances for absolute values in each column.

7. The grand sum of absolute values of row sums and grand sum of absolute values of column sums for the F-matrix.

Author:Philip J. Bergmann

mantelMantel test on two matrices of any form

Description

Calculates a Mantel test to compare two matrices. Three types of matrices can be compared: the classic approach where only the lower triangle of the matrices is compared, which assumes square matrices with uninformative diagonals; an approach where the lower triangle and diagonal are compared for when the diagonal is informative, such as when comparing variance-covariance matrices; and an approach when the entire matrix is informative, which can be used for square or rectangular matrices. When the test is done on the lower triangle and diagonal, either all cells can be randomized together, or diagonal and off-diagonal cells are randomized separately, which may be useful when diagonals and off-diagonals contain qualitatively different information (like variances and covariances). The test calculates a Pearson correlation between the two matrices. To do the permutation test, it randomizes the first matrix specified, repeating the analysis a specified number of times to create a null distribution. This function does a two-tailed test.

Usage

mantel(x_mat, y_mat, s, type=c("tir","diag","d_s","whole"))

Arguments

x_matThe first matrix to be compared

y_matThe second matrix to be compared

sThe number of permutations to be done to calculate the p-value

type“tri” uses only the lower triangle of square matrices, “diag” uses the lower triangle and diagonal of square matrices and randomizes them together, “d_s” uses lower triangle and diagonal but randomizes them separately, “whole” uses the entire matrices that can be of any size

Values

Returns the Pearson correlation, R, between the two matrices, the p-value, the number of columns and rows in the input matrices (which must be the same dimensions), and the number of permutations performed.

Author:Philip J. Bergmann

farrayF-array calculator

Description

This function takes data for multiple phenotypic traits and multiple performance measures (all in columns), and for multiple species (one column should be a species identifier). It then calculates an F-matrix for each species, using the fmat function, assembles a species x trait matrix for each performance measure, calculates an evolutionary variance-covariance matrix for each performance measure using a user-supplied phylogeny, and does pairwise modified Mantel tests (using the function mantel) to compare eVCV matrices among performance measures. The Mantel test randomizes the diagonal and off-diagonal elements separately. This function uses the functions fmat and mantel and is dependent on the package Geiger.

Usage

farray(species, pheno, perf, tree, s=10000)

Arguments

speciesA vector with species identifiers for each individual in the data

phenoA data frame containing phenotypic trait data, with traits in columns and individuals in rows

perfA data frame containing performance measure data, with different performance measures in columns and individuals in rows

treeA phylogenetic tree, an object of class “phylo”

sThe number of permutations for the modified Mantel tests, the default is 10,000 permutations

Values

Returns a list containing all of the output from the function “fmat” for each species, a species x phenotypic trait matrix for each performance measure, an eVCV for each performance measure, and the modified Mantel test results, for each pairwise comparison of eVCVs.

Author:Philip J. Bergmann

1