register_partition_methods {cola} | R Documentation |
Register user-defined partition functions
register_partition_methods(..., scale_method = c("standardization", "rescale", "none"))
... |
a named list of functions. |
scale_method |
normally, data matrix is scaled by rows before sent to the partition function. The default scaling is applied by |
The user-defined function should accept at least two arguments. The first two arguments are the data
matrix and the number of partitions. The third optional argument should always be ...
so that parameters
for the partition function can be passed by partition_param
from consensus_partition
.
If users forget to add ...
, it is added internally.
The function should return a vector of partitions (or class labels) or an object which can be recognized by cl_membership
.
The partition function should be applied on columns (Users should be careful with this because some of the R functions apply on rows and
some of the R functions apply on columns). E.g. following is how we register kmeans
partition method:
register_partition_methods( kmeans = function(mat, k, ...) { # mat is transposed because kmeans() applies on rows kmeans(t(mat), centers = k, ...)$centers } )
The registered partition methods will be used as defaults in run_all_consensus_partition_methods
.
To remove a partition method, use remove_partition_methods
.
There are following default partition methods:
hierarchcial clustering with Euclidean distance, later columns are partitioned by cutree
. If users want to use another distance metric or clustering method, consider to register a new partition method. E.g. register_partition_methods(hclust_cor = function(mat, k) cutree(hclust(as.dist(cor(mat)))))
.
by kmeans
.
by skmeans
.
by pam
.
by Mclust
. mclust is applied to the first three principle components from rows.
No value is returned.
Zuguang Gu <z.gu@dkfz.de>
all_partition_methods
lists all registered partition methods.
all_partition_methods() register_partition_methods( random = function(mat, k) sample(k, ncol(mat), replace = TRUE) ) all_partition_methods() remove_partition_methods("random")