scMethrix objectR/scMethrix_clustering.R
cluster_scMethrix.RdGenerates a cluster object for an scMethrix object
cluster_scMethrix( scm = NULL, dist = NULL, assay = "score", type = c("hierarchical", "partition", "model"), colname = "Cluster", n_clusters = 1, verbose = TRUE, ... )
| scm | scMethrix; Input |
|---|---|
| dist | dist; Optional. A distance matrix generated for an assay. Will use default paramaters for |
| assay | string; The assay to use. Default is 'score' |
| type | string; The type of distance metric to use. Available options are 'hierarchical', 'partition', "model". An arbitrary cluster function can be used, and must return a named vector containing integers representing the cluster membership (e.g. |
| colname | string; the name of the colData column that contains the cluster information |
| n_clusters | integer; the desired number of clusters. This is ignored for model-based clustering |
| verbose | boolean; flag to output messages or not |
| ... | Additional parameters for the clustering functions |
An scMethrix object
Enables multiple methods of clustering to classify samples in an scMethrix object. Either an scMethrix object or a dist object must be provided for clustering.
get_distance_matrix() for distance metrics, hclust() for heirarchical clustering, kmeans() for partition clustering, Mclust() for model clustering
#>#>dist <- get_distance_matrix(scMethrix_data,assay = "impute") # For a generic clustering function # The function must return a named vector of integers fun <- function (dist) { fit <- hclust(dist, method="ward.D") fit <- cutree(fit, k=2) return(fit) } fun(dist) # Example of arbitrary function output#> C1 C2 C3 C4 #> 1 1 1 2colData(cluster_scMethrix(scMethrix_data, dist = dist, type = fun))#> DataFrame with 4 rows and 2 columns #> Sample Cluster #> <integer> <integer> #> C1 1 1 #> C2 2 1 #> C3 3 1 #> C4 4 2