clusterSamples: clusterSamples: K-means clustering on samples based on latent...

Description Usage Arguments Details Value Examples

View source: R/clusterSamples.R

Description

MOFA factors are continuous in nature but they can be used to predict discrete clusters of samples, similar to the iCluster model (Shen, 2009).
The clustering can be performed in a single factor, which is equivalent to setting a manual threshold; or using multiple factors, where multiple sources of variation are aggregated.
Importantly, this type of clustering is not weighted and does not take into account the different importance of the latent factors.

Usage

1
clusterSamples(object, k, factors = "all", ...)

Arguments

object

a trained MOFAmodel object.

k

number of clusters

factors

character vector with the factor name(s), or numeric vector with the index of the factor(s) to use. Default is 'all'

...

extra arguments passed to kmeans

Details

In some cases, samples can have missing values in the factor space. This occurs when a factor is active in a single view and some samples are missing this data.
In such a case, there are several strategies to follow:

By default, the conflictive samples are ignored in the clustering procedure and NAs are returned.

Value

output from kmeans function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Example on the CLL data
filepath <- system.file("extdata", "CLL_model.hdf5", package = "MOFAdata")
MOFA_CLL <- loadModel(filepath)
# cluster samples based into 3 groups based on all factors
clusterSamples(MOFA_CLL, k=3, factors="all")
# cluster samples based into 2 groups based on factor 1
clusters <- clusterSamples(MOFA_CLL, k=2, factors=1)
# cluster can be visualized for example on the factors values:
plotFactorBeeswarm(MOFA_CLL, factor=1, color_by=clusters)

# Example on the scMT data
filepath <- system.file("extdata", "scMT_model.hdf5", package = "MOFAdata")
MOFA_scMT <- loadModel(filepath)
# cluster samples based into 2 groups based on all factor 1 and 2
clusters <- clusterSamples(MOFA_CLL, k=2, factors=1:2)
# cluster can be visualized for example on the factors values:
plotFactorScatter(MOFA_CLL, factors=1:2, color_by=clusters)

MOFA documentation built on Feb. 11, 2021, 2:01 a.m.