computeCountPercentage.Rd
Calculates the percentage contribution of a specified set of molecules to the total counts within the count matrix of the given assay.
computeCountPercentage(
object,
regex = NULL,
molecules = NULL,
var_name = NULL,
assay_name = activeAssay(object),
overwrite = FALSE
)
An object of class SPATA2
or, in case of S4 generics,
objects of classes for which a method has been defined.
Character value. A regular expression with which to create the set of molecules (e.g. '^MT-.*' to subset human mitochondrial genes).
Character vector. Instead of providing a regular expression the set of molecules can be specified directly.
Character value. The name of the new meta feature.
Only relevant if the SPATA2
object contains more than
one assay: Denotes the assay of interest and thus the
molecular modality to use. Defaults to the active assay
as set by activateAssay()
.
Logical value. Must be TRUE
to allow overwriting.
The updated input object, containing the added, removed or computed results.
The equivalent of Seurat::PercentageFeatureSet()
. Usage differs. See examples.
library(SPATA2)
library(SPATAData)
library(patchwork)
object <- downloadSpataObject("MGH258")
# compute the percentage contribution of mitochondrial genes
object <- computeCountPercentage(object, regex = "MT-.*", var_name = "perc_mit")
plotSurface(object, color_by = "perc_mit") +
plotDensityPlot(object, variables = "perc_mit")
# keep only spots with less than 20% mitochondrial counts
object <- filterSpataObject(object, perc_mit < 20)
# new outlier identification necessary?
plotSurface(object, color_by = "tissue_section")