man/runSoupX.Rd
19fd2e8f
 % Generated by roxygen2: do not edit by hand
 % Please edit documentation in R/runSoupX.R
 \name{runSoupX}
 \alias{runSoupX}
2a3bb2b3
 \title{Detecting and correct contamination with SoupX}
19fd2e8f
 \usage{
 runSoupX(
   inSCE,
   sample = NULL,
   useAssay = "counts",
   background = NULL,
   bgAssayName = NULL,
   bgBatch = NULL,
   assayName = ifelse(is.null(background), "SoupX", "SoupX_bg"),
   cluster = NULL,
2a3bb2b3
   reducedDimName = ifelse(is.null(background), "SoupX_UMAP_", "SoupX_bg_UMAP_"),
19fd2e8f
   tfidfMin = 1,
   soupQuantile = 0.9,
2a3bb2b3
   maxMarkers = 100,
   contaminationRange = c(0.01, 0.8),
   rhoMaxFDR = 0.2,
   priorRho = 0.05,
   priorRhoStdDev = 0.1,
   forceAccept = FALSE,
19fd2e8f
   adjustMethod = c("subtraction", "soupOnly", "multinomial"),
   roundToInt = FALSE,
2a3bb2b3
   tol = 0.001,
19fd2e8f
   pCut = 0.01
 )
 }
 \arguments{
 \item{inSCE}{A \linkS4class{SingleCellExperiment} object.}
 
 \item{sample}{A single character specifying a name that can be found in
 \code{colData(inSCE)} to directly use the cell annotation; or a character
 vector with as many elements as cells to indicates which sample each cell
93e2414e
 belongs to. SoupX will be run on cells from each sample separately. Default
19fd2e8f
 \code{NULL}.}
 
93e2414e
 \item{useAssay}{A single character string specifying which assay in
19fd2e8f
 \code{inSCE} to use. Default \code{'counts'}.}
 
93e2414e
 \item{background}{A numeric matrix of counts or a
 \linkS4class{SingleCellExperiment} object with the matrix in \code{assay}
 slot. It should have the same structure as \code{inSCE} except it contains
19fd2e8f
 the matrix including empty droplets. Default \code{NULL}.}
 
93e2414e
 \item{bgAssayName}{A single character string specifying which assay in
 \code{background} to use when \code{background} is a
19fd2e8f
 \linkS4class{SingleCellExperiment} object. If \code{NULL}, the function
 will use the same value as \code{useAssay}. Default \code{NULL}.}
 
 \item{bgBatch}{The same thing as \code{sample} but for \code{background}. Can
93e2414e
 be a single character only when \code{background} is a
19fd2e8f
 \linkS4class{SingleCellExperiment} object. Default \code{NULL}.}
 
93e2414e
 \item{assayName}{A single character string of the output corrected matrix.
 Default \code{"SoupX"} when not using a background, otherwise,
19fd2e8f
 \code{"SoupX_bg"}.}
 
93e2414e
 \item{cluster}{Prior knowledge of clustering labels on cells. A single
 character string for specifying clustering label stored in
19fd2e8f
 \code{colData(inSCE)}, or a character vector with as many elements as cells.
fe29a031
 When not supplied, \code{\link[scran]{quickCluster}} method will be applied.}
19fd2e8f
 
93e2414e
 \item{reducedDimName}{A single character string of the prefix of output
 corrected embedding matrix for each sample. Default \code{"SoupX_UMAP_"} when
2a3bb2b3
 not using a background, otherwise, \code{"SoupX_bg_UMAP_"}.}
 
93e2414e
 \item{tfidfMin}{Numeric. Minimum value of tfidf to accept for a marker gene.
2a3bb2b3
 Default \code{1}. See \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{soupQuantile}{Numeric. Only use genes that are at or above this
 expression quantile in the soup. This prevents inaccurate estimates due to
 using genes with poorly constrained contribution to the background. Default
2a3bb2b3
 \code{0.9}. See \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{maxMarkers}{Integer. If we have heaps of good markers, keep only the
2a3bb2b3
 best maxMarkers of them. Default \code{100}. See \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{contaminationRange}{Numeric vector of two elements. This constrains
2a3bb2b3
 the contamination fraction to lie within this range. Must be between 0 and 1.
93e2414e
 The high end of this range is passed to
 \code{\link[SoupX]{estimateNonExpressingCells}} as
 \code{maximumContamination}. Default \code{c(0.01, 0.8)}. See
2a3bb2b3
 \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{rhoMaxFDR}{Numeric. False discovery rate passed to
 \code{\link[SoupX]{estimateNonExpressingCells}}, to test if rho is less than
 \code{maximumContamination}. Default \code{0.2}. See
19fd2e8f
 \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{priorRho}{Numeric. Mode of gamma distribution prior on contamination
2a3bb2b3
 fraction. Default \code{0.05}. See \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{priorRhoStdDev}{Numeric. Standard deviation of gamma distribution prior
 on contamination fraction. Default \code{0.1}. See
19fd2e8f
 \code{?SoupX::autoEstCont}.}
 
2a3bb2b3
 \item{forceAccept}{Logical. Should we allow very high contamination fractions
93e2414e
 to be used. Passed to \code{\link[SoupX]{setContaminationFraction}}. Default
2a3bb2b3
 \code{FALSE}. See \code{?SoupX::autoEstCont}.}
 
93e2414e
 \item{adjustMethod}{Character. Method to use for correction. One of
 \code{'subtraction'}, \code{'soupOnly'}, or \code{'multinomial'}. Default
19fd2e8f
 \code{'subtraction'}. See \code{?SoupX::adjustCounts}.}
 
93e2414e
 \item{roundToInt}{Logical. Should the resulting matrix be rounded to
2a3bb2b3
 integers? Default \code{FALSE}. See \code{?SoupX::adjustCounts}.}
 
93e2414e
 \item{tol}{Numeric. Allowed deviation from expected number of soup counts.
2a3bb2b3
 Don't change this. Default \code{0.001}. See \code{?SoupX::adjustCounts}.}
19fd2e8f
 
93e2414e
 \item{pCut}{Numeric. The p-value cut-off used when
 \code{method = 'soupOnly'}. Default \code{0.01}. See
19fd2e8f
 \code{?SoupX::adjustCounts}.}
 }
 \value{
93e2414e
 The input \code{inSCE} object with \code{soupX_nUMIs},
 \code{soupX_clustrers}, \code{soupX_contamination} appended to \code{colData}
 slot; \code{soupX_{sample}_est} and \code{soupX_{sample}_counts} for each
 sample appended to \code{rowData} slot; and other computational metrics at
19fd2e8f
 \code{getSoupX(inSCE)}. Replace "soupX" to "soupX_bg" when \code{background}
 is used.
 }
 \description{
93e2414e
 A wrapper function for \link[SoupX]{autoEstCont} and
 \link[SoupX]{adjustCounts}. Identify potential contamination from
2a3bb2b3
 experimental factors such as ambient RNA. Visit
19fd2e8f
 \href{https://rawcdn.githack.com/constantAmateur/SoupX/204b602418df12e9fdb4b68775a8b486c6504fe4/inst/doc/pbmcTutorial.html}{their vignette}
 for better understanding.
 }
7bebf185
 \examples{
 \dontrun{
93e2414e
 # SoupX does not work for toy example,
71984ccf
 sce <- importExampleData("pbmc3k")
7bebf185
 sce <- runSoupX(sce, sample = "sample")
26d84d20
 plotSoupXResults(sce, sample = "sample")
7bebf185
 }
 }
26d84d20
 \seealso{
 plotSoupXResults
 }
19fd2e8f
 \author{
 Yichen Wang
 }