This function returns a SummarizedExperiment with clustering
information in its colData or rowData
getCluster(x, ...)
addCluster(x, ...)
# S4 method for class 'SummarizedExperiment'
addCluster(
x,
BLUSPARAM,
assay.type = assay_name,
assay_name = NULL,
by = MARGIN,
MARGIN = "rows",
name = "clustering",
clust.col = "cluster",
full = FALSE,
...
)
# S4 method for class 'SingleCellExperiment'
addCluster(
x,
BLUSPARAM,
assay.type = assay_name,
assay_name = NULL,
dimred = NULL,
by = MARGIN,
MARGIN = "rows",
name = "clustering",
clust.col = "cluster",
full = FALSE,
...
)
# S4 method for class 'SummarizedExperiment'
getCluster(
x,
BLUSPARAM,
assay.type = assay_name,
assay_name = NULL,
by = MARGIN,
MARGIN = "rows",
...
)
# S4 method for class 'SingleCellExperiment'
getCluster(
x,
BLUSPARAM,
assay.type = assay_name,
assay_name = NULL,
dimred = NULL,
by = MARGIN,
MARGIN = "rows",
...
)
# S4 method for class 'ANY'
getCluster(x, BLUSPARAM, by = MARGIN, MARGIN = "rows", full = FALSE, ...)A
SummarizedExperiment
object.
Additional parameters to use altExps for example
A BlusterParam object specifying the algorithm to use.
Character scalar. Specifies the name of assay
used in calculation.
Deprecated. Use assay.type instead.
Character scalar. Determines if association is calculated
row-wise / for features ('rows') or column-wise / for samples ('cols').
Must be 'rows' or 'cols'.
Deprecated. Use by instead.
Character scalar. The name to store the result in
metadata
Character scalar. Indicates the name of the
rowData (or colData) where the data will be stored.
(Default: "clusters")
Logical scalar indicating whether the full clustering statistics should be returned for each method.
Character scalar or integer scalar.
Specifies dimension reduction results used in calculation. Either
dimred or assay.type must be specified.
addCluster returns an object of the same type as the x
parameter with clustering information named clusters stored in
colData or rowData.
This is a wrapper for the clusterRows function from the
bluster package.
When setting full = TRUE, the clustering information will be stored in
the metadata of the object.
By default, clustering is done on the features.
library(bluster)
data(GlobalPatterns, package = "mia")
tse <- GlobalPatterns
# Cluster on rows using Kmeans
tse <- addCluster(
tse,
assay.type = "counts",
BLUSPARAM = KmeansParam(centers = 3)
)
# Clustering done on the samples using Hclust
res <- getCluster(
tse,
assay.type = "counts",
by = "samples",
BLUSPARAM = HclustParam(metric = "bray", dist.fun = vegan::vegdist)
)
res |> head()
#> CL3 CC1 SV1 M31Fcsw M11Fcsw M31Plmr
#> 1 2 3 4 5 6
#> Levels: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# Apply clustering to PCA results
library(scater)
#> Loading required package: scuttle
#> Loading required package: ggplot2
tse <- transformAssay(tse, method = "rclr")
tse <- runPCA(tse, assay.type = "rclr")
#> Warning: more singular values/vectors requested than available
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
tse <- addCluster(
tse,
dimred = "PCA",
BLUSPARAM = KmeansParam(centers = 3),
by = 2
)
tse$cluster |> head()
#> CL3 CC1 SV1 M31Fcsw M11Fcsw M31Plmr
#> 1 1 1 2 2 3
#> Levels: 1 2 3