R/Lib_MapBetaDiversity.R
ordination_to_NN.Rd
compute_NMDS <- function(MatBCdist,dimMDS=3) nbiterNMDS <- 4 if (Sys.info()["sysname"] == "Windows") nbCoresNMDS <- 2 else if (Sys.info()["sysname"] == "Linux") nbCoresNMDS <- 4 # multiprocess of spectral species distribution and alpha diversity metrics # plan(multisession, workers = nbCoresNMDS) ## Parallelize using four cores plan(multisession, workers = nbCoresNMDS) ## Parallelize using four cores BetaNMDS <- future_lapply(MatBCdist, FUN = nmds, mindim = dimMDS, maxdim = dimMDS, nits = 1, future.packages = c("ecodist")) plan(sequential) # find iteration with minimum stress Stress <- vector(length = nbiterNMDS) for (i in 1:nbiterNMDS) Stress[i] <- BetaNMDS[[i]]$stress print("Stress obtained for NMDS iterations:") print(Stress) print("Rule of thumb") print("stress < 0.05 provides an excellent represention in reduced dimensions") print("stress < 0.1 is great") print("stress < 0.2 is good") print("stress > 0.3 provides a poor representation") MinStress <- find(Stress == min(Stress)) BetaNMDS_sel <- BetaNMDS[[MinStress]]$conf BetaNMDS_sel <- data.frame(BetaNMDS_sel[[1]]) return(BetaNMDS_sel) Identifies ordination coordinates based on nearest neighbors
ordination_to_NN(
SSD_subset,
Beta_Ordination_sel,
Sample_Sel,
nb_partitions,
nbclusters,
pcelim = 0.02,
nbCPU = 1,
SamplesPerThread = 2000,
progressbar = FALSE
)
numeric. matrix corresponding to Spectral species distribution for a set of windows
ordination of dissimilarity matrix for a selection of spatial units
numeric. Samples selected during ordination
number of k-means then averaged
number of clusters
numeric. Minimum contribution in percent required for a spectral species
numeric. number of CPUs available
numeric. number of samples to be processed per thread for dissimilarity matrix
boolean. should progress bar be displayed (set to TRUE only if no conflict of parallel process)
Ordination_est coordinates of each spatial unit in ordination space