% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cluster.R
\name{graphClustering}
\alias{graphClustering}
\title{Spectral Graph Clustering}
\usage{
graphClustering(
  object,
  dim.use = c("pca", "dm"),
  cells.use = NULL,
  which.dims = which(object@pca.sig),
  num.nn = 30,
  do.jaccard = TRUE,
  method = c("Louvain", "Infomap"),
  group.id = method
)
}
\arguments{
\item{object}{An URD object}

\item{dim.use}{(Character) Calculate on principal components (\code{pca}) or diffusion components (\code{dm})}

\item{cells.use}{(Character vector) Which cells to include in the clustering (default is NULL, which uses all cells)}

\item{which.dims}{(Numeric vector) Which PCs (or diffusion components) to use. Defaults to the significant PCs. (The default will probably work with diffusion components, though it is non-sensical in that case.)}

\item{num.nn}{(Numeric or numeric vector) How many nearest-neighbors to use in the k-nn graph. (If multiple values are provided, multiple clusterings are calculated.)}

\item{do.jaccard}{(Logical) Weight edges in the k-nn graph according to their Jaccard overlap?}

\item{method}{(Character) Clustering method to use (\code{Louvain})}

\item{group.id}{(Character) Prefix to use for clustering name (Default is method). Number of nearest neighbors is appended.}
}
\value{
An URD object with cluster identities saved in \code{@group.ids} in the column named \code{group.id}.
}
\description{
Computes a spectral graph-based clustering, either on principal components or
diffusion components. A k-nearest neighbor graph is computed, its edges are
optionally weighted by the Jaccard overlap of cells' neighborhoods, and then
a clustering is computed with either the Louvain or Infomap algorithms. The
resultant clustering is stored as a column in the slot \code{@group.ids}. The
number of detected clusters is sensitive to the nearest neighbor parameter,
and several should be investigated.
}
\examples{
# Try several different nearest neighbor parameters
# Output will be stored as Infomap-10, Infomap-15, ... in object.6s.mnn@group.ids
object.6s.mnn <- graphClustering(object.6s.mnn, num.nn = c(10,15,20,30,40), 
method="Infomap", do.jaccard = T)

# Cluster on the diffusion map instead of PCA
# Output will be stored as Louvain-DM-10, Louvain-DM-20, Louvain-DM-30, etc.
object <- graphClustering(object, dim.use="dm", num.nn = c(10,20,30,40), method="Louvain", do.jaccard=T, group.id="Louvain-DM")

}
