gwpca_df_mc {heterogen}R Documentation

Perform GWPCA from data.frame with spatial structure.

Description

gwpca_df is an R function that performs Generalized Weighted Principal Component Analysis (GWPCA) on a given dataset. This function allow to calculate the environmental heterogeneity from data.frame with spatial structure.

Usage

gwpca_df_mc(
  datadf,
  bandwidth = 0.2,
  tolerance = 5,
  nprocess = 10000,
  parallel = FALSE,
  ncores = 2,
  normalized = FALSE,
  method = "iter",
  dirds = "rds"
)

Arguments

datadf

The input data matrix for which GWPCA needs to be performed. It should contain numerical values only. Rows represent cells, and columns represent bioclimatic variables.

bandwidth

The bandwidth for the spatial weighting function.

tolerance

The tolerance for spatial weight computation.

nprocess

(Optional) The number of iterations for calculating the principal components. Default is set to 1000.

parallel

(Optional) A logical value indicating whether to run the computation in parallel. If TRUE, multiple cores will be used for processing. Default is FALSE.

ncores

(Optional) The number of cores to be used for parallel computation. Only applicable if parallel is set to TRUE. Default is 4.

normalized

(Optional) A logical value indicating whether the input data should be normalized before performing GWPCA. Default is FALSE, meaning the data will not be normalized. Take in account that core function performs correlation analysis in order to normalize the input variables.

method

The method used for GWPCA computation. It can take one of the following values. local Performs GWPCA locally and will save each iteration on .rds files. Recommended for large-scale data sets. inter Uses RAM memory to . Default is inter.

dirds

(Optional) The directory where the results will be saved in RDS format. Default is rds.

Value

A matrix of eigenvalues

Examples


path_csv <- system.file("extdata","south.csv", package="heterogen")
south_csv <- rio::import(path_csv)

# notice: south_csv object contains x,y (lot/lat coordinates)
# and environmental variables
north_het <- gwpca_df_mc(as.matrix(south_csv), parallel = TRUE, 
ncores = 2, bandwidth = 0.1, tolerance = 10)




[Package heterogen version 1.2.33 Index]