Description Usage Arguments Details Value Examples
View source: R/clusterSamples.R
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.
1 | clusterSamples(object, k, factors = "all", ...)
|
object |
a trained |
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 |
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:
Use clustering approaches that deal with NAs (not implemented in MOFA)
If the factor in question is not important, you can remove it with subsetFactors
If the factor in question is important and just a small number of samples are conflictive,
you can manually set them to 0 using object@Expectations$Z[is.na(object@Expectations$Z)] <- 0
By default, the conflictive samples are ignored in the clustering procedure and NAs are returned.
output from kmeans
function
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.