% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/trainNMF.R
\name{trainNMF}
\alias{trainNMF}
\title{train NMF model}
\usage{
trainNMF(
  x,
  y,
  groups = NULL,
  mgs,
  n_top = NULL,
  gene_id = "gene",
  group_id = "cluster",
  weight_id = "weight",
  hvg = NULL,
  model = c("ns", "std"),
  scale = TRUE,
  verbose = TRUE,
  slot_sc = "counts",
  slot_sp = "counts",
  ...
)
}
\arguments{
\item{x, y}{single-cell and mixture dataset, respectively. Can be a
numeric matrix or \code{SingleCellExperiment}.}

\item{groups}{character vector of group labels for cells in \code{x}.
When \code{x} is a \code{SingleCellExperiment},
defaults to \code{colLabels(x)}. Make sure groups is not a Factor.}

\item{mgs}{\code{data.frame} or \code{DataFrame} of marker genes.
Must contain columns holding gene identifiers, group labels and
the weight (e.g., logFC, -log(p-value) a feature has in a given group.}

\item{n_top}{integer scalar specifying the number of markers to select per
group. By default NULL uses all the marker genes to initialize the model.}

\item{gene_id, group_id, weight_id}{character specifying the column
in \code{mgs} containing gene identifiers, group labels and weights,
respectively.}

\item{hvg}{character vector containing hvg to include in the model.
By default NULL.}

\item{model}{character string indicating which model to use when running NMF.
Either "ns" (default) or "std".}

\item{scale}{logical specifying whether to scale single-cell counts to unit
variance. This gives the user the option to normalize the data beforehand
as you see fit (CPM, FPKM, ...) when passing a matrix or specifying the
slot from where to extract the count data.}

\item{verbose}{logical. Should information on progress be reported?}

\item{slot_sc, slot_sp}{If the object is of class \code{SingleCellExperiment}
indicates matrix to use. By default "counts".}

\item{...}{additional parameters.}
}
\value{
base a list where the first element is an \code{NMFfit} object and
  the second is a matrix containing the topic profiles learnt.
}
\description{
This is the training function used by SPOTLight. This function
  takes in single cell expression data, trains the model and learns topic
   profiles for each cell type
}
\examples{
set.seed(321)
# mock up some single-cell, mixture & marker data
sce <- mockSC(ng = 200, nc = 10, nt = 3)
spe <- mockSP(sce)
mgs <- getMGS(sce)

res <- trainNMF(
    x = sce,
    y = spe,
    groups = sce$type,
    mgs = mgs,
    weight_id = "weight",
    group_id = "type",
    gene_id = "gene")
# Get NMF model
res[["mod"]]
# Get topic profiles
res[["topic"]]
}
\author{
Marc Elosua Bayes & Helena L Crowell
}
