cluster_scMethrix: Generates a cluster object for an 'scMethrix' object

Description Usage Arguments Details Value See Also Examples

View source: R/scMethrix_clustering.R

Description

Generates a cluster object for an scMethrix object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cluster_scMethrix(
  scm = NULL,
  dist = NULL,
  assay = "score",
  type = c("hierarchical", "partition", "model"),
  colname = "Cluster",
  n_clusters = 1,
  verbose = TRUE,
  ...
)

Arguments

scm

scMethrix; Input scMethrix object. If this is specified the distance matrix will be a generic spearman.dist distance

dist

dist; Optional. A distance matrix generated for an assay. Will use default paramaters for get_distance_matrix.

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. c(C1=1,C2=1,C3=1,C4=2)).

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

Details

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.

Value

An scMethrix object

See Also

get_distance_matrix() for distance metrics, hclust() for heirarchical clustering, kmeans() for partition clustering, Mclust() for model clustering

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data('scMethrix_data')
scMethrix_data <- impute_regions(scMethrix_data)
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
colData(cluster_scMethrix(scMethrix_data, dist = dist, type = fun))

CompEpigen/scMethrix documentation built on Nov. 6, 2021, 3:09 p.m.