% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllGenerics.R, R/cluster.R
\name{getCluster}
\alias{getCluster}
\alias{addCluster}
\alias{addCluster,SummarizedExperiment-method}
\alias{addCluster,SingleCellExperiment-method}
\alias{getCluster,SummarizedExperiment-method}
\alias{getCluster,SingleCellExperiment-method}
\alias{getCluster,ANY-method}
\title{Clustering wrapper}
\usage{
getCluster(x, ...)

addCluster(x, ...)

\S4method{addCluster}{SummarizedExperiment}(
  x,
  BLUSPARAM,
  assay.type = assay_name,
  assay_name = NULL,
  by = MARGIN,
  MARGIN = "rows",
  name = "clustering",
  clust.col = "cluster",
  full = FALSE,
  ...
)

\S4method{addCluster}{SingleCellExperiment}(
  x,
  BLUSPARAM,
  assay.type = assay_name,
  assay_name = NULL,
  dimred = NULL,
  by = MARGIN,
  MARGIN = "rows",
  name = "clustering",
  clust.col = "cluster",
  full = FALSE,
  ...
)

\S4method{getCluster}{SummarizedExperiment}(
  x,
  BLUSPARAM,
  assay.type = assay_name,
  assay_name = NULL,
  by = MARGIN,
  MARGIN = "rows",
  ...
)

\S4method{getCluster}{SingleCellExperiment}(
  x,
  BLUSPARAM,
  assay.type = assay_name,
  assay_name = NULL,
  dimred = NULL,
  by = MARGIN,
  MARGIN = "rows",
  ...
)

\S4method{getCluster}{ANY}(x, BLUSPARAM, by = MARGIN, MARGIN = "rows", full = FALSE, ...)
}
\arguments{
\item{x}{A
\code{\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}}
object.}

\item{...}{Additional parameters to use altExps for example}

\item{BLUSPARAM}{A \linkS4class{BlusterParam} object specifying the algorithm to use.}

\item{assay.type}{\code{Character scalar}. Specifies the name of assay
used in calculation.}

\item{assay_name}{Deprecated. Use \code{assay.type} instead.}

\item{by}{\code{Character scalar}. Determines if association is calculated
row-wise / for features ('rows') or column-wise / for samples ('cols').
Must be \code{'rows'} or \code{'cols'}.}

\item{MARGIN}{Deprecated. Use \code{by} instead.}

\item{name}{\code{Character scalar}. The name to store the result in
\code{\link[SummarizedExperiment:RangedSummarizedExperiment-class]{metadata}}}

\item{clust.col}{\code{Character scalar}. Indicates the name of the
\code{rowData} (or \code{colData}) where the data will be stored.
(Default: \code{"clusters"})}

\item{full}{Logical scalar indicating whether the full clustering statistics should be returned for each method.}

\item{dimred}{\code{Character scalar} or \code{integer scalar}.
Specifies dimension reduction results used in calculation. Either
\code{dimred} or \code{assay.type} must be specified.}
}
\value{
\code{addCluster} returns an object of the same type as the \code{x}
parameter with clustering information named \code{clusters} stored in
\code{colData} or \code{rowData}.
}
\description{
This function returns a \code{SummarizedExperiment} with clustering
information in its colData or rowData
}
\details{
This is a wrapper for the \code{clusterRows} function from the
\link[bluster]{bluster} package.

When setting \code{full = TRUE}, the clustering information will be stored in
the metadata of the object.

By default, clustering is done on the features.
}
\examples{
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()

# Apply clustering to PCA results
library(scater)
tse <- transformAssay(tse, method = "rclr")
tse <- runPCA(tse, assay.type = "rclr")
tse <- addCluster(
    tse,
    dimred = "PCA",
    BLUSPARAM = KmeansParam(centers = 3),
    by = 2
)
tse$cluster |> head()

}
