View source: R/nhclu_affprop.R
nhclu_affprop | R Documentation |
This function performs non-hierarchical clustering using the Affinity Propagation algorithm.
nhclu_affprop(
similarity,
index = names(similarity)[3],
seed = NULL,
p = NA,
q = NA,
maxits = 1000,
convits = 100,
lam = 0.9,
details = FALSE,
nonoise = FALSE,
K = NULL,
prc = NULL,
bimaxit = NULL,
exact = NULL,
algorithm_in_output = TRUE
)
similarity |
The output object from |
index |
The name or number of the similarity column to use. By default,
the third column name of |
seed |
The seed for the random number generator used when
|
p |
Input preference, which can be a vector specifying individual
preferences for each data point. If scalar, the same value is used for all
data points. If |
q |
If |
maxits |
The maximum number of iterations to execute. |
convits |
The algorithm terminates if the exemplars do not change for
|
lam |
The damping factor, a value in the range [0.5, 1). Higher values correspond to heavier damping, which may help prevent oscillations. |
details |
If |
nonoise |
If |
K |
The desired number of clusters. If not |
prc |
A parameter needed when |
bimaxit |
A parameter needed when |
exact |
A flag indicating whether to compute the initial preference range exactly. |
algorithm_in_output |
A |
This function is based on the apcluster package (apcluster).
A list
of class bioregion.clusters
with five slots:
name: A character
string containing the name of the algorithm.
args: A list
of input arguments as provided by the user.
inputs: A list
describing the characteristics of the clustering
process.
algorithm: A list
of objects associated with the clustering
procedure, such as original cluster objects
(if algorithm_in_output = TRUE
).
clusters: A data.frame
containing the clustering results.
If algorithm_in_output = TRUE
, the algorithm
slot includes the output of
apcluster.
Pierre Denelle (pierre.denelle@gmail.com)
Boris Leroy (leroy.boris@gmail.com)
Maxime Lenormand (maxime.lenormand@inrae.fr)
Frey B & Dueck D (2007) Clustering by Passing Messages Between Data Points. Science 315, 972-976.
For more details illustrated with a practical example, see the vignette: https://biorgeo.github.io/bioregion/articles/a4_2_non_hierarchical_clustering.html.
Associated functions: nhclu_clara nhclu_clarans nhclu_dbscan nhclu_kmeans nhclu_affprop
comat_1 <- matrix(sample(0:1000, size = 10*12, replace = TRUE,
prob = 1/1:1001), 10, 12)
rownames(comat_1) <- paste0("Site", 1:10)
colnames(comat_1) <- paste0("Species", 1:12)
comat_1 <- cbind(comat_1,
matrix(0, 10, 8,
dimnames = list(paste0("Site", 1:10),
paste0("Species", 13:20))))
comat_2 <- matrix(sample(0:1000,
size = 10*12,
replace = TRUE,
prob = 1/1:1001),
10, 12)
rownames(comat_2) <- paste0("Site", 11:20)
colnames(comat_2) <- paste0("Species", 9:20)
comat_2 <- cbind(matrix(0, 10, 8,
dimnames = list(paste0("Site", 11:20),
paste0("Species", 1:8))),
comat_2)
comat <- rbind(comat_1, comat_2)
dissim <- dissimilarity(comat, metric = "Simpson")
sim <- dissimilarity_to_similarity(dissim)
clust1 <- nhclu_affprop(sim)
clust2 <- nhclu_affprop(sim, q = 1)
# Fixed number of clusters
clust3 <- nhclu_affprop(sim, K = 2, prc = 10, bimaxit = 20, exact = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.