diff --git a/01b_MesobromionCluster.R b/01b_MesobromionCluster.R index 7fd9bed2a1b7ab29279ea1e94eb03f61aa399521..215c99d24923e9f43f785a9e870c17e99ecfb9d5 100644 --- a/01b_MesobromionCluster.R +++ b/01b_MesobromionCluster.R @@ -110,7 +110,7 @@ Mesobromion <- function(species.path, traits.path, output, myfunction="get.corXY corXY.output <- foreach(i=1:length(allcomb.t), .combine=rbind) %myinfix% { tt <- unlist(allcomb.t[i]) corXY.output <- rbind(corXY.output, - get.corXY.bootstrap(comm=species, trait=traits, + myfunction(comm=species, trait=traits, trait.sel=tt, bootstrap=nperm)) } save(corXY.output, file = paste(output,"_", chunk.i, "_.RData", sep="")) diff --git a/99_HIDDEN_functions.R b/99_HIDDEN_functions.R index ef81a8006912f9ff823495935f21469d4dff945c..00c6328cdf3a6025cdf137b9059c3519114d1d4f 100644 --- a/99_HIDDEN_functions.R +++ b/99_HIDDEN_functions.R @@ -89,14 +89,15 @@ get.corXY.bootstrap <- function(comm, traits, trait.sel="all", bootstrap=199){ for(b in 1:bootstrap){ #RV.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.tmp)[index.bootstr[[b]],]) RD.tmp <- dcor(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.tmp)[index.bootstr[[b]],])^2 - syn.out.perm.tmp <- matrix.x(comm=comm, traits=traits[index.traits[[bootstrap]],ii,drop=F], + syn.out.perm.tmp <- matrix.x(comm=comm, traits=traits[index.traits[[b]],ii,drop=F], scale=T)$matrix.X #, asym.bin=binary.traits #RV.perm.tmp <- RV.rtest(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.perm.tmp)[index.bootstr[[b]],]) RD.perm.tmp <- dcor(W.beals[index.bootstr[[b]],], as.data.frame(syn.out.perm.tmp)[index.bootstr[[b]],])^2 corXY <- rbind(corXY, data.frame(Trait.comb=lab.tmp, bootstr.n=b, Test="RD", Coef.obs=RD.tmp, Coef.perm=RD.perm.tmp)) - if(b %in% round(seq(1,bootstrap, length.out=10))){print(paste("trait", paste0(ii, collapse="_"), "perm", b))} + if(b %in% round(seq(1,bootstrap, length.out=10))){ + print(paste("trait", paste0(ii, collapse="_"), "perm", b, paste(colnames(traits[trait.sel]), collapse="+")))} } return(corXY) }