register_partition_method: Register user-defined partition functions

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/z.global.R

Description

Register user-defined partition functions

Usage

1
register_partition_method(..., scale_method = c("standardization", "rescale", "none"))

Arguments

...

a named list of functions.

scale_method

normally, data matrix are scaled by rows before sent to the partition function. The default scaling is applied by scale. However, some partition functions may not accept negative values which are produced by scale. Here scale_method can be set to rescale which scales rows by (x - min)/(max - min). Note here scale_method only means the method to scale rows. When scale_rows is set to FALSE in consensus_partition or run_all_consensus_partition_methods, there wil be no row scaling when doing partition. The value for scale_method can be a vector if user specifies more than one partition function.

Details

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 or run_all_consensus_partition_methods. If users forget to add ... in the end, 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:

1
2
3
4
5
  register_partition_method(
      kmeans = function(mat, k, ...) {
          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_method.

There are following default partition methods:

"hclust"

hierarchcial clustering with Euclidean distance, later columns are partitioned by cutree. If users want to use another distance metric, consider to register a new partition method. E.g. register_partition_method(hclust_cor = function(mat, k) hc = cutree(hclust(as.dist(cor(mat))))).

"kmeans"

by kmeans.

"skmeans"

by skmeans.

"pam"

by pam.

"mclust"

by Mclust. mclust is applied to the first three principle components from rows.

"som"

by som. The SOM map is organized as kr x kr grids where kr = floor(sqrt(ncol(mat))).

Value

No value is returned.

Author(s)

Zuguang Gu <[email protected]>

See Also

all_partition_methods lists all registered partition methods.

Examples

1
2
3
4
5
6

jokergoo/cola documentation built on Nov. 13, 2018, 1:22 p.m.