Skip to content

Commit

Permalink
Regularized KMEANS clustering, new functionalities
Browse files Browse the repository at this point in the history
Implementation of hard threshold regularized KMEANS clustering (HTKmeans, function `htk_cluster()`). Tuning functions for lambda in HTKmeans and k in kNN prediction of the cluster assignment
  • Loading branch information
PiotrTymoszuk authored Nov 17, 2023
1 parent 3a0adc7 commit 9ed2609
Show file tree
Hide file tree
Showing 23 changed files with 2,342 additions and 299 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: clustTools
Type: Package
Title: Tools for Dimensionality Reduction and Data Clustering
Version: 1.2.1
Version: 1.3.0
Maintainer: Piotr Tymoszuk <[email protected]>
Description: Provides a comprehensive set of R functions for dimensionality
reduction (PCA, MDS and UMAP), clustering (HCl, k-means, PAM, DBSCAN, SOM)
and combined reduction-clustering tools. Visualization and QC toolset is
provided as well.
reduction (PCA, MDS and UMAP), clustering (HCl, KMEANS, PAM, DBSCAN, SOM
and regularized KMEANS) and combined reduction-clustering tools.
Visualization and QC toolset is provided as well.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand All @@ -16,6 +16,7 @@ Authors@R:
comment = c(ORCID = "0000-0002-0398-6034"))
Imports:
caret,
clusterHD,
cowplot,
coxed,
dbscan,
Expand Down
18 changes: 18 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ S3method(extract,clust_analysis)
S3method(extract,cluster_cv)
S3method(extract,combi_analysis)
S3method(extract,red_analysis)
S3method(extract,tuner)
S3method(impact,clust_analysis)
S3method(impact,combi_analysis)
S3method(impact,min_analysis)
Expand All @@ -39,12 +40,14 @@ S3method(np,red_analysis)
S3method(pbc,clust_analysis)
S3method(pbc,combi_analysis)
S3method(plot,clust_analysis)
S3method(plot,clust_red)
S3method(plot,combi_analysis)
S3method(plot,cross_dist)
S3method(plot,importance)
S3method(plot,knb)
S3method(plot,red_analysis)
S3method(plot,sil_extra)
S3method(plot,tuner)
S3method(plot,umatrix_analysis)
S3method(plot_clust_hm,clust_analysis)
S3method(plot_clust_hm,combi_analysis)
Expand All @@ -55,22 +58,30 @@ S3method(predict,combi_analysis)
S3method(predict,min_analysis)
S3method(predict,red_analysis)
S3method(predict,umatrix_analysis)
S3method(prediter,clust_analysis)
S3method(prediter,combi_analysis)
S3method(prediter,min_analysis)
S3method(prediter,umatrix_analysis)
S3method(print,clust_analysis)
S3method(print,combi_analysis)
S3method(print,cross_dist)
S3method(print,red_analysis)
S3method(print,tuner)
S3method(qe,clust_analysis)
S3method(qe,combi_analysis)
S3method(rename,clust_analysis)
S3method(rename,combi_analysis)
S3method(silhouette,clust_analysis)
S3method(silhouette,combi_analysis)
S3method(summary,clust_analysis)
S3method(summary,cluster_cv)
S3method(summary,combi_analysis)
S3method(summary,cross_dist)
S3method(summary,importance)
S3method(summary,knb)
S3method(summary,red_analysis)
S3method(summary,sil_extra)
S3method(summary,tuner)
S3method(te,clust_analysis)
S3method(te,combi_analysis)
S3method(var,clust_analysis)
Expand All @@ -97,6 +108,7 @@ export(extract.red_analysis)
export(get_clust_tendency)
export(get_kernel_info)
export(hcluster)
export(htk_cluster)
export(impact)
export(is_clust_analysis)
export(is_cluster_cv)
Expand All @@ -107,6 +119,7 @@ export(is_knb)
export(is_min_analysis)
export(is_red_analysis)
export(is_sil_extra)
export(is_tuner)
export(is_umatrix_analysis)
export(kcluster)
export(min_max)
Expand All @@ -121,11 +134,13 @@ export(plot.importance)
export(plot.knb)
export(plot.red_analysis)
export(plot.sil_extra)
export(plot.tuner)
export(plot_clust_hm)
export(plot_nbclust)
export(predict.clust_analysis)
export(predict.combi_analysis)
export(predict.red_analysis)
export(prediter)
export(qe)
export(red_analysis)
export(reduce_data)
Expand All @@ -136,11 +151,14 @@ export(silhouette.clust_analysis)
export(silhouette.combi_analysis)
export(som_cluster)
export(som_reduce)
export(summary.clust_analysis)
export(summary.combi_analysis)
export(summary.cross_dist)
export(summary.importance)
export(summary.knb)
export(summary.sil_extra)
export(te)
export(tune_htk)
export(var)
export(var.clust_analysis)
export(var.combi_analysis)
Expand Down
27 changes: 25 additions & 2 deletions R/appearance.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Appearance for the S3 class objects

#' Printing of a clust_analysis object.
#' Printing of objects.
#'
#' @description
#' Prints a `clust_analysis`, `combi_analysis`, `red_analysis`
Expand Down Expand Up @@ -33,7 +33,12 @@

stopifnot(is_combi_analysis(x))

purrr::walk(x$clust_analyses, print)
cat(paste('Combined SOM/clusetring analysis with',
x$dist_method, 'distance method.'))

cat('\nCluster assignment:\n')

print(as_tibble(x$clust_assignment))

}

Expand Down Expand Up @@ -61,9 +66,27 @@
stopifnot(is_red_analysis(x))

cat(paste0(toupper(x$red_fun), ' reduction analysis object.'))

cat('\nComponents:\n')

print(as_tibble(x$component_tbl))

}

#' @rdname print.clust_analysis
#' @export

print.tuner <- function(x, ...) {

stopifnot(is_tuner(x))

cat(paste('Tuning results for',
paste(x$tune_params, collapse = ', ')))

cat('\nBest parameter combination:\n')

print(as_tibble(x$best_tune))

}

# END ------
7 changes: 6 additions & 1 deletion R/class_testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @description
#' Tests if the object is an instance of the `red_analysis`, `clust_analysis`,
#' `combi_analysis`, `importance`, `cross_dist`, `sil_extra`, `min_analysis`,
#' `umatrix_analysis`, `cluster_cv` or `knb` class.
#' `umatrix_analysis`, `cluster_cv`, `knb` or `tuner` class.
#'
#' @return a logical value.
#'
Expand Down Expand Up @@ -60,4 +60,9 @@

is_knb <- function(x) inherits(x, 'knb')

#' @rdname is_clust_analysis
#' @export

is_tuner <- function(x) inherits(x, 'tuner')

# END ------
Loading

0 comments on commit 9ed2609

Please sign in to comment.