The fast optimal circular clustering (FOCC) (Debnath and Song 2021) algorithm can efficiently and optimally cluster circular data. Here circular data broadly refer to data points on any non-self-intersecting loop. We demonstrate the main functions offered by the OptCirClust
package.
Circular datasets can be obtained from different sources, including simulated data and real data like circular genomes. Here we generate simulated circular data. The input circular \(O\) contains some points belonging to a circle with a Circumference=6
. We will find \(K=5\) clusters in this data.
library(OptCirClust)
= rnorm(100)
O = 5
K = 6 Circumference
Now we demonstrate how to cluster the data using three different algorithms: the recommended fast optimal circular clustering (FOCC), the slow brute force optimal circular clustering (BOCC), and the slow and heuristic circular clustering (HEUC). The BOCC is implemented by extending the linear clustering algorithm Ckmeans.1d.dp
in the identically named package. The HEUC is implemented by extending the heuristic \(K\)-means algorithm offered by the kmeans
function in R. We set the random seed to be one so that the same result will be generated by the HEUC method.
# Our recommended method is the fast and optimal FOCC:
<- CirClust(O, K, Circumference, method = "FOCC")
result_FOCC
# The slow and optimal BOCC:
<- CirClust(O, K, Circumference, method = "BOCC")
result_BOCC
# The slow and heuristic HEUC:
<- CirClust(O, K, Circumference, method = "HEUC") result_HEUC
The clustering outcomes obtained from the CirClust
function can be visualized using the plot
function.
<- par(mar=c(0,0,2,0))
opar
plot(result_FOCC, main = "FOCC: fast and optimal\n***Recommended***")
plot(result_BOCC, main = "BOCC: quadratic time\nalways optimal")
plot(result_HEUC, main = "HEUC: heuristic\nnot always optimal")
par(opar)
The circle represents the circular coordinate system with the origin marked by horizontal line and the \(0\). The lines on the circle are the data points and the dashed line represents the cluster borders. The radial line from the center to the inner circular border along with \(0\) shows the origin of the circular coordinate system. The arrow shows the coordinate direction. Points belonging to a cluster are marked with identical color. Clusters are numbered according to the cluster number produced by the corresponding algorithm.
The clustering outcomes can be used for further analysis of the circular data.