cluster_analysis_fun: Internal Workers for Repeated Clustering Analysis

View source: R/cluster_analysis_fun.R

cluster_analysis_funR Documentation

Internal Workers for Repeated Clustering Analysis

Description

Internal worker functions used by the parallel clustering-analysis wrappers. Each function executes one clustering trial, optionally assigns a deterministic seed, records elapsed computation time, and extracts a result element named Cls.

Usage

cluster_analysis_fun(
  i,
  fun,
  DataOrDistances,
  ClusterNo = NULL,
  SetSeed = TRUE,
  ...
)

CA_data_fun(
  i,
  fun,
  Data,
  ClusterNo = NULL,
  SetSeed = TRUE,
  ...
)

CA_dist_fun(
  i,
  fun,
  Distances,
  ClusterNo = NULL,
  SetSeed = TRUE,
  ...
)

Arguments

i

Positive integer trial identifier. When SetSeed = TRUE, the seed is 1000 + i.

fun

Function or character string naming the clustering function.

DataOrDistances

Generic data, distance, or dissimilarity input passed to fun.

Data

Dataset passed to a data-based clustering function.

Distances

Distance or dissimilarity input passed to a distance-based clustering function.

ClusterNo

Optional number of clusters. If NULL, it is not included in the clustering-function call.

SetSeed

Logical scalar. If TRUE, use seed 1000 + i. If FALSE, call set.seed(NULL) before executing the clustering function.

...

Further arguments passed to the clustering function.

Details

The functions inspect the formal arguments of fun to determine the name under which the main input is supplied.

cluster_analysis_fun() recognizes generic data and distance argument names. CA_data_fun() prefers Data, and CA_dist_fun() prefers names associated with distances or dissimilarities.

Named arguments in ... may not duplicate arguments supplied by the worker. If fun has no ... formal argument, unsupported named arguments are removed before the call.

Only an exactly unique element named Cls is extracted. Otherwise, Cls is returned as NULL.

Value

A list with components:

Cls

Clustering vector extracted from the result, or NULL.

ComputationTime

Named numeric scalar containing elapsed time in seconds.

Seed

Integer seed, or NULL when SetSeed = FALSE.

CAs

Complete object returned by the clustering function.

Note

These are internal implementation functions. Users should normally call parApplyClusterAnalysis, parApplyDataBasedCA, or parApplyDistanceBasedCA.

Author(s)

Michael Thrun

References

Thrun, M. C.: Distance-Based Clustering Challenges for Unbiased Benchmarking Studies, Nature Scientific Reports, Vol. 11, pp. 18988, DOI: 10.1038/s41598-021-98126-1, 2021.

See Also

parApplyClusterAnalysis

Examples

## Not run: 
#data(Hepta)
#Distance=as.matrix(parallelDist::parallelDist(Hepta$Data))
#out=cluster_analysis_fun(i = 1,fun = APclusterin
#g,DataOrDistances = Distance,ClusterNo = 7)

## End(Not run)

FCPS documentation built on July 15, 2026, 5:08 p.m.