% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/perplexity.R
\name{resamplePerplexity}
\alias{resamplePerplexity}
\alias{resamplePerplexity,SingleCellExperiment-method}
\alias{resamplePerplexity,matrix-method}
\title{Calculate and visualize perplexity of all models in a celdaList, with
 count resampling}
\usage{
resamplePerplexity(x, ...)

\S4method{resamplePerplexity}{SingleCellExperiment}(
  x,
  useAssay = "counts",
  altExpName = "featureSubset",
  resample = 5,
  seed = 12345
)

\S4method{resamplePerplexity}{matrix}(x, celdaList, resample = 5, seed = 12345)
}
\arguments{
\item{x}{A numeric \link{matrix} of counts or a
\linkS4class{SingleCellExperiment} returned from \link{celdaGridSearch}
with the matrix located in the assay slot under \code{useAssay}.
Rows represent features and columns represent cells. Must contain
"celda_grid_search" slot in \code{metadata(x)} if \code{x} is a
\linkS4class{SingleCellExperiment} object.}

\item{...}{Ignored. Placeholder to prevent check warning.}

\item{useAssay}{A string specifying which \link{assay}
slot to use if \code{x} is a
\linkS4class{SingleCellExperiment} object. Default "counts".}

\item{altExpName}{The name for the \link{altExp} slot
to use. Default "featureSubset".}

\item{resample}{Integer. The number of times to resample the counts matrix
for evaluating perplexity. Default 5.}

\item{seed}{Integer. Passed to \link[withr]{with_seed}. For reproducibility,
a default value of 12345 is used. If NULL, no calls to
\link[withr]{with_seed} are made.}

\item{celdaList}{Object of class 'celdaList'. Used only if \code{x} is a
matrix object.}
}
\value{
A \linkS4class{SingleCellExperiment} object or
 \code{celdaList} object with a \code{perplexity}
 property, detailing the perplexity of all K/L combinations that appeared in
 the celdaList's models.
}
\description{
Calculates the perplexity of each model's cluster assignments
 given the provided countMatrix, as well as resamplings of that count
 matrix, providing a distribution of perplexities and a better sense of the
 quality of a given K/L choice.
}
\examples{
data(sceCeldaCGGridSearch)
sce <- resamplePerplexity(sceCeldaCGGridSearch)
plotGridSearchPerplexity(sce)
data(celdaCGSim, celdaCGGridSearchRes)
celdaCGGridSearchRes <- resamplePerplexity(
  celdaCGSim$counts,
  celdaCGGridSearchRes
)
plotGridSearchPerplexity(celdaCGGridSearchRes)
}