Title: | Data Structures for Single Cell Data |
Version: | 5.1.0 |
Description: | Defines S4 classes for single-cell genomic data and associated information, such as dimensionality reduction embeddings, nearest-neighbor graphs, and spatially-resolved coordinates. Provides data access methods and R-native hooks to ensure the Seurat object is familiar to other R users. See Satija R, Farrell J, Gennert D, et al (2015) <doi:10.1038/nbt.3192>, Macosko E, Basu A, Satija R, et al (2015) <doi:10.1016/j.cell.2015.05.002>, and Stuart T, Butler A, et al (2019) <doi:10.1016/j.cell.2019.05.031>, Hao Y, Hao S, et al (2021) <doi:10.1016/j.cell.2021.04.048> and Hao Y, et al (2023) <doi:10.1101/2022.02.24.481684> for more details. |
License: | MIT + file LICENSE |
URL: | https://satijalab.github.io/seurat-object/, https://github.com/satijalab/seurat-object |
BugReports: | https://github.com/satijalab/seurat-object/issues |
Additional_repositories: | https://bnprks.r-universe.dev |
Depends: | R (≥ 4.1.0), sp (≥ 1.5.0) |
Imports: | future, future.apply, generics, grDevices, grid, lifecycle, Matrix (≥ 1.6.4), methods, progressr, Rcpp (≥ 1.0.5), rlang (≥ 0.4.7), spam, stats, tools, utils |
Suggests: | BPCells, DelayedArray, fs (≥ 1.5.2), ggplot2, HDF5Array, rmarkdown, sf (≥ 1.0.0), testthat |
LinkingTo: | Rcpp, RcppEigen |
Config/Needs/website: | pkgdown |
BuildManual: | true |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
Collate: | 'RcppExports.R' 'zzz.R' 'generics.R' 'keymixin.R' 'graph.R' 'default.R' 'assay.R' 'logmap.R' 'layers.R' 'assay5.R' 'centroids.R' 'command.R' 'compliance.R' 'data.R' 'jackstraw.R' 'dimreduc.R' 'segmentation.R' 'molecules.R' 'spatial.R' 'fov.R' 'neighbor.R' 'seurat.R' 'sparse.R' 'utils.R' |
NeedsCompilation: | yes |
Packaged: | 2025-04-22 18:55:17 UTC; root |
Author: | Paul Hoffman |
Maintainer: | Rahul Satija <seurat@nygenome.org> |
Repository: | CRAN |
Date/Publication: | 2025-04-22 19:40:01 UTC |
SeuratObject: Data Structures for Single Cell Data
Description
Defines S4 classes for single-cell genomic data and associated information, such as dimensionality reduction embeddings, nearest-neighbor graphs, and spatially-resolved coordinates. Provides data access methods and R-native hooks to ensure the Seurat object is familiar to other R users. See Satija R, Farrell J, Gennert D, et al (2015) doi:10.1038/nbt.3192, Macosko E, Basu A, Satija R, et al (2015) doi:10.1016/j.cell.2015.05.002, and Stuart T, Butler A, et al (2019) doi:10.1016/j.cell.2019.05.031, Hao Y, Hao S, et al (2021) doi:10.1016/j.cell.2021.04.048 and Hao Y, et al (2023) doi:10.1101/2022.02.24.481684 for more details.
Author(s)
Maintainer: Rahul Satija seurat@nygenome.org (ORCID)
Authors:
Paul Hoffman hoff0792@alumni.umn.edu (ORCID)
David Collins dcollins@nygenome.org (ORCID)
Yuhan Hao yhao@nygenome.org (ORCID)
Austin Hartman ahartman@nygenome.org (ORCID)
Gesmira Molla gmolla@nygenome.org (ORCID)
Andrew Butler abutler@nygenome.org (ORCID)
Tim Stuart tstuart@nygenome.org (ORCID)
Other contributors:
Madeline Kowalski mkowalski@nygenome.org (ORCID) [contributor]
Saket Choudhary schoudhary@nygenome.org (ORCID) [contributor]
Skylar Li sli@nygenome.org [contributor]
Longda Jiang ljiang@nygenome.org (ORCID) [contributor]
Jeff Farrell jfarrell@g.harvard.edu [contributor]
Shiwei Zheng szheng@nygenome.org (ORCID) [contributor]
Christoph Hafemeister chafemeister@nygenome.org (ORCID) [contributor]
Patrick Roelli proelli@nygenome.org [contributor]
See Also
Useful links:
Report bugs at https://github.com/satijalab/seurat-object/issues
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'Assay'
x$i
## S3 replacement method for class 'Assay'
x$i <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
value |
A matrix-like object to add as a new layer |
Value
$: Layer data for layer i
$<-
: x
with layer data value
saved as i
See Also
v3 Assay object, validity, and interaction methods:
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
rna <- pbmc_small[["RNA"]]
# Fetch a layer with `$`
rna$data[1:10, 1:4]
# Add a layer with `$`
rna$data <- rna$counts
rna$data[1:10, 1:4]
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'Assay5'
x$i
## S3 replacement method for class 'Assay5'
x$i <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
value |
A matrix-like object to add as a new layer |
Value
$: Layer data for layer i
$<-
: x
with layer data value
saved as i
See Also
v5 Assay object, validity, and interaction methods:
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Cell-Level Meta Data
Description
Get and set cell-level meta data
Usage
## S3 method for class 'Seurat'
x$i
## S3 replacement method for class 'Seurat'
x$i, ... <- value
## S4 replacement method for signature 'Seurat,character,missing,data.frame'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,missing,missing,data.frame'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,factor'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,list'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,missing,missing,list'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,vector'
x[[i, j, ...]] <- value
Arguments
x |
A |
i |
Name of cell-level meta data |
... |
Ignored |
value |
A vector to add as cell-level meta data |
j |
Ignored |
Value
$: Metadata column i
for object x
;
note: unlike [[
, $
drops the shape of the metadata
to return a vector instead of a data frame
$<-
: x
with metadata value
saved as i
See Also
Seurat object, validity, and interaction methods
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Examples
# Get metadata using `$'
head(pbmc_small$groups)
# Add metadata using the `$' operator
set.seed(42)
pbmc_small$value <- sample(1:3, size = ncol(pbmc_small), replace = TRUE)
head(pbmc_small[["value"]])
Command Log Parameter Access
Description
Pull parameter values from a SeuratCommand
object
Usage
## S3 method for class 'SeuratCommand'
x$i
Arguments
x |
A |
i |
A parameter name |
Value
The value for parameter i
See Also
Command log object and interaction methods
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Examples
cmd <- pbmc_small[["NormalizeData.RNA"]]
cmd$normalization.method
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'StdAssay'
x$i
## S3 replacement method for class 'StdAssay'
x$i <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
value |
A matrix-like object to add as a new layer |
Value
$: Layer data for layer i
$<-
: x
with layer data value
saved as i
See Also
v5 Standard Assay object, validity, and interaction methods
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Assay Class Label
Description
Assay Class Label
Usage
.AssayClass(object)
## S3 method for class 'StdAssay'
.AssayClass(object)
## Default S3 method:
.AssayClass(object)
Arguments
object |
A |
Value
The assay class label for object
BPCells Matrix Mode
Description
Get the mode (on-disk, in-memory) of an IterableMatrix
object
from BPCells
Usage
.BPMatrixMode(object, simplify = FALSE)
Arguments
object |
An |
simplify |
Return “ |
Value
One of the following, depending on the mode of object
:
-
“
memory
” -
“
file
” -
“
directory
”
If simplify
is TRUE
, returns “disk
” instead of
“file
” or “directory
”
Calculate nCount and nFeature
Description
Calculate nCount and nFeature
Usage
.CalcN(object, ...)
Arguments
object |
An assay-like object |
... |
Arguments passed to other methods |
Value
A named list with ...
Examples
calcn <- .CalcN(pbmc_small[["RNA"]])
head(as.data.frame(calcn))
Check Feature Margin
Description
Check Feature Margin
Usage
.CheckFmargin(fmargin)
Arguments
fmargin |
Either |
Value
fmargin
Examples
.CheckFmargin(1L)
.CheckFmargin(2.3)
# Error if `fmargin` is outside of [1:2]
if (FALSE) {
.CheckFmargin(3L)
}
Get the Package that Defines a Class
Description
Get the Package that Defines a Class
Usage
.ClassPkg(object)
## Default S3 method:
.ClassPkg(object)
## S3 method for class 'DelayedArray'
.ClassPkg(object)
## S3 method for class 'R6'
.ClassPkg(object)
## S3 method for class 'R6ClassGenerator'
.ClassPkg(object)
Arguments
object |
An object |
Value
The package that defines the class of object
Examples
.ClassPkg(pbmc_small)
Identify Object Collections
Description
Find all collection (named lists) slots in an S4 object
Usage
.Collections(object, exclude = character(length = 0L), ...)
Arguments
object |
An S4 object |
exclude |
A character vector of slot names to exclude |
... |
Arguments passed to |
Value
A character vector of names of collection slots
See Also
.FilterObjects()
,
.FindObject()
,
.Subobjects()
Examples
.Collections(pbmc_small)
Get Parent S4 Classes
Description
Get Parent S4 Classes
Usage
.Contains(object)
Arguments
object |
An S4 object |
Value
A vector of class names that object
inherits from
Examples
.Contains(pbmc_small)
Generic Assay Creation
Description
Create an assay object; runs a standardized filtering scheme that
works regardless of the direction of the data (eg. cells as columns
and features as rows or vice versa) and creates an assay object based
on the initialization scheme defined for StdAssay
-derived
class type
Usage
.CreateStdAssay(
counts,
min.cells = 0,
min.features = 0,
cells = NULL,
features = NULL,
transpose = FALSE,
type = "Assay5",
...
)
## Default S3 method:
.CreateStdAssay(
counts,
min.cells = 0,
min.features = 0,
cells = NULL,
features = NULL,
transpose = FALSE,
type = "Assay5",
layer = "counts",
...
)
## S3 method for class 'list'
.CreateStdAssay(
counts,
min.cells = 0,
min.features = 0,
cells = NULL,
features = NULL,
transpose = FALSE,
type = "Assay5",
csum = Matrix::colSums,
fsum = Matrix::rowSums,
...
)
## S3 method for class 'Matrix'
.CreateStdAssay(
counts,
min.cells = 0,
min.features = 0,
cells = NULL,
features = NULL,
transpose = FALSE,
type = "Assay5",
layer = "counts",
...
)
## S3 method for class 'matrix'
.CreateStdAssay(
counts,
min.cells = 0,
min.features = 0,
cells = NULL,
features = NULL,
transpose = FALSE,
type = "Assay5",
layer = "counts",
...
)
Arguments
counts |
A two-dimensional expression matrix |
min.cells |
Include features detected in at least this many cells; will subset the counts matrix as well. To reintroduce excluded features, create a new object with a lower cutoff |
min.features |
Include cells where at least this many features are detected |
cells |
Vector of cell names |
features |
Vector of feature names |
type |
Type of assay object to create; must be the name of a class
that's derived from |
... |
Extra parameters passed to |
layer |
Name of layer to store |
csum |
Function for calculating cell sums |
fsum |
Function for calculating feature sums |
Value
An object of class type
with a layer named layer
containing the data found in counts
Find the Default FOV
Description
Attempts to find the “default” FOV using the revamped spatial framework
Usage
.DefaultFOV(object, assay = NULL)
Arguments
object |
A |
Value
...
Deprecate Functions and Arguments
Description
Provides automatic deprecation and defunctation of functions and arguments;
Usage
.Deprecate(
when,
what,
with = NULL,
...,
pkg = NULL,
env = missing_arg(),
user_env = missing_arg()
)
Arguments
when |
A string giving the version when the behaviour was deprecated. |
what |
A string describing what is deprecated:
You can optionally supply the namespace: |
with |
An optional string giving a recommended replacement for the
deprecated behaviour. This takes the same form as |
... |
Arguments passed on to
|
pkg |
Name of package to use for comparison |
env , user_env |
Managed internally by |
Value
Run for its side effect and invisibly returns NULL
See Also
lifecycle::deprecate_soft()
lifecycle::deprecate_warn()
lifecycle::deprecate_stop()
Disk Loading Function
Description
Generate a function to load a matrix from an on-disk file
Usage
.DiskLoad(x)
## Default S3 method:
.DiskLoad(x)
## S3 method for class ''10xMatrixH5''
.DiskLoad(x)
## S3 method for class 'AnnDataMatrixH5'
.DiskLoad(x)
## S3 method for class 'DelayedMatrix'
.DiskLoad(x)
## S3 method for class 'H5ADMatrix'
.DiskLoad(x)
## S3 method for class 'HDF5Matrix'
.DiskLoad(x)
## S3 method for class 'IterableMatrix'
.DiskLoad(x)
## S3 method for class 'MatrixDir'
.DiskLoad(x)
## S3 method for class 'MatrixH5'
.DiskLoad(x)
## S3 method for class 'TileDBMatrix'
.DiskLoad(x)
Arguments
x |
A file-backed object |
Value
A one-length character that defines a function to load a matrix from a file
Dollar-sign Autocompletion
Description
Autocompletion for $
access on an
Assay
object
Usage
## S3 method for class 'Assay'
.DollarNames(x, pattern = "")
Arguments
x |
An |
pattern |
A regular expression. Only matching names are returned. |
Value
The layer name matches for pattern
See Also
Dollar-sign Autocompletion
Description
Autocompletion for $
access on an Assay5
object
Usage
## S3 method for class 'Assay5'
.DollarNames(x, pattern = "")
Arguments
x |
An |
pattern |
A regular expression. Only matching names are returned. |
Value
The layer name matches for pattern
See Also
Dollar-sign Autocompletion
Description
Autocompletion for $
access on a Seurat
object
Usage
## S3 method for class 'Seurat'
.DollarNames(x, pattern = "")
Arguments
x |
A |
pattern |
A regular expression. Only matching names are returned. |
Value
The meta data matches for pattern
See Also
Dollar-sign Autocompletion
Description
Autocompletion for $
access on a
SeuratCommand
object
Usage
## S3 method for class 'SeuratCommand'
.DollarNames(x, pattern = "")
Arguments
x |
A |
pattern |
A regular expression. Only matching names are returned. |
Value
The parameter name matches for pattern
See Also
Command log object and interaction methods
$.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Dollar-sign Autocompletion
Description
Autocompletion for $
access on an Assay5
object
Usage
## S3 method for class 'StdAssay'
.DollarNames(x, pattern = "")
Arguments
x |
An |
pattern |
A regular expression. Only matching names are returned. |
Value
The layer name matches for pattern
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Move Files and Directories
Description
Move files and directories with fs; includes a handler for when
path
is a directory on a different filesystem than new_path
by explicitly copying and deleting path
Usage
.FileMove(path, new_path, overwrite = FALSE, n = 1L)
Arguments
path |
A character vector of one or more paths. |
new_path |
New file path. If Should either be the same length as |
n |
The number of callers to go back. |
Value
The new path (invisibly).
Note
This function requires the fs package to be installed
See Also
Find a File Path
Description
Find a File Path
Usage
.FilePath(x)
## Default S3 method:
.FilePath(x)
## S3 method for class 'DelayedMatrix'
.FilePath(x)
## S3 method for class 'IterableMatrix'
.FilePath(x)
Arguments
x |
A file-backed object |
Value
The path to the file that backs x
; if x
is not a
file-backed object, returns NULL
Find Subobjects Of A Certain Class
Description
Find Subobjects Of A Certain Class
Usage
.FilterObjects(object, classes.keep = c("Assay", "StdAssay", "DimReduc"))
Arguments
object |
An S4 object |
classes.keep |
A vector of classes to keep |
Value
A vector of object names that are of class classes.keep
See Also
.Collections()
,
.FindObject()
,
.Subobjects()
Examples
.FilterObjects(pbmc_small)
.FilterObjects(pbmc_small, "Graph")
Find A Subobject
Description
Determine the slot that a subobject is contained in
Usage
.FindObject(object, name, exclude = c("misc", "tools"))
Arguments
object |
An S4 object |
name |
Name of subobject to find |
exclude |
A character vector of slot names to exclude |
Value
The name of the slot that contains name
; returns NULL
if a subobject named name
cannot be found
See Also
.Collections()
,
.FilterObjects()
,
.Subobjects()
Examples
.FindObject(pbmc_small, "tsne")
Returns the most frequently observed features in 'features_by_layer'. If two features are observed at the same frequency their median index will be used to break the tie. If 'nfeatures' is not specified, all features in 'common_features' are returned.
Description
Returns the most frequently observed features in 'features_by_layer'. If two features are observed at the same frequency their median index will be used to break the tie. If 'nfeatures' is not specified, all features in 'common_features' are returned.
Usage
.GetConsensusFeatures(features_by_layer, common_features, nfeatures = NULL)
Arguments
features_by_layer |
A 2D named vector containing mapping each layer to it's corresponding variable features. |
common_features |
The intersection of features across all layers. |
nfeatures |
The number of variable features to return. |
Get a Method
Description
Get a Method
Usage
.GetMethod(fxn, cls)
Arguments
fxn |
Name of a function as a character |
cls |
The class to find a method of |
Value
The method of fxn
for class cls
; if no method found,
returns the default method. If no default method found; returns NULL
Examples
.GetMethod('t', 'Matrix')
.GetMethod('t', 'data.frame')
Returns the top variable features from a data frame of highly variable feature annotations. Features are marked as variable if their value in 'label_column' is neither 'NA' nor 'FALSE'. When a ranking is provided via 'rank_column', features are ordered accordingly.
Description
Returns the top variable features from a data frame of highly variable feature annotations. Features are marked as variable if their value in 'label_column' is neither 'NA' nor 'FALSE'. When a ranking is provided via 'rank_column', features are ordered accordingly.
Usage
.GetVariableFeatures(hvf_info, label_column, rank_column, nfeatures)
Arguments
hvf_info |
A 'data.frame' containing highly variable feature annotations. |
label_column |
A column in 'hvf_info' indicating which features are variable. A feature is considered variable if it's corresponding value is not 'NA' or 'FALSE'. |
rank_column |
A column in 'hvf_info' indicating the rank of each feature. |
nfeatures |
The number of variable features to return. |
Test Future Compatibility with Seurat
Description
Check to see if SeuratObject and/or Seurat are at least a specific version or if they're configured to act as if they're a specific version (see details below). This allows testing compatibility with future requirements for both SeuratObject and Seurat
Usage
.IsFutureSeurat(version, lib.loc = NULL)
Arguments
version |
A version string or object of class
|
lib.loc |
a character vector of directory names of R libraries,
or |
Details
Blah blah blah
Value
TRUE
if SeuratObject and/or Seurat
Regex Pattern for Keys
Description
Regex Pattern for Keys
Usage
.KeyPattern()
Value
Returns the regex pattern for keys (“^[a-zA-Z][a-zA-Z0-9]*_$”)
See Also
.RandomKey()
,
Key-validity
,
KeyMixin-class
Get the Margin of an Object
Description
Get the Margin of an Object
Usage
.MARGIN(x, ...)
Arguments
x |
An object |
Value
The margin, eg. 1
for rows or 2
for columns
Propagate a List
Description
Propagate a List
Usage
.PropagateList(x, names, default = NA)
Arguments
x |
A list or character vector |
names |
A vector of names to keep from |
default |
A default value for unassigned values of |
Value
A named list where the names are present in both x
and
names
and the values are either the values from x
or
default
Examples
.PropagateList("counts", c("RNA", "ADT", "SCT"))
.PropagateList(c("counts", "data"), c("RNA", "ADT", "SCT"))
.PropagateList("ADT", c("RNA", "ADT", "SCT"))
.PropagateList(c("RNA", "SCT"), c("RNA", "ADT", "SCT"))
.PropagateList(c("RNA", ADT = "counts"), c("RNA", "ADT", "SCT"))
.PropagateList(list(SCT = c("counts", "data"), ADT = "counts"), c("RNA", "ADT", "SCT"))
.PropagateList(list(SCT = c("counts", "data"), "ADT"), c("RNA", "ADT", "SCT"))
Generate a Random Key
Description
Generate a Random Key
Usage
.RandomKey(length = 7L, ...)
Arguments
length |
How long should the name be |
... |
Extra parameters passed to |
Value
Returns a valid key
See Also
.KeyPattern()
,
Key-validity
,
KeyMixin-class
Examples
set.seed(42L)
.RandomKey()
Identify Sparse Slots
Description
Identify Sparse Slots
Usage
.SparseSlots(x, type = c("pointers", "indices", "entries"))
## S3 method for class 'CsparseMatrix'
.SparseSlots(x, type = c("pointers", "entries", "indices"))
## S3 method for class 'RsparseMatrix'
.SparseSlots(x, type = c("pointers", "indices", "entries"))
## S3 method for class 'spam'
.SparseSlots(x, type = c("pointers", "indices", "entries"))
Arguments
x |
A sparse matrix |
type |
... |
Value
...
See Also
IsSparse()
,
RegisterSparseMatrix()
Get the Subobject Names
Description
Get the Subobject Names
Usage
.Subobjects(object, exclude = c("misc", "tools"), collapse = TRUE, ...)
Arguments
object |
An S4 object |
exclude |
A character vector of slot names to exclude |
collapse |
Collapse the list into a vector |
... |
Arguments passed to |
Value
If collapse = TRUE
, then a vector with the names of all
subobjects; otherwise, a named list where the names are the names of the
collections and the values are the names of subobjects within the collection
See Also
.Collections()
,
.FilterObjects()
,
.FindObject()
Examples
.Subobjects(pbmc_small)
Add in metadata associated with either cells or features.
Description
Adds additional data to the object. Can be any piece of information
associated with a cell (examples include read depth, alignment rate,
experimental batch, or subpopulation identity) or feature (ENSG name,
variance). To add cell level information, add to the Seurat object. If adding
feature-level metadata, add to the Assay object (e.g. object[["RNA"]]
)
Usage
AddMetaData(object, metadata, col.name = NULL)
## S3 method for class 'Assay'
AddMetaData(object, metadata, col.name = NULL)
## S3 method for class 'Assay5'
AddMetaData(object, metadata, col.name = NULL)
## S3 method for class 'Seurat'
AddMetaData(object, metadata, col.name = NULL)
Arguments
object |
An object |
metadata |
A vector, list, or data.frame with metadata to add |
col.name |
A name for meta data if not a named list or data.frame |
Value
object
with metadata added
Examples
cluster_letters <- LETTERS[Idents(object = pbmc_small)]
names(cluster_letters) <- colnames(x = pbmc_small)
pbmc_small <- AddMetaData(
object = pbmc_small,
metadata = cluster_letters,
col.name = 'letter.idents'
)
head(x = pbmc_small[[]])
Add in metadata associated with either cells or features.
Description
Adds additional data to the object. Can be any piece of information
associated with a cell (examples include read depth, alignment rate,
experimental batch, or subpopulation identity) or feature (ENSG name,
variance). To add cell level information, add to the Seurat object. If adding
feature-level metadata, add to the Assay object (e.g. object[["RNA"]]
)
Usage
## S3 method for class 'StdAssay'
AddMetaData(object, metadata, col.name = NULL)
Arguments
object |
An object |
metadata |
A vector, list, or data.frame with metadata to add |
col.name |
A name for meta data if not a named list or data.frame |
Value
object
with metadata added
Radian/Degree Conversions
Description
Convert degrees to radians and vice versa
Usage
Degrees(rad)
Radians(deg)
Arguments
rad |
Angle in radians |
deg |
Angle in degrees |
Value
Degrees
: rad
in degrees
Radians
: deg
in radians
See Also
PolyVtx()
Examples
Degrees(pi)
Radians(180)
The Assay Class
Description
The Assay object is the basic unit of Seurat; each Assay stores raw, normalized, and scaled data as well as cluster information, variable features, and any other assay-specific metadata. Assays should contain single cell expression data such as RNA-seq, protein, or imputed expression data.
Slots
counts
Unnormalized data such as raw counts or TPMs
data
Normalized expression data
scale.data
Scaled expression data
assay.orig
Original assay that this assay is based off of. Used to track assay provenance
var.features
Vector of features exhibiting high variance across single cells
meta.features
Feature-level metadata
misc
A named list of unstructured miscellaneous data
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
V3 Assay Validity
Description
Validation of Assay
objects is handled by
validObject
data
Validation
blah
counts
Validation
blah
scale.data
Validation
blah
Feature-Level Meta Data Validation
blah
Variable Feature Validation
blah
Key Validation
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “
''
”) wherenchar() == 0
An string composed of one or more alphanumeric values (both lower- and upper-case) that ends with an underscore (“
_
”); the first character must be a letter
Keys that are not empty strings are validated with the regex
“^[a-zA-Z][a-zA-Z0-9]*_$
”
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
rna <- pbmc_small[["RNA"]]
validObject(rna)
The v5 Assay
Object
Description
The v5 Assay
is the typical Assay
class used in Seurat
v5; ...
Slots
layers
A named list containing expression matrices; each matrix should be a two-dimensional object containing some subset of cells and features defined in the
cells
andfeatures
slots. Cell and feature membership is recorded in thecells
andfeatures
slots, respectivelycells
A logical mapping of cell names and layer membership; this map contains all the possible cells that this assay can contain. New layers must have some subset of cells present in this map
features
A logical mapping of feature names and layer membership; this map contains all the possible features that this assay can contain. New layers must have some subset of features present in this map
default
A one-length integer with the end index of the default layer; the default layer be all layers up to and including the layer at index
default
assay.orig
Original assay that this assay is based off of; used to track assay provenance
meta.data
A data frame with feature-level meta data; should have the same number of rows as
features
misc
A named list of unstructured miscellaneous data
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
V5 Assay Validity
Description
Validation of Assay5
objects is handled by
validObject
Layer Validation
blah
Key Validation
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “
''
”) wherenchar() == 0
An string composed of one or more alphanumeric values (both lower- and upper-case) that ends with an underscore (“
_
”); the first character must be a letter
Keys that are not empty strings are validated with the regex
“^[a-zA-Z][a-zA-Z0-9]*_$
”
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
The Transposed v5 Assay
Object
Description
The Transposed v5 Assay
Object
Slots
layers
A named list containing expression matrices; each matrix should be a two-dimensional object containing some subset of cells and features defined in the
cells
andfeatures
slots. Cell and feature membership is recorded in thecells
andfeatures
slots, respectivelycells
A logical mapping of cell names and layer membership; this map contains all the possible cells that this assay can contain. New layers must have some subset of cells present in this map
features
A logical mapping of feature names and layer membership; this map contains all the possible features that this assay can contain. New layers must have some subset of features present in this map
default
A one-length integer with the end index of the default layer; the default layer be all layers up to and including the layer at index
default
assay.orig
Original assay that this assay is based off of; used to track assay provenance
meta.data
A data frame with feature-level meta data; should have the same number of rows as
features
misc
A named list of unstructured miscellaneous data
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
Lifecycle
Warning: functionality described here is experimental and prone to change without notice
Get and Set Assay Data
Description
General accessor and setter functions for Assay
objects.
GetAssayData
can be used to pull information from any of the
expression matrices (eg. “counts”, “data”, or
“scale.data”). SetAssayData
can be used to replace one of these
expression matrices
Usage
GetAssayData(object, ...)
SetAssayData(object, layer, new.data, slot = deprecated(), ...)
## S3 method for class 'Seurat'
GetAssayData(object, assay = NULL, layer = NULL, slot = deprecated(), ...)
## S3 method for class 'Seurat'
SetAssayData(
object,
layer = "data",
new.data,
slot = deprecated(),
assay = NULL,
...
)
## S3 method for class 'Assay'
GetAssayData(
object,
layer = c("data", "scale.data", "counts"),
slot = deprecated(),
...
)
## S3 method for class 'Assay'
SetAssayData(
object,
layer = c("data", "scale.data", "counts"),
new.data,
slot = deprecated(),
...
)
Arguments
object |
An object |
... |
Arguments passed to other methods |
layer |
Name of layer to get or set |
new.data |
New assay data to add |
slot |
|
assay |
Specific assay to get data from or set data for; defaults to the default assay |
Value
GetAssayData
: returns the specified assay data
SetAssayData
: object
with the assay data set
Lifecycle
GetAssayData
and SetAssayData
have been superseded. To fetch
expression matrices, use LayerData
; to set expression data,
use LayerData<-
Examples
# Get assay data from the default assay in a Seurat object
GetAssayData(object = pbmc_small, layer = "data")[1:5,1:5]
# Set an Assay layer through the Seurat object
count.data <- GetAssayData(object = pbmc_small[["RNA"]], layer = "counts")
count.data <- as.matrix(x = count.data + 1)
new.seurat.object <- SetAssayData(
object = pbmc_small,
layer = "counts",
new.data = count.data,
assay = "RNA"
)
# Get the data directly from an Assay object
GetAssayData(pbmc_small[["RNA"]], layer = "data")[1:5,1:5]
# Set an Assay layer directly
count.data <- GetAssayData(pbmc_small[["RNA"]], layer = "counts")
count.data <- as.matrix(x = count.data + 1)
new.assay <- SetAssayData(pbmc_small[["RNA"]], layer = "counts", new.data = count.data)
Get and Set Assay Data
Description
General accessor and setter functions for Assay
objects.
GetAssayData
can be used to pull information from any of the
expression matrices (eg. “counts”, “data”, or
“scale.data”). SetAssayData
can be used to replace one of these
expression matrices
Usage
## S3 method for class 'StdAssay'
GetAssayData(object, layer = NULL, slot = deprecated(), ...)
## S3 method for class 'StdAssay'
SetAssayData(object, layer, new.data, slot = deprecated(), ...)
Arguments
object |
An object |
layer |
Name of layer to get or set |
slot |
|
... |
Arguments passed to other methods |
new.data |
New assay data to add |
Value
GetAssayData
: returns the specified assay data
SetAssayData
: object
with the assay data set
Lifecycle
GetAssayData
and SetAssayData
have been superseded. To fetch
expression matrices, use LayerData
; to set expression data,
use LayerData<-
Query Specific Object Types
Description
List the names of Assay
, DimReduc
,
Graph
, Neighbor
objects
Usage
Assays(object, ...)
Graphs(object, slot = NULL)
Neighbors(object, slot = NULL)
Reductions(object, slot = NULL)
## S3 method for class 'Seurat'
Assays(object, slot = deprecated(), ...)
Arguments
object |
A |
... |
Ignored |
slot |
Name of component object to return |
Value
If slot
is NULL
, the names of all component objects
in this Seurat
object. Otherwise, the specific object specified
Examples
Assays(pbmc_small)
Graphs(pbmc_small)
Reductions(object = pbmc_small)
Attach Required Packages
Description
Helper function to attach required packages. Detects if a package is already
attached and if so, skips it. Should be called in .onAttach
Usage
AttachDeps(deps)
Arguments
deps |
A character vector of packages to attach |
Value
Invisibly returns NULL
Lifecycle
AttachDeps
has been superseded as of SeuratObject v5.0.0;
as an alternative, list dependencies in the Depends
section of
DESCRIPTION
Examples
# Use in your .onAttach hook
if (FALSE) {
.onAttach <- function(libname, pkgname) {
AttachDeps(c("SeuratObject", "rlang"))
}
}
Get, Set, and Query Segmentation Boundaries
Description
Get, Set, and Query Segmentation Boundaries
Usage
Boundaries(object, ...)
DefaultBoundary(object)
DefaultBoundary(object, ...) <- value
Molecules(object, ...)
## S3 method for class 'FOV'
Boundaries(object, ...)
## S3 method for class 'FOV'
DefaultBoundary(object)
## S3 replacement method for class 'FOV'
DefaultBoundary(object, ...) <- value
## S3 method for class 'FOV'
Molecules(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
The name of a segmentation boundary to set as default |
Value
Boundaries
: The names of all segmentation boundaries present
within object
DefaultBoundary
: The name of the default
segmentation boundary
DefaultBoundary<-
: object
with the default
segmentation boundary set to value
Molecules
: The names of all molecule sets present within
object
Cast Assay Layers
Description
Cast layers in v5 assays to other classes
Usage
CastAssay(object, to, ...)
## S3 method for class 'Assay5'
CastAssay(object, to, layers = NA, verbose = TRUE, ...)
Arguments
object |
An object |
to |
Either a class name or a function that takes a layer and returns the same layer as a new class |
... |
If |
layers |
A vector of layers to cast; defaults to all layers |
verbose |
Show progress updates |
Value
object
with the layers cast to class specified by to
Cast Assay Layers
Description
Cast layers in v5 assays to other classes
Usage
## S3 method for class 'StdAssay'
CastAssay(object, to, layers = NA, verbose = TRUE, ...)
Arguments
object |
An object |
to |
Either a class name or a function that takes a layer and returns the same layer as a new class |
layers |
A vector of layers to cast; defaults to all layers |
verbose |
Show progress updates |
... |
If |
Value
object
with the layers cast to class specified by to
Cell and Feature Names
Description
Get the cell and feature names of an object
Usage
Cells(x, ...)
Features(x, ...)
## Default S3 method:
Cells(x, ...)
## S3 method for class 'Assay5'
Cells(x, layer = NULL, simplify = TRUE, ...)
## S3 method for class 'Assay5'
Features(x, layer = NULL, simplify = TRUE, ...)
## S3 method for class 'DimReduc'
Cells(x, ...)
## S3 method for class 'Neighbor'
Cells(x, ...)
Arguments
x |
An object |
... |
Arguments passed to other methods |
layer |
Layer to pull cells/features for; defaults to default layer;
if |
simplify |
Simplify the cell/feature names into a single vector; if
|
Value
Cell
: A vector of cell names
Features
: A vector of feature names
See Also
dimnames.Assay()
,
dimnames.Assay5()
,
dimnames.Seurat()
Examples
Cells(x = pbmc_small)
Cell and Feature Names
Description
Get the cell and feature names of an object
Usage
## S3 method for class 'StdAssay'
Cells(x, layer = NULL, simplify = TRUE, ...)
## S3 method for class 'StdAssay'
Features(x, layer = NULL, simplify = TRUE, ...)
Arguments
x |
An object |
layer |
Layer to pull cells/features for; defaults to default layer;
if |
simplify |
Simplify the cell/feature names into a single vector; if
|
... |
Arguments passed to other methods |
Value
Cell
: A vector of cell names
Features
: A vector of feature names
Get cell names grouped by identity class
Description
Get cell names grouped by identity class
Usage
CellsByIdentities(object, idents = NULL, cells = NULL, return.null = FALSE)
Arguments
object |
A Seurat object |
idents |
A vector of identity class levels to limit resulting list to; defaults to all identity class levels |
cells |
A vector of cells to grouping to |
return.null |
If no cells are requested, return a |
Value
A named list where names are identity classes and values are vectors of cells belonging to that class
Examples
CellsByIdentities(object = pbmc_small)
Get a vector of cell names associated with an image (or set of images)
Description
Get a vector of cell names associated with an image (or set of images)
Usage
CellsByImage(object, images = NULL, unlist = FALSE)
Arguments
object |
Seurat object |
images |
Vector of image names |
unlist |
Return as a single vector of cell names as opposed to a list, named by image name. |
Value
A vector of cell names
Examples
## Not run:
CellsByImage(object = object, images = "slice1")
## End(Not run)
The Centroids
Class
Description
The Centroids
Class
Slots
cells
(
character [n]
) A vector of cell names; there should be as many cell names as there are points and no duplicate namesnsides
(
integer [1L]
) The number of sides to draw when plotting centroids; must be either0L
for circles or greater than 3radius
(
numeric [1L]
) The radius of the shape when plotting the centroidstheta
(
numeric [1L]
) The angle in degrees to adjust the shape when plotting the centroids
See Also
Centroids
methods: Centroids-methods
Segmentation layer classes:
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Centroids
Methods
Description
Methods for Centroids
objects
Usage
## S3 method for class 'Centroids'
Cells(x, ...)
## S3 method for class 'Centroids'
GetTissueCoordinates(object, full = TRUE, ...)
## S3 method for class 'Centroids'
Radius(object, ...)
## S3 method for class 'Centroids'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'Centroids'
Theta(object)
## S3 method for class 'Centroids'
is.finite(x)
## S3 method for class 'Centroids'
is.infinite(...)
## S3 method for class 'Centroids'
length(x)
## S3 method for class 'Centroids'
lengths(x, use.names = TRUE)
## S3 method for class 'Centroids'
subset(x, cells = NULL, ...)
## S4 method for signature 'Centroids,character,ANY,ANY'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'Centroids,numeric,ANY,ANY'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'Centroids'
show(object)
Arguments
x , object |
A |
... |
Arguments passed to other methods |
full |
Expand the coordinates to the full polygon |
new.names |
vector of new cell names |
use.names |
Ignored |
i , cells |
A vector of cells to keep; if |
j , drop |
Ignored |
Details
GetTissueCoordinates
: Get cell spatial coordinates
Radius
: Get the centroid radius
RenameCells
: Update cell names
Theta
: Get the offset angle
is.finite
, is.infinite
: Test to see if the centroids
are circular or polygonal
length
: Get the number of sides for the polygonal centroid
lengths
: Generate a run-length encoding of the cells present
subset
, [
: Subset a Centroids
object to
certain cells
show
: Display an object summary to stdout
Value
GetTissueCoordinates
: A data frame with three columns:
-
“
x
”: the x-coordinate -
“
y
”: the y-coordinate -
“
cell
”: the cell name
If full
is TRUE
, then each coordinate will indicate a vertex
for the cell polygon; otherwise, each coordinate will indicate a centroid
for the cell
Radius
The radius of the centroids
RenameCells
: object
with the cells renamed to
new.names
Theta
: The offset angle in degrees
is.finite
: TRUE
if the centroids are polygonal,
FALSE
if circular
is.infinite
: The opposite of is.finite
length
: 0
if the centroids are circular, otherwise the
number of sides of the polygonal centroid
lengths
: An rle
object for the cells
subset
, [
: x
subsetted to the cells specified
by cells
/i
show
: Invisibly returns NULL
See Also
Segmentation layer classes:
Centroids-class
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Check the Use of Dots
Description
Function to check the use of unused arguments passed to ...
; this
function is designed to be called from another function to see if an
argument passed to ...
remains unused and alert the user if so. Also
accepts a vector of function or function names to see if ...
can be
used in a downstream function
Usage
CheckDots(..., fxns = NULL)
Arguments
... |
Arguments passed to a function that fall under |
fxns |
A list/vector of functions or function names |
Details
Behavior of CheckDots
can be controlled by the following option(s):
- “
Seurat.checkdots
” Control how to alert the presence of unused arguments in
...
; choose from-
“
warn
”: emit a warning (default) -
“
error
”: throw an error -
“
silent
”: no not alert the presence of unused arguments in...
-
Value
Emits either an error or warning if an argument passed is unused;
invisibly returns NULL
Examples
## Not run:
f <- function(x, ...) {
CheckDots(...)
return(x ^ 2)
}
f(x = 3, y = 9)
## End(Not run)
Check features names format
Description
Check features names format
Usage
CheckFeaturesNames(data)
Arguments
data |
a matrix input, rownames(data) are feature names |
Value
data
with update feature names
Conditional Garbage Collection
Description
Call gc
only when desired
Usage
CheckGC(option = "SeuratObject.memsafe")
Arguments
option |
... |
Value
Invisibly returns NULL
Check layers names for the input list
Description
Check layers names for the input list
Usage
CheckLayersName(matrix.list, layers.type = c("counts", "data"))
Arguments
matrix.list |
A list of matrices |
layers.type |
layers type, such as counts or data |
Check Matrix Validity
Description
Check Matrix Validity
Usage
CheckMatrix(object, checks, ...)
## Default S3 method:
CheckMatrix(object, checks, ...)
## S3 method for class 'dMatrix'
CheckMatrix(object, checks = c("infinite", "logical", "integer", "na"), ...)
## S3 method for class 'lMatrix'
CheckMatrix(object, checks = c("infinite", "logical", "integer", "na"), ...)
Arguments
object |
A matrix |
checks |
Type of checks to perform, choose one or more from:
|
... |
Arguments passed to other methods |
Value
Emits warnings for each test and invisibly returns NULL
Generate a Class Key
Description
Generate class keys for S4 classes. A class key follows the following
structure: “package:class
”
Usage
ClassKey(class, package = NULL)
Arguments
class |
Class name |
package |
Optional name of package; by default, will search namespaces of loaded packages to determine the providing package |
Value
The class key (“package:class
”)
See Also
Examples
ClassKey("Seurat")
Get SeuratCommands
Description
Pull information on previously run commands in the Seurat object.
Usage
Command(object, ...)
## S3 method for class 'Seurat'
Command(object, command = NULL, value = NULL, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
command |
Name of the command to pull, pass |
value |
Name of the parameter to pull the value for |
Value
Either a SeuratCommand object or the requested parameter value
Create a v5 Assay object
Description
Create an Assay5
object from a feature expression matrix;
the expected format of the matrix is features x cells
Usage
CreateAssay5Object(
counts = NULL,
data = NULL,
min.cells = 0,
min.features = 0,
csum = NULL,
fsum = NULL,
...
)
Arguments
counts |
A two-dimensional expression matrix |
data |
Optional prenormalized data matrix |
min.cells |
Include features detected in at least this many cells; will subset the counts matrix as well. To reintroduce excluded features, create a new object with a lower cutoff |
min.features |
Include cells where at least this many features are detected |
csum |
Function for calculating cell sums |
fsum |
Function for calculating feature sums |
... |
Arguments passed to other methods |
Value
An Assay5
object
Create an Assay object
Description
Create an Assay object from a feature (e.g. gene) expression matrix. The expected format of the input matrix is features x cells.
Usage
CreateAssayObject(
counts,
data,
min.cells = 0,
min.features = 0,
key = NULL,
check.matrix = FALSE,
...
)
Arguments
counts |
Unnormalized data such as raw counts or TPMs |
data |
Prenormalized data; if provided, do not pass |
min.cells |
Include features detected in at least this many cells. Will subset the counts matrix as well. To reintroduce excluded features, create a new object with a lower cutoff |
min.features |
Include cells where at least this many features are detected |
key |
Optional key to initialize assay with |
check.matrix |
Check counts matrix for NA, NaN, Inf, and non-integer values |
... |
Arguments passed to |
Details
Non-unique cell or feature names are not allowed. Please make unique before calling this function.
Value
A Assay
object
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
## Not run:
pbmc_raw <- read.table(
file = system.file('extdata', 'pbmc_raw.txt', package = 'Seurat'),
as.is = TRUE
)
pbmc_rna <- CreateAssayObject(counts = pbmc_raw)
pbmc_rna
## End(Not run)
Create a Centroids
Objects
Description
Create a Centroids
Objects
Usage
CreateCentroids(coords, nsides, radius, theta)
Arguments
coords |
The coordinates of cell/spot centroids |
nsides |
The number of sides to represent cells/spots; pass
|
radius |
Radius of shapes when plotting |
theta |
Angle to adjust shapes when plotting |
Value
A Centroids
object
Create a DimReduc object
Description
Create a DimReduc object
Usage
CreateDimReducObject(
embeddings = new(Class = "matrix"),
loadings = new(Class = "matrix"),
projected = new(Class = "matrix"),
assay = NULL,
stdev = numeric(),
key = NULL,
global = FALSE,
jackstraw = NULL,
misc = list()
)
Arguments
embeddings |
A matrix with the cell embeddings |
loadings |
A matrix with the feature loadings |
projected |
A matrix with the projected feature loadings |
assay |
Assay used to calculate this dimensional reduction |
stdev |
Standard deviation (if applicable) for the dimensional reduction |
key |
A character string to facilitate looking up features from a specific DimReduc |
global |
Specify this as a global reduction (useful for visualizations) |
jackstraw |
Results from the JackStraw function |
misc |
list for the user to store any additional information associated with the dimensional reduction |
Value
A DimReduc
object
See Also
Dimensional reduction object, validity, and interaction methods
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Examples
data <- GetAssayData(pbmc_small[["RNA"]], slot = "scale.data")
pcs <- prcomp(x = data)
pca.dr <- CreateDimReducObject(
embeddings = pcs$rotation,
loadings = pcs$x,
stdev = pcs$sdev,
key = "PC",
assay = "RNA"
)
Create Spatial Coordinates
Description
Create Spatial Coordinates
Usage
CreateFOV(coords, ...)
## S3 method for class 'Centroids'
CreateFOV(
coords,
molecules = NULL,
assay = "Spatial",
key = NULL,
name = NULL,
...
)
## S3 method for class 'data.frame'
CreateFOV(
coords,
type = c("segmentation", "centroids"),
nsides = Inf,
radius = NULL,
theta = 0L,
molecules = NULL,
assay = "Spatial",
key = NULL,
name = NULL,
...
)
## S3 method for class 'list'
CreateFOV(coords, molecules = NULL, assay = "Spatial", key = NULL, ...)
## S3 method for class 'Segmentation'
CreateFOV(
coords,
molecules = NULL,
assay = "Spatial",
key = NULL,
name = NULL,
...
)
Arguments
coords |
Spatial coordinates |
... |
Arguments passed to other methods |
molecules |
A |
assay |
Name of associated assay |
key |
Key for these spatial coordinates |
name |
When |
type |
When providing a |
nsides |
The number of sides to represent cells/spots; pass
|
radius |
Radius of shapes when plotting |
theta |
Angle to adjust shapes when plotting |
Value
A FOV
object
See Also
Create a Molecules
Object
Description
Create a Molecules
Object
Usage
CreateMolecules(coords, ...)
## S3 method for class 'data.frame'
CreateMolecules(coords, key = "", ...)
## S3 method for class 'Molecules'
CreateMolecules(coords, ...)
## S3 method for class ''NULL''
CreateMolecules(coords, ...)
Arguments
coords |
Spatial coordinates for molecules; should be a data frame with three columns:
|
... |
Arguments passed to other methods |
key |
A key to set for the molecules |
Value
A Molecules
object
Create a Segmentation
Objects
Description
Create a Segmentation
Objects
Usage
CreateSegmentation(coords)
## S3 method for class 'data.frame'
CreateSegmentation(coords)
## S3 method for class 'Segmentation'
CreateSegmentation(coords)
Arguments
coords |
The coordinates of cell segmentations |
Value
A Segmentation
object
Create a Seurat
object
Description
Create a Seurat
object from raw data
Usage
CreateSeuratObject(
counts,
assay = "RNA",
names.field = 1,
names.delim = "_",
meta.data = NULL,
project = "CreateSeuratObject",
...
)
## Default S3 method:
CreateSeuratObject(
counts,
assay = "RNA",
names.field = 1L,
names.delim = "_",
meta.data = NULL,
project = "SeuratProject",
min.cells = 0,
min.features = 0,
...
)
## S3 method for class 'Assay'
CreateSeuratObject(
counts,
assay = "RNA",
names.field = 1L,
names.delim = "_",
meta.data = NULL,
project = "SeuratProject",
...
)
## S3 method for class 'Assay5'
CreateSeuratObject(
counts,
assay = "RNA",
names.field = 1L,
names.delim = "_",
meta.data = NULL,
project = "SeuratProject",
...
)
Arguments
counts |
Either a |
assay |
Name of the initial assay |
names.field |
For the initial identity class for each cell, choose this
field from the cell's name. E.g. If your cells are named as
BARCODE_CLUSTER_CELLTYPE in the input matrix, set |
names.delim |
For the initial identity class for each cell, choose this delimiter from the cell's column name. E.g. If your cells are named as BARCODE-CLUSTER-CELLTYPE, set this to “-” to separate the cell name into its component parts for picking the relevant field. |
meta.data |
Additional cell-level metadata to add to the Seurat object.
Should be a |
project |
Project name for the |
... |
Arguments passed to other methods |
min.cells |
Include features detected in at least this many cells. Will subset the counts matrix as well. To reintroduce excluded features, create a new object with a lower cutoff |
min.features |
Include cells where at least this many features are detected |
Value
A Seurat
object
Note
In previous versions (<3.0), this function also accepted a parameter to set the expression threshold for a ‘detected’ feature (gene). This functionality has been removed to simplify the initialization process/assumptions. If you would still like to impose this threshold for your particular dataset, simply filter the input expression matrix before calling this function.
Examples
## Not run:
pbmc_raw <- read.table(
file = system.file('extdata', 'pbmc_raw.txt', package = 'Seurat'),
as.is = TRUE
)
pbmc_small <- CreateSeuratObject(counts = pbmc_raw)
pbmc_small
## End(Not run)
Crop Coordinates
Description
Crop Coordinates
Usage
Crop(object, x = NULL, y = NULL, coords = c("plot", "tissue"), ...)
## S3 method for class 'FOV'
Crop(object, x = NULL, y = NULL, coords = c("plot", "tissue"), ...)
Arguments
object |
An object |
x , y |
Range to crop x/y limits to; if |
coords |
Coordinate system to execute crop; choose from:
|
... |
Arguments passed to other methods |
Value
object
cropped to the region specified by x
and y
Default Assay
Description
Get and set the default assay
Usage
DefaultAssay(object, ...)
DefaultAssay(object, ...) <- value
## S3 method for class 'Graph'
DefaultAssay(object, ...)
## S3 replacement method for class 'Graph'
DefaultAssay(object, ...) <- value
## S3 method for class 'Assay'
DefaultAssay(object, ...)
## S3 replacement method for class 'Assay'
DefaultAssay(object, ...) <- value
## S3 method for class 'Assay5'
DefaultAssay(object, ...)
## S3 replacement method for class 'Assay5'
DefaultAssay(object, ...) <- value
## S3 method for class 'SeuratCommand'
DefaultAssay(object, ...)
## S3 method for class 'DimReduc'
DefaultAssay(object, ...)
## S3 replacement method for class 'DimReduc'
DefaultAssay(object, ...) <- value
## S3 method for class 'Seurat'
DefaultAssay(object, ...)
## S3 replacement method for class 'Seurat'
DefaultAssay(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Name of assay to set as default |
Value
DefaultAssay
: The name of the default assay
DefaultAssay<-
: An object with the default assay updated
Examples
# Get current default assay
DefaultAssay(object = pbmc_small)
# Create dummy new assay to demo switching default assays
new.assay <- pbmc_small[["RNA"]]
Key(object = new.assay) <- "RNA2_"
pbmc_small[["RNA2"]] <- new.assay
# switch default assay to RNA2
DefaultAssay(object = pbmc_small) <- "RNA2"
DefaultAssay(object = pbmc_small)
Default Assay
Description
Get and set the default assay
Usage
## S3 method for class 'StdAssay'
DefaultAssay(object, ...)
## S3 replacement method for class 'StdAssay'
DefaultAssay(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Name of assay to set as default |
Value
DefaultAssay
: The name of the default assay
DefaultAssay<-
: An object with the default assay updated
Find the default DimReduc
Description
Searches for DimReducs
matching “umap”, “tsne”,
or “pca”, case-insensitive, and in that order. Priority given to
DimReducs
matching the DefaultAssay
or assay specified
(eg. “pca” for the default assay weights higher than “umap”
for a non-default assay)
Usage
DefaultDimReduc(object, assay = NULL)
Arguments
object |
A |
assay |
Name of assay to use; defaults to the default assay of the object |
Value
The default DimReduc
, if possible
Examples
DefaultDimReduc(pbmc_small)
Get and Set the Default FOV
Description
Get and Set the Default FOV
Usage
DefaultFOV(object, ...)
DefaultFOV(object, ...) <- value
## S3 method for class 'Seurat'
DefaultFOV(object, assay = NULL, ...)
## S3 replacement method for class 'Seurat'
DefaultFOV(object, assay = NA, ...) <- value
Arguments
object |
A |
... |
Arguments passed to other methods |
value |
The name of the |
assay |
Name of assay to get or set default |
Value
DefaultFOV
: The name of the default FOV
DefaultFOV<-
: object
with the default FOV set
to value
Default Layer
Description
Get and set the default layer
Usage
DefaultLayer(object, ...)
DefaultLayer(object, ...) <- value
## S3 method for class 'Assay'
DefaultLayer(object, ...)
## S3 method for class 'Assay5'
DefaultLayer(object, ...)
## S3 replacement method for class 'Assay5'
DefaultLayer(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Name of layer to set as default |
Value
DefaultLayer
: The name of the default layer
DefaultLayer<-
: An object with the default layer updated
Default Layer
Description
Get and set the default layer
Usage
## S3 method for class 'StdAssay'
DefaultLayer(object, ...)
## S3 replacement method for class 'StdAssay'
DefaultLayer(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Name of layer to set as default |
Value
DefaultLayer
: The name of the default layer
DefaultLayer<-
: An object with the default layer updated
The Dimensional Reduction Class
Description
The DimReduc object stores a dimensionality reduction taken out in Seurat; each DimReduc consists of a cell embeddings matrix, a feature loadings matrix, and a projected feature loadings matrix.
Slots
cell.embeddings
Cell embeddings matrix (required)
feature.loadings
Feature loadings matrix (optional)
feature.loadings.projected
Projected feature loadings matrix (optional)
assay.used
Name of assay used to generate
DimReduc
objectglobal
Is this
DimReduc
global/persistent? If so, it will not be removed when removing its associated assaystdev
A vector of standard deviations
jackstraw
A
JackStrawData-class
object associated with thisDimReduc
misc
A named list of unstructured miscellaneous data
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Dimensional Reduction Validity
Description
Validation of DimReduc
objects is handled by
validObject
Cell Embeddings Validation
The cell embeddings matrix must be a numeric matrix of dimensions
n_{cells}
by d_{dimensions}
; row names must be the cell names
and column names must be the dimension identifier. The dimension identifier
must be “key_dimension
” (eg. “PC_1
”). Dimension
identifiers must be in order and cannot be skipped
Feature and Projected Feature Loadings Validation
blah
Standard Deviations Validation
blah
Key Validation
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “
''
”) wherenchar() == 0
An string composed of one or more alphanumeric values (both lower- and upper-case) that ends with an underscore (“
_
”); the first character must be a letter
Keys that are not empty strings are validated with the regex
“^[a-zA-Z][a-zA-Z0-9]*_$
”
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Get the Neighbor nearest neighbors distance matrix
Description
Get the Neighbor nearest neighbors distance matrix
Usage
Distances(object, ...)
## S3 method for class 'Neighbor'
Distances(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
Value
The distance matrix
Get Cell Embeddings
Description
Get Cell Embeddings
Usage
Embeddings(object, ...)
## S3 method for class 'DimReduc'
Embeddings(object, ...)
## S3 method for class 'Seurat'
Embeddings(object, reduction = "pca", ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
reduction |
Name of reduction to pull cell embeddings for |
Value
The embeddings matrix
Examples
# Get the embeddings directly from a DimReduc object
Embeddings(object = pbmc_small[["pca"]])[1:5, 1:5]
# Get the embeddings from a specific DimReduc in a Seurat object
Embeddings(object = pbmc_small, reduction = "pca")[1:5, 1:5]
Empty Data Frames
Description
Create an empty data frame with no row names and zero columns
Usage
EmptyDF(n)
Arguments
n |
Number of rows for the data frame |
Value
A data frame with n
rows and
zero columns
Examples
EmptyDF(4L)
Empty Matrices
Description
Create empty 0x0 matrices of varying types
Usage
EmptyMatrix(repr = "C", type = "d")
Arguments
repr |
Representation of empty matrix; choose from:
|
type |
Type of resulting matrix to return, choose from:
Note, when |
Value
A 0x0 matrix of the specified representation and type
See Also
Examples
EmptyMatrix()
EmptyMatrix("spam")
Extract delimiter information from a string.
Description
Parses a string (usually a cell name) and extracts fields based on a delimiter
Usage
ExtractField(string, field = 1, delim = "_")
Arguments
string |
String to parse. |
field |
Integer(s) indicating which field(s) to extract. Can be a vector multiple numbers. |
delim |
Delimiter to use, set to underscore by default. |
Value
A new string, that parses out the requested fields, and (if multiple), rejoins them with the same delimiter
Examples
ExtractField('Hello World', field = 1, delim = '_')
The Field of View Object
Description
A modern container for storing coordinates of spatially-resolved single
cells. Capable of storing multiple cell segmentation boundary masks.
Supports coordinates for spatially-resolved molecule (FISH) data.
Compatible with SpatialImage
Slots
molecules
A named list of
Molecules
objects defining spatially-resolved molecular coordinatesboundaries
A named list of
Segmentation
andCentroids
objects defining spatially-resolved boundariesassay
A character naming the associated assay of the spatial coordinates
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
FOV
Methods
Description
Methods for FOV
objects
Usage
## S3 method for class 'FOV'
Cells(x, boundary = NULL, ...)
## S3 method for class 'FOV'
Features(x, set = NULL, ...)
## S3 method for class 'FOV'
FetchData(object, vars, cells = NULL, simplify = TRUE, ...)
## S3 method for class 'FOV'
GetTissueCoordinates(object, which = NULL, ...)
## S3 method for class 'FOV'
Keys(object, ...)
## S3 method for class 'FOV'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'FOV'
x$i, ...
## S3 method for class 'FOV'
x[i, j, ...]
## S3 method for class 'FOV'
x[[i, ...]]
## S3 method for class 'FOV'
length(x)
## S3 method for class 'FOV'
names(x)
## S3 method for class 'FOV'
subset(x, cells = NULL, features = NULL, ...)
## S4 replacement method for signature 'FOV,character,missing,Centroids'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'FOV,character,missing,Molecules'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'FOV,character,missing,NULL'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'FOV,character,missing,Segmentation'
x[[i, j, ...]] <- value
## S4 method for signature 'FOV'
show(object)
Arguments
x , object |
A |
boundary , set |
Name of segmentation boundary or molecule set to
extract cell or feature names for; pass |
... |
Arguments passed to other methods |
vars |
A vector of variables to fetch; can be the name of a segmentation boundary, to get tissue coordinates, or molecule names, to get molecule coordinates |
simplify |
If only returning either boundary or molecule coordinates, return a single data frame instead of a list |
which |
Name of segmentation boundary or molecule set |
new.names |
vector of new cell names |
i , cells |
For |
j , features |
For |
value |
For |
Details
The following methods are defined for interacting with a
FOV
object:
Cells
: Get cell names
Features
: Get spatially-resolved molecule names
FetchData
: Fetch boundary and/or molecule coordinates from
a FOV
object
GetTissueCoordinates
: Get boundary or molecule
coordinates from a FOV
object
Keys
: Get the keys of molecule sets contained within a
FOV
object
RenameCells
: Update cell names
$
, [[
: Extract a segmentation boundary
length
: Get the number of segmentation layers in a
FOV
object
names
: Get the names of segmentation layers and molecule sets
subset
, [
: Subset a FOV
object
[[<-
: Add or remove segmentation layers and molecule
information to/from a FOV
object
show
: Display an object summary to stdout
Value
Cells
: A vector of cell names
Features
: A vector of spatially-resolved molecule names;
if no molecular information present, returns NULL
FetchData
: If both molecule and boundary coordinates are
requested, then a two-length list:
-
“
molecules
”: A data frame with the molecule coordinates requested. If molecules requested are keyed, the keys are preserved in the data frame -
“
coordinates
”: A data frame with coordinates from the segmentation boundaries requested
If simplify
is TRUE
and only one data frame is generated, then
only the data frame is returned. Otherwise, a one-length list is returned
with the single data frame generated
GetTissueCoordinates
: ...
Keys
: A named vector of molecule set keys; names are the
names of the molecule sets and values are the keys for the respective
molecule set
RenameCells
: object
with the cells renamed to
new.names
$
, [[
: The segmentation boundary or spatially-resolved
molecule information stored at i
length
: The number of segmentation layers
(Segmentation
or
Centroids
objects)
names
: A vector of segmentation boundary and molecule set names
subset
: x
with just the cells and features specified
[[<-
: Varies depending on the class of value
:
If
value
isNULL
, returnsx
with the boundaryi
removed; also allows removingmolecules
; does not allow removing the default segmentationIf
value
is aMolecules
, returnsx
withvalue
stored inmolecules
; requires thati
is “molecules”Otherwise, stores
value
as a segmentation boundary namedi
show
: Invisibly returns NULL
See Also
FOV Validity
Description
Validation of FOV
objects is handled by
validObject
Boundary Validation
blah
Molecule Validation
blah
See Also
Access cellular data
Description
Retrieves data (feature expression, PCA scores, metrics, etc.) for a set of cells in a Seurat object
Usage
FetchData(object, ...)
## S3 method for class 'DimReduc'
FetchData(object, vars, cells = NULL, ...)
## S3 method for class 'Seurat'
FetchData(
object,
vars,
cells = NULL,
layer = NULL,
clean = TRUE,
slot = deprecated(),
...
)
Arguments
object |
An object |
... |
Arguments passed to other methods |
vars |
List of all variables to fetch, use keyword “ident” to pull identity classes |
cells |
Cells to collect data for (default is all cells) |
layer |
Layer to pull feature data for |
clean |
Remove cells that are missing data; choose from:
Passing |
slot |
Deprecated in favor of |
Value
A data frame with cells as rows and cellular data as columns
Examples
pc1 <- FetchData(object = pbmc_small, vars = 'PC_1')
head(x = pc1)
head(x = FetchData(object = pbmc_small, vars = c('groups', 'ident')))
Find Sub-objects of a Certain Class
Description
Get the names of objects within a Seurat
object that are of a
certain class
Usage
FilterObjects(object, classes.keep = c("Assay", "StdAssay", "DimReduc"))
Arguments
object |
A |
classes.keep |
A vector of names of classes to get |
Value
A vector with the names of objects within the Seurat
object
that are of class classes.keep
Lifecycle
FilterObjects
was deprecated in version 5.0.0; use .FilterObjects
instead
Examples
FilterObjects(pbmc_small)
Get image data
Description
Get image data
Usage
GetImage(object, mode = c("grob", "raster", "plotly", "raw"), ...)
## S3 method for class 'Seurat'
GetImage(
object,
mode = c("grob", "raster", "plotly", "raw"),
image = NULL,
...
)
Arguments
object |
An object |
mode |
How to return the image; should accept one of “grob”, “raster”, “plotly”, or “raw” |
... |
Arguments passed to other methods |
image |
Name of |
Value
Image data, varying depending on the value of mode
:
- “grob”
-
An object representing image data inheriting from
grob
objects (eg.rastergrob
) - “raster”
An object of class
raster
- “plotly”
-
A list with image data suitable for Plotly rendering, see
plotly::layout
for more details - “raw”
The raw image data as stored in the object
See Also
Get tissue coordinates
Description
Get tissue coordinates
Usage
GetTissueCoordinates(object, ...)
## S3 method for class 'Seurat'
GetTissueCoordinates(object, image = NULL, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
image |
Name of |
Value
A data frame with tissue coordinates
The Graph Class
Description
The Graph class inherits from dgCMatrix
.
We do this to enable future expandability of graphs.
Slots
assay.used
Optional name of assay used to generate
Graph
object
See Also
Other graph:
as.Graph()
Highly Variable Features
Description
Get and set variable feature information for an Assay
object.
HVFInfo
and VariableFeatures
utilize generally variable
features, while SVFInfo
and SpatiallyVariableFeatures
are
restricted to spatially variable features
Usage
HVFInfo(object, method, status = FALSE, ...)
VariableFeatures(object, method = NULL, ...)
VariableFeatures(object, ...) <- value
SVFInfo(object, method, status, ...)
SpatiallyVariableFeatures(object, method, ...)
## S3 method for class 'Seurat'
HVFInfo(
object,
method = NULL,
status = FALSE,
assay = NULL,
selection.method = deprecated(),
...
)
## S3 method for class 'Seurat'
VariableFeatures(
object,
method = NULL,
assay = NULL,
nfeatures = NULL,
layer = NA,
simplify = TRUE,
selection.method = deprecated(),
...
)
## S3 replacement method for class 'Seurat'
VariableFeatures(object, assay = NULL, ...) <- value
## S3 method for class 'Seurat'
SVFInfo(
object,
method = c("markvariogram", "moransi"),
status = FALSE,
assay = NULL,
selection.method = deprecated(),
...
)
## S3 method for class 'Seurat'
SpatiallyVariableFeatures(
object,
method = "moransi",
assay = NULL,
decreasing = TRUE,
selection.method = deprecated(),
...
)
## S3 method for class 'Assay'
HVFInfo(object, method, status = FALSE, selection.method = deprecated(), ...)
## S3 method for class 'Assay'
SpatiallyVariableFeatures(
object,
method = "moransi",
decreasing = TRUE,
selection.method = deprecated(),
...
)
## S3 method for class 'Assay'
SVFInfo(
object,
method = c("markvariogram", "moransi"),
status = FALSE,
selection.method = deprecated(),
...
)
## S3 method for class 'Assay'
VariableFeatures(object, method = NULL, selection.method = deprecated(), ...)
## S3 replacement method for class 'Assay'
VariableFeatures(object, ...) <- value
## S3 method for class 'Assay5'
HVFInfo(object, method = NULL, status = FALSE, layer = NA, strip = TRUE, ...)
## S3 method for class 'Assay5'
VariableFeatures(
object,
method = NULL,
layer = NA,
simplify = TRUE,
nfeatures = NULL,
selection.method = deprecated(),
...
)
## S3 method for class 'StdAssay'
SVFInfo(
object,
method = c("markvariogram", "moransi"),
status = FALSE,
selection.method = deprecated(),
...
)
## S3 method for class 'Assay5'
SVFInfo(
object,
method = c("markvariogram", "moransi"),
status = FALSE,
selection.method = deprecated(),
...
)
## S3 method for class 'Assay5'
SpatiallyVariableFeatures(
object,
method = "moransi",
decreasing = TRUE,
selection.method = deprecated(),
...
)
Arguments
object |
An object |
method |
Which method to pull. For
For
|
status |
Add variable status to the resulting data frame |
... |
Arguments passed to other methods |
value |
A character vector of variable features |
assay |
Name of assay to pull highly variable feature information for |
selection.method |
|
nfeatures |
Maximum number of features to select when simplifying |
layer |
Layer to pull variable features for |
simplify |
When pulling for multiple layers, combine into a single vector and select a common set of variable features for all layers |
decreasing |
Return features in decreasing order (most spatially variable first). |
strip |
Remove method/layer identifiers from highly variable data frame |
Value
HVFInfo
: A data frame with feature means, dispersion, and
scaled dispersion
VariableFeatures
: a vector of the variable features
SVFInfo
: a data frame with the spatially variable features
SpatiallyVariableFeatures
: a character vector of the spatially
variable features
Examples
# Get the HVF info from a specific Assay in a Seurat object
HVFInfo(object = pbmc_small, assay = "RNA")[1:5, ]
# Get the HVF info directly from an Assay object
HVFInfo(pbmc_small[["RNA"]], method = 'vst')[1:5, ]
Get, set, and manipulate an object's identity classes
Description
Get, set, and manipulate an object's identity classes
Usage
Idents(object, ...)
Idents(object, ...) <- value
RenameIdents(object, ...)
ReorderIdent(object, var, ...)
SetIdent(object, ...)
StashIdent(object, save.name, ...)
## S3 method for class 'Seurat'
Idents(object, ...)
## S3 replacement method for class 'Seurat'
Idents(object, cells = NULL, drop = FALSE, replace = FALSE, ...) <- value
## S3 method for class 'Seurat'
ReorderIdent(
object,
var,
reverse = FALSE,
afxn = mean,
reorder.numeric = FALSE,
...
)
## S3 method for class 'Seurat'
RenameIdents(object, ...)
## S3 method for class 'Seurat'
SetIdent(object, cells = NULL, value, ...)
## S3 method for class 'Seurat'
StashIdent(object, save.name = "orig.ident", ...)
## S3 method for class 'Seurat'
droplevels(x, ...)
## S3 method for class 'Seurat'
levels(x)
## S3 replacement method for class 'Seurat'
levels(x) <- value
Arguments
... |
Arguments passed to other methods; for |
value |
The name of the identities to pull from object metadata or the identities themselves |
var |
Feature or variable to order on |
save.name |
Store current identity information under this name |
cells |
Set cell identities for specific cells |
drop |
Drop unused levels |
replace |
Replace identities for unset cells with |
reverse |
Reverse ordering |
afxn |
Function to evaluate each identity class based on; default is
|
reorder.numeric |
Rename all identity classes to be increasing numbers starting from 1 (default is FALSE) |
x , object |
An object |
Value
Idents
: The cell identities
Idents<-
: object
with the cell identities changed
RenameIdents
: An object with selected identity classes renamed
ReorderIdent
: An object with
SetIdent
: An object with new identity classes set
StashIdent
: An object with the identities stashed
Examples
# Get cell identity classes
Idents(pbmc_small)
# Set cell identity classes
# Can be used to set identities for specific cells to a new level
Idents(pbmc_small, cells = 1:4) <- 'a'
head(Idents(pbmc_small))
# Can also set idents from a value in object metadata
colnames(pbmc_small[[]])
Idents(pbmc_small) <- 'RNA_snn_res.1'
levels(pbmc_small)
# Rename cell identity classes
# Can provide an arbitrary amount of idents to rename
levels(pbmc_small)
pbmc_small <- RenameIdents(pbmc_small, '0' = 'A', '2' = 'C')
levels(pbmc_small)
## Not run:
head(Idents(pbmc_small))
pbmc_small <- ReorderIdent(pbmc_small, var = 'PC_1')
head(Idents(pbmc_small))
## End(Not run)
# Set cell identity classes using SetIdent
cells.use <- WhichCells(pbmc_small, idents = '1')
pbmc_small <- SetIdent(pbmc_small, cells = cells.use, value = 'B')
head(pbmc_small[[]])
pbmc_small <- StashIdent(pbmc_small, save.name = 'idents')
head(pbmc_small[[]])
# Get the levels of identity classes of a Seurat object
levels(x = pbmc_small)
# Reorder identity classes
levels(x = pbmc_small)
levels(x = pbmc_small) <- c('C', 'A', 'B')
levels(x = pbmc_small)
Pull spatial image names
Description
List the names of SpatialImage
objects present in a Seurat
object. If assay
is provided, limits search to images associated with
that assay
Usage
Images(object, assay = NULL)
Arguments
object |
A |
assay |
Name of assay to limit search to |
Value
A list of image names
Examples
## Not run:
Images(object)
## End(Not run)
Get Neighbor algorithm index
Description
Get Neighbor algorithm index
Usage
Index(object, ...)
Index(object, ...) <- value
## S3 method for class 'Neighbor'
Index(object, ...)
## S3 replacement method for class 'Neighbor'
Index(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
The index to store |
Value
Returns the value in the alg.idx slot of the Neighbor object
Idents<-
: A Neighbor object with the index stored
Get Neighbor nearest neighbor index matrices
Description
Get Neighbor nearest neighbor index matrices
Usage
Indices(object, ...)
## S3 method for class 'Neighbor'
Indices(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
Value
A matrix with the nearest neighbor indices
Is an object global/persistent?
Description
Typically, when removing Assay
objects from an Seurat
object,
all associated objects (eg. DimReduc
, Graph
, and
SeuratCommand
objects)
are removed as well. If an associated object is marked as global/persistent,
the associated object will remain even if its original assay was deleted
Usage
IsGlobal(object, ...)
## Default S3 method:
IsGlobal(object, ...)
## S3 method for class 'DimReduc'
IsGlobal(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
Value
TRUE
if the object is global/persistent otherwise FALSE
Examples
IsGlobal(pbmc_small[['pca']])
Check if a matrix is empty
Description
Takes a matrix and asks if it's empty (either 0x0 or 1x1 with a value of NA)
Usage
IsMatrixEmpty(x)
## Default S3 method:
IsMatrixEmpty(x)
Arguments
x |
A matrix |
Value
Whether or not x
is empty
See Also
Examples
IsMatrixEmpty(new("matrix"))
IsMatrixEmpty(matrix())
IsMatrixEmpty(matrix(1:3))
Check List Names
Description
Check to see if a list has names; also check to enforce that all names are present and unique
Usage
IsNamedList(x, all.unique = TRUE, allow.empty = FALSE, pass.zero = FALSE)
Arguments
x |
A list |
all.unique |
Require that all names are unique from one another |
allow.empty |
Allow empty ( |
pass.zero |
Pass on zero-length lists |
Value
TRUE
if ..., otherwise FALSE
Examples
IsNamedList(list())
IsNamedList(list(), pass.zero = TRUE)
IsNamedList(list(1, 2, 3))
IsNamedList(list(a = 1, b = 2, c = 3))
IsNamedList(list(a = 1, 2, c = 3))
IsNamedList(list(a = 1, 2, c = 3), allow.empty = TRUE)
IsNamedList(list(a = 1, a = 2, a = 3))
IsNamedList(list(a = 1, a = 2, a = 3), all.unique = FALSE)
Is a Matrix Sparse
Description
Is a Matrix Sparse
Usage
IsSparse(x)
Arguments
x |
A matrix |
Value
...
See Also
.SparseSlots()
,
RegisterSparseMatrix()
Examples
IsSparse(matrix())
IsSparse(LayerData(pbmc_small, "counts"))
Get and set JackStraw information
Description
Get and set JackStraw information
Usage
JS(object, ...)
JS(object, ...) <- value
## S3 method for class 'JackStrawData'
JS(object, slot, ...)
## S3 replacement method for class 'JackStrawData'
JS(object, slot, ...) <- value
## S3 method for class 'DimReduc'
JS(object, slot = NULL, ...)
## S3 replacement method for class 'DimReduc'
JS(object, slot = NULL, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
JackStraw information |
slot |
Name of slot to store JackStraw scores to Can shorten to 'empirical', 'fake', 'full', or 'overall' |
Value
JS
: either a JackStrawData
object or the
specified jackstraw data
JS<-
: object
with the update jackstraw information
The JackStrawData Class
Description
The JackStrawData is used to store the results of a JackStraw computation.
Slots
empirical.p.values
Empirical p-values
fake.reduction.scores
Fake reduction scores
empirical.p.values.full
Empirical p-values on full
overall.p.values
Overall p-values from ScoreJackStraw
JackStrawData
Methods
Description
Methods for JackStrawData
objects for generics defined in
other packages
Usage
## S3 method for class 'JackStrawData'
.DollarNames(x, pattern = "")
## S3 method for class 'JackStrawData'
x$i, ...
## S3 method for class 'JackStrawData'
as.logical(x, ...)
## S4 method for signature 'JackStrawData'
show(object)
Arguments
x , object |
A |
pattern |
A regular expression. Only matching names are returned. |
i |
A |
... |
Ignored |
Value
$
: Slot i
from x
as.logical
: TRUE
if empirical p-values have been
calculated otherwise FALSE
show
: Prints summary to stdout
and
invisibly returns NULL
Functions
-
.DollarNames(JackStrawData)
: Autocompletion for$
access on aJackStrawData
object -
$
: Access data from aJackStrawData
object -
as.logical(JackStrawData)
: Have empirical p-values for aJackStrawData
object been calculated -
show(JackStrawData)
: Overview of aJackStrawData
object
Split and Join Layers Together
Description
Split and Join Layers Together
Usage
JoinLayers(object, ...)
## S3 method for class 'Assay5'
JoinLayers(object, layers = NULL, new = NULL, ...)
## S3 method for class 'Seurat'
JoinLayers(object, assay = NULL, layers = NULL, new = NULL, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
layers |
Names of layers to split or join |
new |
Name of new layers |
assay |
Name of assay to split layers |
Value
object
with the layers specified joined
Get and set object keys
Description
Get and set object keys
Usage
Key(object, ...)
Keys(object, ...)
Key(object, ...) <- value
## S3 method for class 'Assay'
Key(object, ...)
## S3 replacement method for class 'Assay'
Key(object, ...) <- value
## S3 method for class 'Assay5'
Key(object, ...)
## S3 replacement method for class 'Assay5'
Key(object, ...) <- value
## S3 method for class 'DimReduc'
Key(object, ...)
## S3 replacement method for class 'DimReduc'
Key(object, ...) <- value
## S3 method for class 'Seurat'
Key(object, ...)
## S3 method for class 'Seurat'
Keys(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Key value |
Value
Key
: the object key
Keys
: a named vector of keys of sub-objects
Key<-
: object
with an updated key
Examples
# Get an Assay key
Key(pbmc_small[["RNA"]])
# Set the key for an Assay
Key(pbmc_small[["RNA"]]) <- "newkey_"
Key(pbmc_small[["RNA"]])
# Get a DimReduc key
Key(object = pbmc_small[["pca"]])
# Set the key for DimReduc
Key(object = pbmc_small[["pca"]]) <- "newkey2_"
Key(object = pbmc_small[["pca"]])
# Show all keys associated with a Seurat object
Key(object = pbmc_small)
Keys(object = pbmc_small)
Key Validity
Description
Validation of KeyMixin
objects is handled by
validObject
Key Validation
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “
''
”) wherenchar() == 0
An string composed of one or more alphanumeric values (both lower- and upper-case) that ends with an underscore (“
_
”); the first character must be a letter
Keys that are not empty strings are validated with the regex
“^[a-zA-Z][a-zA-Z0-9]*_$
”
See Also
.KeyPattern()
,
.RandomKey()
,
KeyMixin-class
A Mixin for Keyed objects
Description
A mixin (virtual class) for enabling keyed objects; provides consistent behavior for getting, setting, and validating keys
Usage
## S3 method for class 'character'
Key(object, ..., quiet = FALSE)
## S3 method for class 'KeyMixin'
Key(object, ...)
## S3 replacement method for class 'KeyMixin'
Key(object, ...) <- value
Arguments
object |
An object |
... |
Ignored |
quiet |
Suppress warnings when updating characters to keys |
value |
A key to set |
Details
Key.character
: Update a character to a key
Key.KeyMixin
: Get the key of a keyed object
Key<-
: Set the key of a keyed object
Value
Key.character
: object
but as a syntactically-valid key
Key.KeyMixin
: The key from object
; if no key set,
returns NULL
Key<-
: object
with the key set to value
Slots
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
.KeyPattern()
,
.RandomKey()
,
Key-validity
Query and Manipulate Assay Layers
Description
Query and Manipulate Assay Layers
Usage
LayerData(object, layer, ...)
LayerData(object, layer, ...) <- value
Layers(object, ...)
## S3 method for class 'Assay'
LayerData(
object,
layer = NULL,
cells = NULL,
features = NULL,
slot = deprecated(),
...
)
## S3 replacement method for class 'Assay'
LayerData(object, layer, ...) <- value
## S3 method for class 'Assay'
Layers(object, search = NA, ...)
## S3 method for class 'Assay5'
LayerData(
object,
layer = NULL,
cells = NULL,
features = NULL,
fast = FALSE,
slot = deprecated(),
...
)
## S3 replacement method for class 'Assay5'
LayerData(object, layer, features = NULL, cells = NULL, ...) <- value
## S3 method for class 'Assay5'
Layers(object, search = NA, ...)
## S3 method for class 'Seurat'
LayerData(object, layer = NULL, assay = NULL, slot = deprecated(), ...)
## S3 replacement method for class 'Seurat'
LayerData(object, layer, assay = NULL, ...) <- value
## S3 method for class 'Seurat'
Layers(object, search = NA, assay = NULL, ...)
Arguments
object |
An object |
layer |
Name of layer to fetch or set |
... |
Arguments passed to other methods |
value |
New two-dimensional data to be added as a layer |
features , cells |
Vectors of features/cells to include |
slot |
|
search |
A pattern to search layer names for; pass one of:
|
fast |
Determine how to return the layer data; choose from:
|
assay |
Name of assay to fetch layer data from or assign layer data to |
Value
LayerData
: the layer data for layer
from object
Layer<-
: object
with value
added as a layer
named layer
Layers
: the names of the layers present in object
Query and Manipulate Assay Layers
Description
Query and Manipulate Assay Layers
Usage
## S3 method for class 'StdAssay'
LayerData(
object,
layer = NULL,
cells = NULL,
features = NULL,
fast = FALSE,
slot = deprecated(),
...
)
## S3 replacement method for class 'StdAssay'
LayerData(object, layer, features = NULL, cells = NULL, ...) <- value
## S3 method for class 'StdAssay'
Layers(object, search = NA, ...)
Arguments
object |
An object |
layer |
Name of layer to fetch or set |
features , cells |
Vectors of features/cells to include |
fast |
Determine how to return the layer data; choose from:
|
slot |
|
... |
Arguments passed to other methods |
value |
New two-dimensional data to be added as a layer |
search |
A pattern to search layer names for; pass one of:
|
Value
LayerData
: the layer data for layer
from object
Layer<-
: object
with value
added as a layer
named layer
Layers
: the names of the layers present in object
Get and set feature loadings
Description
Get and set feature loadings
Usage
Loadings(object, ...)
Loadings(object, ...) <- value
## S3 method for class 'DimReduc'
Loadings(object, projected = FALSE, ...)
## S3 replacement method for class 'DimReduc'
Loadings(object, projected = TRUE, ...) <- value
## S3 method for class 'Seurat'
Loadings(object, reduction = "pca", projected = FALSE, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Feature loadings to add |
projected |
Pull the projected feature loadings? |
reduction |
Name of reduction to pull feature loadings for |
Value
Loadings
: the feature loadings for object
Loadings<-
: object
with the updated loadings
Examples
# Get the feature loadings for a given DimReduc
Loadings(object = pbmc_small[["pca"]])[1:5,1:5]
# Set the feature loadings for a given DimReduc
new.loadings <- Loadings(object = pbmc_small[["pca"]])
new.loadings <- new.loadings + 0.01
Loadings(object = pbmc_small[["pca"]]) <- new.loadings
# Get the feature loadings for a specified DimReduc in a Seurat object
Loadings(object = pbmc_small, reduction = "pca")[1:5,1:5]
A Logical Map
Description
A simple container for storing mappings of values using logical matrices.
Keeps track of which values (rows) are present in which observations
(columns). LogMap
objects can be created with LogMap()
;
queries can be performed with [[
and observations can be added
or removed with [[<-
Usage
LogMap(y)
## S4 method for signature 'LogMap,character,missing'
x[[i, j, ...]]
## S4 method for signature 'LogMap,missing,missing'
x[[i, j, ...]]
## S4 method for signature 'LogMap,NULL,missing'
x[[i, j, ...]]
## S4 replacement method for signature 'LogMap,character,missing,character'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'LogMap,character,missing,integer'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'LogMap,character,missing,NULL'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'LogMap,character,missing,numeric'
x[[i, j, ...]] <- value
Arguments
y |
A character vector |
x |
A |
i |
A character vector of length 1, or |
j |
Not used |
... |
Ignored |
value |
A character or integer vector of values to record in the map
for |
Value
LogMap
: A new LogMap
object with zero columns and
length(x = x)
rows; rownames are set to x
[[
: if i
is a character vector, the rownames that are
mapped to i
; otherwise the rownames of x
[[<-
: If value
is NULL
, then x
without
the observations for i
; otherwise, x
with a new column for
i
recording a TRUE
for all values present in value
Slots
.Data
A logical matrix with at least one row
See Also
Logical map objects, validity, and interaction methods:
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
Examples
# Create a LogMap
map <- LogMap(letters[1:10])
map
# Get the names of values in the LogMap
map[[NULL]]
rownames(map)
# Add an observation to the LogMap
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
map
# Get the names of observations in the LogMap
colnames(map)
# Fetch an observation from the LogMap
map[['obs']]
# Get the full logical matrix
map[[]]
# Remove an observation from the LogMap
map[['obs']] <- NULL
map[['entry']] <- NULL
map
Logical Map Validity
Description
Validation of LogMap
objects is handled by
validObject
Data Validation
Logical maps must be a logical matrix containing only TRUE or FALSE values
Value Validation
All values must be named within the rownames of the object. Duplicate or
empty (""
) values are not allowed
Observation Validation
All observations must be named within the column names of the object.
Duplicate or empty (""
) observations are not allowed
See Also
Logical map objects, validity, and interaction methods:
LogMap
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
validObject(map)
Log a command
Description
Logs command run, storing the name, timestamp, and argument list. Stores in the Seurat object
Usage
LogSeuratCommand(object, return.command = FALSE)
Arguments
object |
Name of Seurat object |
return.command |
Return a |
Value
If return.command
, returns a SeuratCommand
object; otherwise, returns the Seurat object with command stored
See Also
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Match Cells
Description
Match Cells
Usage
MatchCells(new, orig, ordered = FALSE)
## S3 method for class 'character'
MatchCells(new, orig, ordered = FALSE)
## S3 method for class ''NULL''
MatchCells(new, orig, ordered = FALSE)
## S3 method for class 'numeric'
MatchCells(new, orig, ordered = FALSE)
Arguments
new |
A vector of new cells |
orig |
A vector of existing cells |
ordered |
Sort the result to the same order as |
Value
A numeric vector with new cells in order of the original cells; if
no match can be found, returns NULL
Get and set miscellaneous data
Description
Get and set miscellaneous data
Usage
Misc(object, ...)
Misc(object, ...) <- value
## S3 method for class 'Assay'
Misc(object, slot = NULL, ...)
## S3 replacement method for class 'Assay'
Misc(object, slot, ...) <- value
## S3 method for class 'Assay5'
Misc(object, slot = NULL, ...)
## S3 replacement method for class 'Assay5'
Misc(object, slot, ...) <- value
## S3 method for class 'DimReduc'
Misc(object, slot = NULL, ...)
## S3 replacement method for class 'DimReduc'
Misc(object, slot, ...) <- value
## S3 method for class 'Seurat'
Misc(object, slot = NULL, ...)
## S3 replacement method for class 'Seurat'
Misc(object, slot, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Data to add |
slot |
Name of specific bit of meta data to pull |
Value
Miscellaneous data
An object with miscellaneous data added
Examples
# Get the misc info
Misc(object = pbmc_small, slot = "example")
# Add misc info
Misc(object = pbmc_small, slot = "example") <- "testing_misc"
Get and set miscellaneous data
Description
Get and set miscellaneous data
Usage
## S3 method for class 'StdAssay'
Misc(object, slot = NULL, ...)
## S3 replacement method for class 'StdAssay'
Misc(object, slot, ...) <- value
Arguments
object |
An object |
slot |
Name of specific bit of meta data to pull |
... |
Arguments passed to other methods |
value |
Data to add |
Value
Miscellaneous data
An object with miscellaneous data added
The Spatial Molecules Class
Description
The Spatial Molecules Class
Slots
.Data
A list of
SpatialPoints
objectskey
The key for the
Molecules
See Also
Molecules
methods: Molecules-methods
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Molecules
Methods
Description
Methods for Molecules
objects
Usage
## S3 method for class 'Molecules'
Features(x, ...)
## S3 method for class 'Molecules'
GetTissueCoordinates(object, features = NULL, ...)
## S3 method for class 'Molecules'
subset(x, features = NULL, ...)
## S4 method for signature 'Molecules'
show(object)
Arguments
x , object |
A |
... |
Arguments passed to other methods |
features |
A vector of molecule names to keep; if |
Details
Features
: Get spatially-resolved molecule names
GetTissueCoordinates
: Get spatially-resolved
molecule coordinates
subset
: Subset a Molecules
object to certain molecules
show
: Display an object summary to stdout
Value
Features
: A vector of spatially-resolved molecule names;
if no molecular information present, returns NULL
GetTissueCoordinates
: A data frame with three columns:
-
“
x
”: the x-coordinate of a molecule -
“
y
”: the y-coordinate of a molecule -
“
molecule
”: the molecule name
subset
: x
subsetted to the features specified
by features
show
: Invisibly returns NULL
See Also
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Segmentation-class
,
Segmentation-methods
The Neighbor class
Description
The Neighbor class is used to store the results of neighbor finding algorithms
Slots
nn.idx
Matrix containing the nearest neighbor indices
nn.dist
Matrix containing the nearest neighbor distances
alg.idx
The neighbor finding index (if applicable). E.g. the annoy index
alg.info
Any information associated with the algorithm that may be needed downstream (e.g. distance metric used with annoy is needed when reading in from stored file).
cell.names
Names of the cells for which the neighbors have been computed.
Neighbor
Methods
Description
Methods for Neighbor
objects for generics defined in
other packages
Usage
## S3 method for class 'Neighbor'
dim(x)
## S4 method for signature 'Neighbor'
show(object)
Arguments
x , object |
A |
Value
dim
Dimensions of the indices matrix
show
: Prints summary to stdout
and
invisibly returns NULL
Functions
-
dim(Neighbor)
: Dimensions of the neighbor indices -
show(Neighbor)
: Overview of aNeighbor
object
Overlay Spatial
Objects Over One Another
Description
Create an overlay of some query spatial object (x
) against some
target object (y
). Basically, find all components of a query that
fall within the bounds of a target spatial region
Usage
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'Centroids,SpatialPolygons'
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'Segmentation,SpatialPolygons'
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'Molecules,SpatialPolygons'
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'FOV,Spatial'
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'FOV,SpatialPolygons'
Overlay(x, y, invert = FALSE, ...)
## S4 method for signature 'FOV,FOV'
Overlay(x, y, invert = FALSE, ...)
Arguments
x |
Query |
y |
Target |
invert |
Invert the overlay and return only the components of |
... |
Ignored |
Value
x
with only the components that fall within the
bounds of y
Note
This function requires the sf package to be installed
Check the existence of a package
Description
Check the existence of a package
Usage
PackageCheck(..., error = TRUE)
Arguments
... |
Package names |
error |
If true, throw an error if the package doesn't exist |
Value
Invisibly returns boolean denoting if the package is installed
Lifecycle
PackageCheck
was deprecated in version 5.0.0; please use
rlang::check_installed()
instead
Examples
PackageCheck("SeuratObject", error = FALSE)
Polygon Vertices
Description
Calculate the vertices of a regular polygon given the number of sides and its radius (distance from center to vertex). Also permits transforming the resulting coordinates by moving the origin and altering the initial angle
Usage
PolyVtx(n, r = 1L, xc = 0L, yc = 0L, t1 = 0)
Arguments
n |
Number of sides of the polygon |
r |
Radius of the polygon |
xc , yc |
X/Y coordinates for the center of the polygon |
t1 |
Angle of the first vertex in degrees |
Value
A data.frame
with n
rows and two columns:
x
X positions of each coordinate
y
Y positions of each coordinate
References
https://stackoverflow.com/questions/3436453/calculate-coordinates-of-a-regular-polygons-vertices
See Also
Examples
(coords <- PolyVtx(5, t1 = 90))
if (requireNamespace("ggplot2", quietly = TRUE)) {
ggplot2::ggplot(coords, ggplot2::aes(x = x, y = y)) + ggplot2::geom_polygon()
}
Get and set project information
Description
Get and set project information
Usage
Project(object, ...)
Project(object, ...) <- value
## S3 method for class 'Seurat'
Project(object, ...)
## S3 replacement method for class 'Seurat'
Project(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Project information to set |
Value
Project information
An object with project information added
Get the spot radius from an image
Description
Get the spot radius from an image
Usage
Radius(object, ...)
Arguments
object |
An image object |
... |
Arguments passed to other methods |
Value
The radius size
Generate a random name
Description
Make a name from randomly sampled characters, pasted together with no spaces
Usage
RandomName(length = 5L, chars = letters, ...)
Arguments
length |
How long should the name be |
chars |
A vector of 1-length characters to use to generate the name |
... |
Extra parameters passed to |
Value
A character with nchar == length
of randomly sampled letters
See Also
Examples
set.seed(42L)
RandomName()
RandomName(7L, replace = TRUE)
Register Sparse Matrix Classes
Description
Register Sparse Matrix Classes
Usage
RegisterSparseMatrix(class, package = NULL)
Arguments
class |
Class name |
package |
Optional name of package; by default, will search namespaces of loaded packages to determine the providing package |
Value
Invisibly returns NULL
See Also
.SparseSlots()
,
IsSparse()
Rename assays in a Seurat
object
Description
Rename assays in a Seurat
object
Usage
RenameAssays(
object,
assay.name = NULL,
new.assay.name = NULL,
verbose = TRUE,
...
)
Arguments
object |
A |
assay.name |
original name of assay |
new.assay.name |
new name of assay |
verbose |
Whether to print messages |
... |
Named arguments as |
Value
object
with assays renamed
Examples
RenameAssays(object = pbmc_small, RNA = 'rna')
Rename cells
Description
Change the cell names in all the different parts of an object. Can be useful before combining multiple objects.
Usage
RenameCells(object, ...)
## S3 method for class 'Assay'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'Assay5'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'DimReduc'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'Neighbor'
RenameCells(object, old.names = NULL, new.names = NULL, ...)
## S3 method for class 'Seurat'
RenameCells(
object,
add.cell.id = missing_arg(),
new.names = missing_arg(),
for.merge = deprecated(),
...
)
Arguments
object |
An object |
... |
Arguments passed to other methods |
new.names |
vector of new cell names |
old.names |
vector of old cell names |
add.cell.id |
prefix to add cell names |
for.merge |
Deprecated |
Details
If add.cell.id
is set a prefix is added to existing cell names. If
new.names
is set these will be used to replace existing names.
Value
An object with new cell names
Examples
# Rename cells in an Assay
head(x = colnames(x = pbmc_small[["RNA"]]))
renamed.assay <- RenameCells(
pbmc_small[["RNA"]],
new.names = paste0("A_", colnames(x = pbmc_small[["RNA"]]))
)
head(x = colnames(x = renamed.assay))
# Rename cells in a DimReduc
head(x = Cells(x = pbmc_small[["pca"]]))
renamed.dimreduc <- RenameCells(
object = pbmc_small[["pca"]],
new.names = paste0("A_", Cells(x = pbmc_small[["pca"]]))
)
head(x = Cells(x = renamed.dimreduc))
# Rename cells in a Seurat object
head(x = colnames(x = pbmc_small))
pbmc_small <- RenameCells(object = pbmc_small, add.cell.id = "A")
head(x = colnames(x = pbmc_small))
Rename cells
Description
Change the cell names in all the different parts of an object. Can be useful before combining multiple objects.
Usage
## S3 method for class 'StdAssay'
RenameCells(object, new.names = NULL, ...)
Arguments
object |
An object |
new.names |
vector of new cell names |
... |
Arguments passed to other methods |
Details
If add.cell.id
is set a prefix is added to existing cell names. If
new.names
is set these will be used to replace existing names.
Value
An object with new cell names
Merge Sparse Matrices by Row
Description
Merge two or more sparse matrices by rowname.
Usage
RowMergeSparseMatrices(mat1, mat2)
Arguments
mat1 |
First matrix |
mat2 |
Second matrix or list of matrices |
Details
Shared matrix rows (with the same row name) will be merged, and unshared rows (with different names) will be filled with zeros in the matrix not containing the row.
Value
Returns a sparse matrix
Save and Load Seurat
Objects from Rds files
Description
Save and Load Seurat
Objects from Rds files
Usage
SaveSeuratRds(
object,
file = NULL,
move = TRUE,
destdir = deprecated(),
relative = FALSE,
...
)
LoadSeuratRds(file, ...)
Arguments
object |
A |
file |
Path to save |
move |
Move on-disk layers into |
destdir |
|
relative |
Save relative paths instead of absolute ones |
... |
Arguments passed on to
|
Value
Invisibly returns file
Progress Updates with progressr
This function uses
progressr to
render status updates and progress bars. To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
Note
This function requires the fs package to be installed
See Also
Examples
if (requireNamespace("fs", quietly = TRUE)) {
# Write out with DelayedArray
if (requireNamespace("HDF5Array", quietly = TRUE)) {
pbmc <- pbmc_small
pbmc[["disk"]] <- CreateAssay5Object(list(
mem = LayerData(pbmc, "counts"),
disk = as(LayerData(pbmc, "counts"), "HDF5Array")
))
# Save `pbmc` to an Rds file
out <- tempfile(fileext = ".Rds")
SaveSeuratRds(pbmc, file = out)
# Object cache
obj <- readRDS(out)
Tool(obj, "SaveSeuratRds")
# Load the saved object with on-disk layers back into memory
pbmc2 <- LoadSeuratRds(out)
pbmc2
pbmc2[["disk"]]
}
# Write out with BPCells
if (requireNamespace("BPCells", quietly = TRUE)) {
pbmc <- pbmc_small
bpm <- BPCells::write_matrix_dir(LayerData(pbmc, "counts"), dir = tempfile())
bph <- BPCells::write_matrix_hdf5(
LayerData(pbmc, "counts"),
path = tempfile(fileext = ".h5"),
group = "counts"
)
pbmc[["disk"]] <- CreateAssay5Object(list(dir = bpm, h5 = bph))
# Save `pbmc` to an Rds file
out <- tempfile(fileext = ".Rds")
SaveSeuratRds(pbmc, file = out)
# Object cache
obj <- readRDS(out)
Tool(obj, "SaveSeuratRds")
# Load the saved object with on-disk layers back into memory
pbmc2 <- LoadSeuratRds(out)
pbmc2
pbmc2[["disk"]]
}
}
The Segmentation
Class
Description
The Segmentation
Class
See Also
Segmentation
methods: Segmentation-methods
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-methods
Segmentation
Methods
Description
Methods for Segmentation
objects
Usage
## S3 method for class 'Segmentation'
Cells(x, ...)
## S3 method for class 'Segmentation'
GetTissueCoordinates(object, full = TRUE, ...)
## S3 method for class 'Segmentation'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'Segmentation'
lengths(x, use.names = TRUE)
## S3 method for class 'Segmentation'
subset(x, cells = NULL, ...)
## S4 method for signature 'Segmentation,ANY,ANY,ANY'
x[i, j, ..., drop = TRUE]
## S4 method for signature 'Segmentation'
coordinates(obj, full = TRUE, ...)
## S4 method for signature 'Segmentation'
show(object)
Arguments
x , object , obj |
A
|
... |
Arguments passed to other methods |
full |
Expand the coordinates to the full polygon |
new.names |
vector of new cell names |
use.names |
Ignored |
i , cells |
A vector of cells to keep; if |
j , drop |
Ignored |
Details
Cells
: Get cell names
GetTissueCoordinates
, coordinates
: Get
tissue coordinates
RenameCells
: Update cell names
lengths
: Generate a run-length encoding of the cells present
subset
, [
: Subset a Segmentation
object to
certain cells
show
: Display an object summary to stdout
Value
Cells
: A vector of cell names
GetTissueCoordinates
, coordinates
: A data frame with
three columns:
-
“
x
”: the x-coordinate -
“
y
”: the y-coordinate -
“
cell
” or “ID
”: the cell name
If full
is TRUE
, then each coordinate will indicate a vertex
for the cell polygon; otherwise, each coordinate will indicate a centroid
for the cell. Note: GetTissueCoordinates
....
RenameCells
: object
with the cells renamed to
new.names
lengths
: An rle
object for the cells
subset
, [
: x
subsetted to the cells specified
by cells
/i
show
: Invisibly returns NULL
Progress Updates with progressr
The following methods use progressr to render status updates and progress bars:
-
RenameCells
To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
Parallelization with future
The following methods use future to enable parallelization:
-
RenameCells
Parallelization strategies can be set using
plan
. Common plans include “sequential
”
for non-parallelized processing or “multisession
” for parallel
evaluation using multiple R sessions; for other plans, see the
“Implemented evaluation strategies” section of
?future::plan
. For a more thorough introduction
to future, see
vignette("future-1-overview")
See Also
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
The Seurat Class
Description
The Seurat object is a representation of single-cell expression data for R;
each Seurat object revolves around a set of cells and consists of one or more
Assay
objects, or individual representations of
expression data (eg. RNA-seq, ATAC-seq, etc). These assays can be reduced
from their high-dimensional state to a lower-dimension state and stored as
DimReduc
objects. Seurat objects also
store additional metadata, both at the cell and feature level (contained
within individual assays). The object was designed to be as self-contained as
possible, and easily extendable to new methods.
Slots
assays
A list of assays for this project
meta.data
Contains meta-information about each cell, starting with number of features detected (nFeature) and the original identity class (orig.ident); more information is added using
AddMetaData
active.assay
Name of the active, or default, assay; settable using
DefaultAssay
active.ident
The active cluster identity for this Seurat object; settable using
Idents
graphs
A list of
Graph
objectsneighbors
...
reductions
A list of dimensional reduction objects for this object
images
A list of spatial image objects
project.name
Name of the project
misc
A list of miscellaneous information
version
Version of Seurat this object was built under
commands
A list of logged commands run on this
Seurat
objecttools
A list of miscellaneous data generated by other tools, should be filled by developers only using
Tool<-
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Seurat Object Validity
Description
Validation of Seurat
objects is handled by
validObject
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
The SeuratCommand
Class
Description
The SeuratCommand
is used for logging commands that are run
on a Seurat
object; it stores parameters and timestamps
Slots
name
Command name
time.stamp
Timestamp of when command was tun
assay.used
Optional name of assay used to generate
SeuratCommand
objectcall.string
String of the command call
params
List of parameters used in the command call
See Also
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Seurat Options
Description
Various options used in Seurat
Package Options
Seurat.coords.short_range
Defaults to
“max”
Currently set to “max”
Seurat.input.sparse_ratio
Defaults to
“0.4”
Currently set to “0.4”
Seurat.io.rds.strict
Defaults to
“FALSE”
Currently set to “FALSE”
Seurat.object.assay.calcn
Run CalcN
when adding assay data to a Seurat
object
Defaults to
“”
Currently set to “”
Seurat.object.assay.version
Defaults to
“v5”
Currently set to “v5”
Seurat.object.assay.v3.missing_layer
Defaults to
“matrix”
Currently set to “matrix”
Seurat.object.project
Default project for new Seurat
objects
Defaults to
“SeuratProject”
Currently set to “SeuratProject”
Simplify Geometry
Description
Simplify Geometry
Simplify segmentations by reducing the number of vertices
Usage
Simplify(coords, tol, topologyPreserve = TRUE)
## S3 method for class 'Spatial'
Simplify(coords, tol, topologyPreserve = TRUE)
Arguments
coords |
A 'Segmentation' object |
tol |
Numerical tolerance value to be used by the Douglas-Peuker algorithm |
topologyPreserve |
Logical determining if the algorithm should attempt to preserve the topology of the original geometry |
Value
A simplified version of coords
A 'Segmentation' object with simplified segmentation vertices
Generate empty dgC sparse matrix
Description
Generate empty dgC sparse matrix
Usage
SparseEmptyMatrix(nrow, ncol, rownames = NULL, colnames = NULL)
Arguments
ncol , nrow |
Number of columns and rows in matrix |
rownames , colnames |
Optional row- and column names for the matrix |
The SpatialImage class
Description
The SpatialImage
class is a virtual class representing spatial
information for Seurat. All spatial image information must inherit from this
class for use with Seurat
objects
Slots
assay
Name of assay to associate image data with; will give this image priority for visualization when the assay is set as the active/default assay in a
Seurat
objectkey
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
SpatialImage-methods
for a list of required and
provided methods
SpatialImage
methods
Description
Methods defined on the SpatialImage
class. Some of these
methods must be overridden in order to ensure proper functionality of the
derived classes (see Required methods below). Other methods are
designed to work across all SpatialImage
-derived subclasses, and
should only be overridden if necessary
Usage
## S3 method for class 'SpatialImage'
Cells(x, ...)
## S3 method for class 'SpatialImage'
DefaultAssay(object, ...)
## S3 replacement method for class 'SpatialImage'
DefaultAssay(object, ...) <- value
## S3 method for class 'SpatialImage'
GetImage(object, mode = c("grob", "raster", "plotly", "raw"), ...)
## S3 method for class 'SpatialImage'
GetTissueCoordinates(object, ...)
## S3 method for class 'SpatialImage'
IsGlobal(object, ...)
## S3 method for class 'SpatialImage'
Key(object, ...)
## S3 replacement method for class 'SpatialImage'
Key(object, ...) <- value
## S3 method for class 'SpatialImage'
Radius(object, ...)
## S3 method for class 'SpatialImage'
RenameCells(object, new.names = NULL, ...)
## S3 method for class 'SpatialImage'
x[i, ...]
## S3 method for class 'SpatialImage'
dim(x)
## S3 method for class 'SpatialImage'
subset(x, cells, ...)
## S4 method for signature 'SpatialImage'
show(object)
Arguments
x , object |
A |
... |
Arguments passed to other methods |
value |
Depends on the method:
|
mode |
How to return the image; should accept one of “grob”, “raster”, “plotly”, or “raw” |
new.names |
vector of new cell names |
i , cells |
A vector of cells to keep |
Value
[Override] Cells
: should return cell names
DefaultAssay
: The associated assay of a
SpatialImage
-derived object
DefaultAssay<-
: object
with the associated assay
updated
[Override] GetImage
: The image data from a
SpatialImage
-derived object
[Override] GetTissueCoordinates
: ...
IsGlobal
: returns TRUE
as images are, by default,
global
Key
: The key for a SpatialImage
-derived object
Key<-
: object
with the key set to value
Radius
: The spot radius size; by default, returns NULL
[Override] RenameCells
: object
with the new
cell names
[
, subset
: x
/object
for only the cells
requested
[Override] dim
: The dimensions of the image data in
(Y, X) format
show
: Prints summary to stdout
and
invisibly returns NULL
Functions
-
Cells(SpatialImage)
: Get the cell names from an image ([Override]) -
DefaultAssay(SpatialImage)
: Get the associated assay of aSpatialImage
-derived object -
DefaultAssay(SpatialImage) <- value
: Set the associated assay of aSpatialImage
-derived object -
GetImage(SpatialImage)
: Get the image data from aSpatialImage
-derived object -
GetTissueCoordinates(SpatialImage)
: Get tissue coordinates for aSpatialImage
-derived object ([Override]) -
IsGlobal(SpatialImage)
: Globality test forSpatialImage
-derived object -
Key(SpatialImage)
: Get the key for aSpatialImage
-derived object -
Key(SpatialImage) <- value
: Set the key for aSpatialImage
-derived object -
Radius(SpatialImage)
: Get the spot radius size -
RenameCells(SpatialImage)
: Rename cells in aSpatialImage
-derived object ([Override]) -
[
: Subset aSpatialImage
-derived object -
dim(SpatialImage)
: Get the plotting dimensions of an image ([Override]) -
subset(SpatialImage)
: Subset aSpatialImage
-derived object ([Override]) -
show(SpatialImage)
: Overview of aSpatialImage
-derived object
Provided methods
These methods are defined on the SpatialImage
object and should not
be overridden without careful thought
-
GetImage
; this method can be overridden to provide image data, normally returns empty image data. If overridden, should default to returning agrob
object -
Radius
; this method can be overridden to provide a spot radius for image objects -
[
; this method can be overridden to change default subset behavior, normally returnssubset(x = x, cells = i)
. If overridden, should only accepti
Required methods
All subclasses of the SpatialImage
class must define the following
methods; simply relying on the SpatialImage
method will result in
errors. For required parameters and their values, see the Usage
and
Arguments
sections
Cells
-
Return the cell/spot barcodes associated with each position
dim
-
Return the dimensions of the image for plotting in
(Y, X)
format GetTissueCoordinates
-
Return tissue coordinates; by default, must return a two-column
data.frame
with x-coordinates in the first column and y-coordinates in the second Radius
-
Return the spot radius; returns
NULL
by default for use with non-spot image technologies RenameCells
-
Rename the cell/spot barcodes for this image
subset
-
Subset the image data by cells/spots
These methods are used throughout Seurat, so defining them and setting the
proper defaults will allow subclasses of SpatialImage
to work
seamlessly
See Also
Core Assay Infrastructure
Description
The StdAssay
class is a virtual class that provides core
infrastructure for assay data in Seurat. Assays contain expression
data (layers) and associated feature-level meta data. Derived classes
(eg. the v5 Assay) may optionally
define additional functionality
Slots
layers
A named list containing expression matrices; each matrix should be a two-dimensional object containing some subset of cells and features defined in the
cells
andfeatures
slots. Cell and feature membership is recorded in thecells
andfeatures
slots, respectivelycells
A logical mapping of cell names and layer membership; this map contains all the possible cells that this assay can contain. New layers must have some subset of cells present in this map
features
A logical mapping of feature names and layer membership; this map contains all the possible features that this assay can contain. New layers must have some subset of features present in this map
default
A one-length integer with the end index of the default layer; the default layer be all layers up to and including the layer at index
default
assay.orig
Original assay that this assay is based off of; used to track assay provenance
meta.data
A data frame with feature-level meta data; should have the same number of rows as
features
misc
A named list of unstructured miscellaneous data
key
A one-length character vector with the object's key; keys must be one or more alphanumeric characters followed by an underscore “
_
” (regex pattern “^[a-zA-Z][a-zA-Z0-9]*_$
”)
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
V5 Assay Validity
Description
Validation of StdAssay
objects is handled by
validObject
Layer Validation
blah
Key Validation
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “
''
”) wherenchar() == 0
An string composed of one or more alphanumeric values (both lower- and upper-case) that ends with an underscore (“
_
”); the first character must be a letter
Keys that are not empty strings are validated with the regex
“^[a-zA-Z][a-zA-Z0-9]*_$
”
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Get the standard deviations for an object
Description
Get the standard deviations for an object
Usage
Stdev(object, ...)
## S3 method for class 'DimReduc'
Stdev(object, ...)
## S3 method for class 'Seurat'
Stdev(object, reduction = "pca", ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
reduction |
Name of reduction to use |
Value
The standard deviations
Examples
# Get the standard deviations for each PC from the DimReduc object
Stdev(object = pbmc_small[["pca"]])
# Get the standard deviations for each PC from the Seurat object
Stdev(object = pbmc_small, reduction = "pca")
Stitch Matrices Together
Description
Stitch Matrices Together
Usage
StitchMatrix(x, y, rowmap, colmap, ...)
Arguments
x |
A matrix |
y |
One or more matrices of the same class or coercible to the
same class as |
rowmap , colmap |
|
... |
Arguments passed to other methods |
Value
A single matrix of type class(x)
consisting of all values
in component matrices
Get the offset angle
Description
Get the offset angle
Usage
Theta(object)
Arguments
object |
An object |
Get and Set Additional Tool Data
Description
Use Tool
to get tool data. If no additional arguments are provided,
will return a vector with the names of tools in the object.
Usage
Tool(object, ...)
Tool(object, ...) <- value
## S3 method for class 'Seurat'
Tool(object, slot = NULL, ...)
## S3 replacement method for class 'Seurat'
Tool(object, ...) <- value
Arguments
object |
An object |
... |
Arguments passed to other methods |
value |
Information to be added to tool list |
slot |
Name of tool to pull |
Value
If no additional arguments, returns the names of the tools in the object; otherwise returns the data placed by the tool requested
Note
For developers: set tool data using Tool<-
. Tool<-
will
automatically set the name of the tool to the function that called
Tool<-
, so each function gets one entry in the tools list and cannot
overwrite another function's entry. The automatic naming will also remove any
method identifiers (eg. RunPCA.Seurat
will become RunPCA
);
please plan accordingly
Examples
# Example function that adds unstructured data to tools
MyTool <- function(object) {
sample.tool.output <- matrix(rnorm(n = 16), nrow = 4)
# Note: `Tool<-` must be called from within a function
# and the name of the tool will be generated from the function name
Tool(object) <- sample.tool.output
return(object)
}
# Run our tool
set.seed(42L)
pbmc_small <- MyTool(pbmc_small)
# Get a list of tools run
Tool(pbmc_small)
# Access specific tool data
Tool(pbmc_small, slot = "MyTool")
Update old Seurat object to accommodate new features
Description
Updates Seurat objects to new structure for storing data/calculations. For Seurat v3 objects, will validate object structure ensuring all keys and feature names are formed properly.
Usage
UpdateSeuratObject(object)
Arguments
object |
Seurat object |
Value
Returns a Seurat object compatible with latest changes
Examples
## Not run:
updated_seurat_object = UpdateSeuratObject(object = old_seurat_object)
## End(Not run)
Update slots in an object
Description
Update slots in an object
Usage
UpdateSlots(object)
Arguments
object |
An object to update |
Value
object
with the latest slot definitions
Highly Variable Features
Description
Get and set variable feature information for an Assay
object.
HVFInfo
and VariableFeatures
utilize generally variable
features, while SVFInfo
and SpatiallyVariableFeatures
are
restricted to spatially variable features
Usage
## S3 method for class 'StdAssay'
HVFInfo(object, method = NULL, status = FALSE, layer = NA, strip = TRUE, ...)
## S3 method for class 'StdAssay'
VariableFeatures(
object,
method = NULL,
layer = NA,
simplify = TRUE,
nfeatures = NULL,
selection.method = deprecated(),
...
)
## S3 replacement method for class 'StdAssay'
VariableFeatures(object, method = "custom", layer = NULL, ...) <- value
## S3 replacement method for class 'Assay5'
VariableFeatures(object, method = "custom", layer = NULL, ...) <- value
## S3 method for class 'StdAssay'
SpatiallyVariableFeatures(
object,
method = "moransi",
decreasing = TRUE,
selection.method = deprecated(),
...
)
Arguments
object |
An object |
method |
Which method to pull. For
For
|
status |
Add variable status to the resulting data frame |
layer |
Layer to pull variable features for |
strip |
Remove method/layer identifiers from highly variable data frame |
... |
Arguments passed to other methods |
simplify |
When pulling for multiple layers, combine into a single vector and select a common set of variable features for all layers |
nfeatures |
Maximum number of features to select when simplifying |
selection.method |
|
value |
A character vector of variable features |
decreasing |
Return features in decreasing order (most spatially variable first). |
Value
HVFInfo
: A data frame with feature means, dispersion, and
scaled dispersion
VariableFeatures
: a vector of the variable features
SVFInfo
: a data frame with the spatially variable features
SpatiallyVariableFeatures
: a character vector of the spatially
variable features
Get Version Information
Description
Get Version Information
Usage
Version(object, ...)
## S3 method for class 'Seurat'
Version(object, ...)
Arguments
object |
An object |
... |
Arguments passed to other methods |
Examples
Version(pbmc_small)
Identify cells matching certain criteria
Description
Returns a list of cells that match a particular set of criteria such as identity class, high/low values for particular PCs, etc.
Usage
WhichCells(object, ...)
## S3 method for class 'Assay'
WhichCells(object, cells = NULL, expression, invert = FALSE, ...)
## S3 method for class 'Seurat'
WhichCells(
object,
cells = NULL,
idents = NULL,
expression,
slot = "data",
invert = FALSE,
downsample = Inf,
seed = 1,
...
)
Arguments
object |
An object |
... |
Arguments passed on to
|
cells |
Subset of cell names |
expression |
A predicate expression for feature/variable expression,
can evaluate anything that can be pulled by |
invert |
Invert the selection of cells |
idents |
A vector of identity classes to keep |
slot |
Slot to pull feature data for |
downsample |
Maximum number of cells per identity class, default is
|
seed |
Random seed for downsampling. If NULL, does not set a seed |
Value
A vector of cell names
See Also
Examples
WhichCells(pbmc_small, idents = 2)
WhichCells(pbmc_small, expression = MS4A1 > 3)
levels(pbmc_small)
WhichCells(pbmc_small, idents = c(1, 2), invert = TRUE)
Matrix-like Subsetting for Logical Maps
Description
Matrix-like Subsetting for Logical Maps
Usage
## S4 method for signature 'LogMap,missing,missing,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,character,character,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,character,missing,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,missing,character,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,numeric,missing,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,missing,numeric,ANY'
x[i, j, ..., drop = FALSE]
## S4 method for signature 'LogMap,numeric,numeric,ANY'
x[i, j, ..., drop = FALSE]
Arguments
x |
A |
i , j |
Vectors of values ( |
... |
Arguments passed to other methods |
drop |
relevant for matrices and arrays. If |
Note
i
is not reordable; passing a different order for i
will return a subset with rows in the same order as x
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
map[]
map[1:5, 2L]
map[c("b", "c", "f"), "obs"]
# Pass `drop = TRUE` to cast to `matrix`
map[1:3, , drop = TRUE]
# Note that `i` is non-reordable
rownames(map)[1:3]
map[c("b", "c", "a"), , drop = TRUE]
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'Assay'
x[i = missing_arg(), j = missing_arg(), ...]
## S4 replacement method for signature 'Assay,character,ANY,ANY'
x[i, j, ...] <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
j |
Ignored |
... |
Arguments passed to |
value |
A matrix-like object to add as a new layer |
Value
[
: The layer data for layer i
[<-
: x
with layer data value
saved as i
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
rna <- pbmc_small[["RNA"]]
# Get a vector of layer names in this assay
rna[]
# Fetch layer data
rna["data"][1:10, 1:4]
# Set layer data
rna["data"] <- rna["counts"]
rna["data"][1:10, 1:4]
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'Assay5'
x[i = missing_arg(), j = missing_arg(), ...]
## S4 replacement method for signature 'Assay5,character,ANY,ANY'
x[i, j, ...] <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
j |
Ignored |
... |
Arguments passed to |
value |
A matrix-like object to add as a new layer |
Value
[
: The layer data for layer i
[<-
: x
with layer data value
saved as i
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Get Feature Loadings
Description
Pull feature loadings from a dimensional reduction
Usage
## S3 method for class 'DimReduc'
x[i, j, drop = FALSE, ...]
Arguments
x |
A |
i |
Feature identifiers or indices |
j |
Dimension identifiers or indices |
drop |
Coerce the result to the lowest possible dimension; see
|
... |
Arguments passed to other methods |
Details
[
does not distinguish between projected and unprojected feature
loadings; to select whether projected or unprojected loadings should be
pulled, please use Loadings
Value
Feature loadings for features i
and dimensions j
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Examples
pca <- pbmc_small[["pca"]]
pca[1:10, 1:5]
Command Log Data Access
Description
Access data from a SeuratCommand
object
Usage
## S3 method for class 'SeuratCommand'
x[i, ...]
Arguments
x |
A |
i |
The name of a command log slot |
... |
Ignored |
Value
[
: Slot i
from x
See Also
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
as.list.SeuratCommand()
Examples
cmd <- pbmc_small[["NormalizeData.RNA"]]
cmd["call.string"]
Layer Data
Description
Get and set layer data
Usage
## S3 method for class 'StdAssay'
x[i = missing_arg(), j = missing_arg(), ...]
## S4 replacement method for signature 'StdAssay,character,ANY,ANY'
x[i, j, ...] <- value
Arguments
x |
An |
i |
Name of layer data to get or set |
j |
Ignored |
... |
Arguments passed to |
value |
A matrix-like object to add as a new layer |
Value
[
: The layer data for layer i
[<-
: x
with layer data value
saved as i
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Add Subobjects
Description
Add subobjects containing expression, dimensional reduction, or other
containerized data to a Seurat
object. Subobjects can be
accessed with [[
and manipulated directly within
the Seurat
object or used independently
Usage
## S4 replacement method for signature 'Seurat,character,missing,Assay'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,Assay5'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,DimReduc'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,Graph'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,Neighbor'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,SeuratCommand'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,SpatialImage'
x[[i, j, ...]] <- value
Arguments
x |
A |
i |
Name to add subobject as |
j |
Ignored |
... |
Ignored |
value |
A valid subobject (eg. a v3 or v5 assay, or a dimensional reduction) |
Value
x
with value
added as i
See Also
See here for pulling subobjects using [[
,
here for adding metadata with [[<-
, and
here for removing subobjects and cell-level meta
data with [[<-
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Remove Subobjects and Cell-Level Meta Data
Description
Remove Subobjects and Cell-Level Meta Data
Usage
## S4 replacement method for signature 'Seurat,character,missing,NULL'
x[[i, j, ...]] <- value
Arguments
x |
A |
i |
Name(s) of subobject(s) or cell-level meta data to remove |
j |
Ignored |
... |
Ignored |
value |
NULL |
Value
x
with i
removed from the object
See Also
See here for pulling subobjects using [[
,
here for adding metadata with [[<-
, and
here for adding subobjects with [[<-
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Add Subobjects
Description
Add subobjects containing expression, dimensional reduction, or other
containerized data to a Seurat
object. Subobjects can be
accessed with [[
and manipulated directly within
the Seurat
object or used independently
Usage
## S4 replacement method for signature 'Seurat,character,missing,StdAssay'
x[[i, j, ...]] <- value
Arguments
x |
A |
i |
Name to add subobject as |
j |
Ignored |
... |
Ignored |
value |
A valid subobject (eg. a v3 or v5 assay, or a dimensional reduction) |
Value
x
with value
added as i
See Also
See here for pulling subobjects using [[
,
here for adding metadata with [[<-
, and
here for removing subobjects and cell-level meta
data with [[<-
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
LogMap
Interaction Methods
Description
Additional methods for using [[
with LogMap
objects
Usage
## S4 method for signature 'LogMap,integer,missing'
x[[i, j, ...]]
## S4 method for signature 'LogMap,numeric,missing'
x[[i, j, ...]]
Arguments
x |
A |
i |
An integer or numeric vector of length 1 |
j |
Not used |
... |
Ignored |
Value
The rownames that are mapped to i
Feature-Level Meta Data
Description
Get and set feature-level meta data
Usage
## S3 method for class 'Assay'
x[[i, ..., drop = FALSE]]
## S4 replacement method for signature 'Assay,ANY,ANY,ANY'
x[[i, j, ...]] <- value
## S3 method for class 'Assay'
head(x, n = 10L, ...)
## S3 method for class 'Assay'
tail(x, n = 10L, ...)
## S4 replacement method for signature 'Assay,missing,missing,data.frame'
x[[i, j, ...]] <- value
Arguments
x |
An |
i |
Name of feature-level meta data to fetch or add |
... |
Ignored |
drop |
See |
j |
Ignored |
value |
Feature-level meta data to add |
n |
Number of meta data rows to show |
Value
[[
: The feature-level meta data for i
[[<-
: x
with value
added as i
in feature-level meta data
head
: The first n
rows of feature-level meta data
tail
: the last n
rows of feature-level meta data
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
rna <- pbmc_small[["RNA"]]
# Pull the entire feature-level meta data data frame
head(rna[[]])
# Pull a specific column of feature-level meta data
head(rna[["vst.mean"]])
head(rna[["vst.mean", drop = TRUE]])
# `head` and `tail` can be used to quickly view feature-level meta data
head(rna)
tail(rna)
Feature-Level Meta Data
Description
Get and set feature-level meta data
Usage
## S3 method for class 'Assay5'
x[[i, j, ..., drop = FALSE]]
## S4 replacement method for signature 'Assay5,ANY,ANY,ANY'
x[[i, j, ...]] <- value
## S3 method for class 'Assay5'
head(x, n = 10L, ...)
## S3 method for class 'Assay5'
tail(x, n = 10L, ...)
Arguments
x |
An |
i |
Name of feature-level meta data to fetch or add |
j |
Ignored |
... |
Ignored |
drop |
See |
value |
Feature-level meta data to add |
n |
Number of meta data rows to show |
Value
[[
: The feature-level meta data for i
[[<-
: x
with value
added as i
in feature-level meta data
head
: The first n
rows of feature-level meta data
tail
: the last n
rows of feature-level meta data
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Get Cell Embeddings
Description
Pull cell embeddings from a dimensional reduction
Usage
## S3 method for class 'DimReduc'
x[[i, j, drop = FALSE, ...]]
Arguments
x |
A |
i |
Cell names or indices |
j |
Dimension identifiers or indices |
drop |
Coerce the result to the lowest possible dimension; see
|
... |
Arguments passed to other methods |
Value
Cell embeddings for cells i
and dimensions j
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Examples
pca <- pbmc_small[["pca"]]
pca[[1:10, 1:5]]
Subobjects and Cell-Level Meta Data
Description
The [[
operator pulls either subobjects
(eg. v3 or v5 assays,
dimensional reduction information,
or nearest-neighbor graphs) or cell-level
meta data from a Seurat
object
Usage
## S3 method for class 'Seurat'
x[[i = missing_arg(), ..., drop = FALSE, na.rm = FALSE]]
## S3 method for class 'Seurat'
head(x, n = 10L, ...)
## S3 method for class 'Seurat'
tail(x, n = 10L, ...)
Arguments
x |
A |
i |
Name of cell-level meta data |
... |
Ignored |
drop |
See |
na.rm |
Remove cells where meta data is all |
n |
Number of meta data rows to show |
Value
Varies based on the value of i
:
If
i
is missing, a data frame with cell-level meta dataIf
i
is a vector with cell-level meta data names, a data frame (or vector ofdrop = TRUE
) with cell-level meta data requestedIf
i
is a one-length character with the name of a subobject, the subobject specified byi
head
: The first n
rows of cell-level metadata
tail
: The last n
rows of cell-level metadata
See Also
See here for adding meta data with [[<-
,
here for adding subobjects with [[<-
, and
here for removing subobjects and cell-level meta
data with [[<-
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Examples
# Get the cell-level metadata data frame
head(pbmc_small[[]])
# Pull specific metadata information
head(pbmc_small[[c("letter.idents", "groups")]])
head(pbmc_small[["groups", drop = TRUE]])
# Get a sub-object (eg. an `Assay` or `DimReduc`)
pbmc_small[["RNA"]]
pbmc_small[["pca"]]
# Get the first 10 rows of cell-level metadata
head(pbmc_small)
# Get the last 10 rows of cell-level metadata
tail(pbmc_small)
Feature-Level Meta Data
Description
Get and set feature-level meta data
Usage
## S3 method for class 'StdAssay'
x[[i, j, ..., drop = FALSE]]
## S3 method for class 'StdAssay'
head(x, n = 10L, ...)
## S3 method for class 'StdAssay'
tail(x, n = 10L, ...)
## S4 replacement method for signature 'StdAssay,character,missing,data.frame'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,missing,missing,data.frame'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,character,missing,factor'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,character,missing,NULL'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,character,missing,vector'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,numeric,missing,ANY'
x[[i, j, ...]] <- value
## S4 replacement method for signature 'StdAssay,missing,missing,NULL'
x[[i, j, ...]] <- value
Arguments
x |
An |
i |
Name of feature-level meta data to fetch or add |
j |
Ignored |
... |
Ignored |
drop |
See |
n |
Number of meta data rows to show |
value |
Feature-level meta data to add |
Value
[[
: The feature-level meta data for i
[[<-
: x
with value
added as i
in feature-level meta data
head
: The first n
rows of feature-level meta data
tail
: the last n
rows of feature-level meta data
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Aggregate Molecules into an Expression Matrix
Description
Aggregate Molecules into an Expression Matrix
Usage
## S3 method for class 'FOV'
aggregate(x, by = NULL, set = NULL, drop = TRUE, ...)
## S3 method for class 'Molecules'
aggregate(x, by, drop = TRUE, ...)
Arguments
x |
An object with spatially-resolved molecule information |
by |
Name of a
|
set |
Name of molecule set to aggregate |
drop |
Drop molecules not present in a segmentation; if |
... |
Arguments passed to other methods |
Value
An expression matrix
Progress Updates with progressr
This function uses
progressr to
render status updates and progress bars. To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
Parallelization with future
This function uses
future to enable
parallelization. Parallelization strategies can be set using
plan
. Common plans include “sequential
”
for non-parallelized processing or “multisession
” for parallel
evaluation using multiple R sessions; for other plans, see the
“Implemented evaluation strategies” section of
?future::plan
. For a more thorough introduction
to future, see
vignette("future-1-overview")
Convert Segmentation Layers
Description
Convert Segmentation Layers
Usage
as.Centroids(x, nsides = NULL, radius = NULL, theta = NULL, ...)
as.Segmentation(x, ...)
## S3 method for class 'Segmentation'
as.Centroids(x, nsides = NULL, radius = NULL, theta = NULL, ...)
## S3 method for class 'Centroids'
as.Segmentation(x, ...)
Arguments
x |
An object |
nsides |
The number of sides to represent cells/spots; pass
|
radius |
Radius of shapes when plotting |
theta |
Angle to adjust shapes when plotting |
... |
Arguments passed to other methods |
Value
as.Centroids
: A
Centroids
object
as.Segmentation
: A
Segmentation
object
Coerce to a Graph
Object
Description
Convert a matrix
(or Matrix
) to
a Graph
object
Usage
as.Graph(x, ...)
## S3 method for class 'Matrix'
as.Graph(x, ...)
## S3 method for class 'matrix'
as.Graph(x, ...)
## S3 method for class 'Neighbor'
as.Graph(x, weighted = TRUE, ...)
Arguments
x |
The matrix to convert |
... |
Ignored |
weighted |
If TRUE, fill entries in Graph matrix with value from the nn.dist slot of the Neighbor object |
Value
A Graph
object
See Also
Other graph:
Graph-class
Examples
# converting sparse matrix
mat <- Matrix::rsparsematrix(nrow = 10, ncol = 10, density = 0.1)
rownames(x = mat) <- paste0("feature_", 1:10)
colnames(x = mat) <- paste0("cell_", 1:10)
g <- as.Graph(x = mat)
# converting dense matrix
mat <- matrix(data = 1:16, nrow = 4)
rownames(x = mat) <- paste0("feature_", 1:4)
colnames(x = mat) <- paste0("cell_", 1:4)
g <- as.Graph(x = mat)
Coerce to a Neighbor
Object
Description
Convert objects to Neighbor
objects
Usage
as.Neighbor(x, ...)
## S3 method for class 'Graph'
as.Neighbor(x, ...)
Arguments
x |
An object to convert to |
... |
Arguments passed to other methods |
Value
A Neighbor
object
Coerce to a Seurat
Object
Description
Convert objects to Seurat objects
Usage
as.Seurat(x, ...)
Arguments
x |
An object to convert to class |
... |
Arguments passed to other methods |
Value
A Seurat
object generated from x
Coerce a SeuratCommand
to a list
Description
Coerce a SeuratCommand
to a list
Usage
## S3 method for class 'SeuratCommand'
as.list(x, complete = FALSE, ...)
Arguments
x |
A |
complete |
Include slots besides just parameters (eg. call string, name, timestamp) |
... |
Ignored |
Value
A list with the parameters and, if complete = TRUE
,
the call string, name, and timestamp
See Also
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
Examples
cmd <- pbmc_small[["NormalizeData.RNA"]]
as.list(cmd)
as.list(cmd, complete = TRUE)
Coerce Logical Maps to Matrices
Description
Coerce a logical map to a matrix; this removes all logical map class capabilities from the object and returns a base-R matrix object
Usage
## S3 method for class 'LogMap'
as.matrix(x, ...)
Arguments
x |
A |
... |
Ignored |
Value
A base-R matrix created from x
See Also
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
mat <- as.matrix(map)
mat
class(mat)
Cast to Sparse
Description
Convert dense objects to sparse representations
Usage
as.sparse(x, ...)
## S3 method for class 'data.frame'
as.sparse(x, row.names = NULL, ...)
## S3 method for class 'Matrix'
as.sparse(x, ...)
## S3 method for class 'matrix'
as.sparse(x, ...)
## S3 method for class 'ngCMatrix'
as.sparse(x, ...)
Arguments
x |
An object |
... |
Arguments passed to other methods |
row.names |
|
Value
A sparse representation of the input data
Row and Column Sums and Means
Description
Calculate rowSums
, colSums
,
rowMeans
, and colMeans
on Assay
objects
Usage
## S4 method for signature 'Assay'
colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Assay'
colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Assay'
rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Assay'
rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data")
Arguments
x |
An |
na.rm |
logical. Should missing values (including |
dims |
completely ignored by the |
... |
Ignored |
slot |
Name of assay expression matrix to calculate column/row means/sums on |
Value
colMeans
: The column (cell-wise) means of slot
colSums
: The column (cell-wise) sums of slot
rowMeans
: The row (feature-wise) means of slot
rowSums
: The row (feature-wise) sums of slot
See Also
Examples
rna <- pbmc_small[["RNA"]]
colMeans(rna)
colSums(rna)
rowMeans(rna)
rowSums(rna)
Row and Column Sums and Means
Description
Calculate rowSums
, colSums
,
rowMeans
, and colMeans
on
Seurat
objects
Usage
## S4 method for signature 'Seurat'
colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Seurat'
colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Seurat'
rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data")
## S4 method for signature 'Seurat'
rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data")
Arguments
x |
A |
na.rm |
logical. Should missing values (including |
dims |
completely ignored by the |
... |
potentially further arguments, for method |
slot |
Name of assay expression matrix to calculate column/row means/sums on |
Value
colMeans
: the column (cell-wise) means of slot
colSums
: the column (cell-wise) sums of slot
rowMeans
: the row (feature-wise) means of slot
rowSums
: the row (feature-wise) sums of slot
See Also
Examples
head(colMeans(pbmc_small))
head(colSums(pbmc_small))
head(rowMeans(pbmc_small))
head(rowSums(pbmc_small))
Feature and Cell Numbers
Description
Feature and Cell Numbers
Usage
## S3 method for class 'Assay'
dim(x)
Arguments
x |
An |
Value
A two-length numeric vector with the total number of
features and cells in x
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Examples
rna <- pbmc_small[["RNA"]]
dim(rna)
Feature and Cell Numbers
Description
Feature and Cell Numbers
Usage
## S3 method for class 'Assay5'
dim(x)
Arguments
x |
An |
Value
A two-length numeric vector with the total number of
features and cells in x
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Dimensional Reduction Meta-Information
Description
Pull meta-information about cells and dimensions for a given
dimensional reduction; cell meta-information is stored
as row meta-information (eg. nrow
, rownames
) and dimension
meta-information is stored as column meta-information (eg. ncol
,
colnames
)
Usage
## S3 method for class 'DimReduc'
dim(x)
## S3 method for class 'DimReduc'
dimnames(x)
## S3 method for class 'DimReduc'
length(x)
## S3 method for class 'DimReduc'
names(x)
Arguments
x |
A |
Value
dim
: The number of cells (nrow
) and dimensions
(ncol
)
dimnames
: The cell (row) and dimension (column) names
length
: The number of dimensions
names
: The dimension identifiers
See Also
Cells
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Examples
pca <- pbmc_small[["pca"]]
pca
dim(pca)
# nrow is number of cells
nrow(pca)
# rownames pulls cell names
head(rownames(pca))
# ncol and length are number of dimensions
ncol(pca)
length(pca)
# colnames and names pull dimension identifiers
head(colnames(pca))
head(names(pca))
Feature and Cell Numbers
Description
Feature and Cell Numbers
Usage
## S3 method for class 'Seurat'
dim(x)
Arguments
x |
A |
Value
A two-length numeric vector with the total number of
features and cells in x
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Examples
# Get the number of features in an object
nrow(pbmc_small)
# Get the number of cells in an object
ncol(pbmc_small)
Feature and Cell Numbers
Description
Feature and Cell Numbers
Usage
## S3 method for class 'StdAssay'
dim(x)
Arguments
x |
An |
Value
A two-length numeric vector with the total number of
features and cells in x
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Assay-Level Feature and Cell Names
Description
Get and set feature and cell names in v5 Assays
Usage
## S3 method for class 'Assay'
dimnames(x)
## S3 replacement method for class 'Assay'
dimnames(x) <- value
Arguments
x |
An |
value |
A two-length list where the first entry is the existing feature
names for |
Value
dimnames
: A two-length list with the following values:
A character vector will all features in
x
A character vector will all cells in
x
dimnames<-
: x
with the cell names updated to those
in value[[2L]]
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Cells()
,
dimnames.Assay5()
,
dimnames.Seurat()
Examples
rna <- pbmc_small[["RNA"]]
# Feature and cell names can be acquired with `rownames` and `colnames`
head(rownames(rna))
head(colnames(rna))
# Cell names can be updated with `colnames<-`
colnames(rna)[1] <- "newcell"
head(colnames(rna))
Assay-Level Feature and Cell Names
Description
Get and set feature and cell names in v5 Assays
Usage
## S3 method for class 'Assay5'
dimnames(x)
## S3 replacement method for class 'Assay5'
dimnames(x) <- value
Arguments
x |
An |
value |
A two-length list with updated feature and/or cells names |
Value
dimnames
: A two-length list with the following values:
A character vector with all features in
x
A character vector with all cells in
x
dimnames<-
: x
with the feature and/or cell
names updated to value
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Cells()
,
dimnames.Assay()
,
dimnames.Seurat()
Feature and Cell Names
Description
Get and set feature and cell inames in Seurat
objects
Usage
## S3 method for class 'Seurat'
dimnames(x)
## S3 replacement method for class 'Seurat'
dimnames(x) <- value
Arguments
x |
A |
value |
A two-length list with updated feature and/or cells names |
Value
dimnames
: A two-length list with the following values:
A character vector with all features in the default assay
A character vector with all cells in
x
dimnames<-
: x
with the feature and/or cell
names updated to value
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Cells()
,
dimnames.Assay()
,
dimnames.Assay5()
Examples
# Get the feature names of an object
head(rownames(pbmc_small))
# Get the cell names of an object
head(colnames(pbmc_small))
colnames(pbmc_small)[1] <- "newcell"
head(colnames(pbmc_small))
Assay-Level Feature and Cell Names
Description
Get and set feature and cell names in v5 Assays
Usage
## S3 method for class 'StdAssay'
dimnames(x)
## S3 replacement method for class 'StdAssay'
dimnames(x) <- value
Arguments
x |
An |
value |
A two-length list with updated feature and/or cells names |
Value
dimnames
: A two-length list with the following values:
A character vector with all features in
x
A character vector with all cells in
x
dimnames<-
: x
with the feature and/or cell
names updated to value
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
,
subset.StdAssay()
Drop Unused Logical Map Values
Description
Remove any unused values from a logical map
Usage
## S3 method for class 'LogMap'
droplevels(x, ...)
Arguments
x |
A |
... |
Ignored |
Value
x
with values not present in any
observation removed
See Also
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
# Remove unused values
map <- droplevels(map)
map
map[[]]
Find Common Logical Map Values
Description
Identify values in a logical map that are common to every observation
Usage
## S3 method for class 'LogMap'
intersect(x, y = missing_arg(), ...)
Arguments
x |
A |
y |
Ignored |
... |
Ignored |
Value
The values of x
that are present in every observation
See Also
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
labels.LogMap()
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
# Identify values that are present in every observation
intersect(map)
Find Observations by Value
Description
Identify the observations that contain a specific value in a logical map
Usage
## S3 method for class 'LogMap'
labels(
object,
values,
select = c("first", "last", "common", "all"),
simplify = TRUE,
...
)
Arguments
object |
A |
values |
A vector of values to find observations for |
select |
Observation selection method; choose from:
|
simplify |
Simplify the resulting list to a vector |
... |
Ignored |
Value
labels
: A list, or vector if simplify
is TRUE
,
of all values and the observations they're found in, according
to the value of select
See Also
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
Examples
map <- LogMap(letters[1:10])
map[['obs']] <- c(1, 3, 7)
map[['entry']] <- c(2, 7, 10)
# Find observations for a set of values
labels(map, c('a', 'b', 'g'))
Merge Assays
Description
Merge one or more v3 assays together
Usage
## S3 method for class 'Assay'
merge(
x = NULL,
y = NULL,
add.cell.ids = NULL,
merge.data = TRUE,
labels = NULL,
collapse = TRUE,
...
)
Arguments
x |
An |
y |
One or more |
add.cell.ids |
A character vector of |
merge.data |
Merge the data slots instead of just merging the counts (which requires renormalization); this is recommended if the same normalization approach was applied to all objects |
labels , collapse |
Currently unused |
... |
Ignored |
Value
A new assay with data merged from c(x, y)
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
split.Assay()
,
subset.Assay()
Merge Assays
Description
Merge one or more v5 assays together
Usage
## S3 method for class 'Assay5'
merge(x, y, labels = NULL, add.cell.ids = NULL, collapse = FALSE, ...)
Arguments
x |
An |
y |
One or more |
labels |
A character vector equal to the number of objects; defaults to
|
add.cell.ids |
A character vector equal to the number of objects
provided to append to all cell names; if |
collapse |
If |
... |
Ignored |
Details
Note: collapsing layers is currently not supported
Value
A new v5 assay with data merged from c(x, y)
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
split.Assay5()
,
subset.Assay5()
Merge Dimensional Reductions
Description
Merge two or more dimensional reduction together
Usage
## S3 method for class 'DimReduc'
merge(x = NULL, y = NULL, add.cell.ids = NULL, ...)
Arguments
x |
A |
y |
One or more |
add.cell.ids |
A character vector equal to the number of objects
provided to append to all cell names; if |
... |
Ignored |
Value
A new DimReduc
object with data merged from c(x, y)
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Merge Seurat Objects
Description
Merge Seurat Objects
Usage
## S3 method for class 'Seurat'
merge(
x = NULL,
y = NULL,
add.cell.ids = NULL,
collapse = FALSE,
merge.data = TRUE,
merge.dr = FALSE,
project = getOption(x = "Seurat.object.project", default = "SeuratProject"),
...
)
Arguments
x |
A |
y |
A single |
add.cell.ids |
A character vector of |
collapse |
If |
merge.data |
Merge the data slots instead of just merging the counts (which requires renormalization); this is recommended if the same normalization approach was applied to all objects |
merge.dr |
Choose how to handle merging dimensional reductions:
|
project |
Project name for the |
... |
Arguments passed to other methods |
Value
merge
: Merged object
Merge Details
When merging Seurat objects, the merge procedure will merge the Assay level
counts and potentially the data slots (depending on the merge.data parameter).
It will also merge the cell-level meta data that was stored with each object
and preserve the cell identities that were active in the objects pre-merge.
The merge will optionally merge reductions depending on the values passed to
merge.dr
if they have the same name across objects. Here the
embeddings slots will be merged and if there are differing numbers of
dimensions across objects, only the first N shared dimensions will be merged.
The feature loadings slots will be filled by the values present in the first
object.The merge will not preserve graphs, logged commands, or feature-level
metadata that were present in the original objects. If add.cell.ids isn't
specified and any cell names are duplicated, cell names will be appended
with _X, where X is the numeric index of the object in c(x, y).
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
names.Seurat()
,
subset.Seurat()
Examples
# `merge' examples
# merge two objects
merge(pbmc_small, y = pbmc_small)
# to merge more than two objects, pass one to x and a list of objects to y
merge(pbmc_small, y = c(pbmc_small, pbmc_small))
Merge Assays
Description
Merge one or more v5 assays together
Usage
## S3 method for class 'StdAssay'
merge(x, y, labels = NULL, add.cell.ids = NULL, collapse = FALSE, ...)
Arguments
x |
An |
y |
One or more |
labels |
A character vector equal to the number of objects; defaults to
|
add.cell.ids |
A character vector equal to the number of objects
provided to append to all cell names; if |
collapse |
If |
... |
Ignored |
Details
Note: collapsing layers is currently not supported
Value
A new v5 assay with data merged from c(x, y)
Note
All assays must be of the same type; merging different v5 assays (eg.
Assay5
and Assay5T
) is currently unsupported
Subobject Names
Description
Get the names of subobjects within a Seurat
object
Usage
## S3 method for class 'Seurat'
names(x)
Arguments
x |
A |
Value
The names of all of the following subobjects within x
:
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
subset.Seurat()
Examples
names(pbmc_small)
Original double-bracket assign
Description
This function has been replaced with value-specific double-bracket assign methods and should generally not be called
Usage
## S4 replacement method for signature 'Seurat,character,ANY,ANY'
x[[i, j, ...]] <- value
Arguments
x |
A |
i |
The name to store a subobject or various cell-level meta data as |
value |
New subobject or cell-level meta data |
Value
x
with value
stored as i
See Also
See here for adding metadata with [[<-
, and
here for removing subobjects and cell-level meta
data with [[<-
A small example version of the PBMC dataset
Description
A subsetted version of 10X Genomics' 3k PBMC dataset
Usage
pbmc_small
Format
A Seurat object with the following slots filled
- assays
-
Currently only contains one assay ("RNA" - scRNA-seq expression data)
counts - Raw expression data
data - Normalized expression data
scale.data - Scaled expression data
var.features - names of the current features selected as variable
meta.features - Assay level metadata such as mean and variance
- meta.data
Cell level metadata
- active.assay
Current default assay
- active.ident
Current default idents
- graphs
Neighbor graphs computed, currently stores the SNN
- reductions
Dimensional reductions: currently PCA and tSNE
- version
Seurat version used to create the object
- commands
Command history
Source
https://support.10xgenomics.com/single-cell-gene-expression/datasets/1.1.0/pbmc3k
Print Top Feature Loadings
Description
Prints a set of features that most strongly define a set of components; note: requires feature loadings to be present in order to work
Usage
## S3 method for class 'DimReduc'
print(x, dims = 1:5, nfeatures = 20, projected = FALSE, ...)
Arguments
x |
A |
dims |
Number of dimensions to display |
nfeatures |
Number of genes to display |
projected |
Use projected slot |
... |
Ignored |
Value
Displays set of features defining the components and
invisibly returns x
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
subset.DimReduc()
Examples
pca <- pbmc_small[["pca"]]
print(pca)
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- future
- generics
- progressr
S4/List Conversion
Description
Convert S4 objects to lists and vice versa. Useful for declassing an S4
object while keeping track of it's class using attributes (see section
S4 Class Definition Attributes below for more details). Both
ListToS4
and S4ToList
are recursive functions, affecting
all lists/S4 objects contained as sub-lists/sub-objects
Usage
S4ToList(object)
IsS4List(x)
ListToS4(x)
## Default S3 method:
S4ToList(object)
## S3 method for class 'list'
S4ToList(object)
Arguments
object |
An S4 object |
x |
A list with an S4 class definition
(“ |
Value
S4ToList
: A list with an S4 class definition attribute
IsS4List
: TRUE
if x
is a list with an S4 class
definition attribute
ListToS4
: An S4 object as defined by the S4 class definition
attribute
S4 Class Definition Attributes
S4 classes are scoped to the package and class name. In order to properly
track which class a list is generated from in order to build a new one,
these function use an attribute
to denote the
class name and package of origin. This attribute is stored as 1-length
character vector named “classDef
” and takes the form
of “package:class
”
See Also
ClassKey()
Examples
# Turn an S4 object into a list
pbmc.list <- S4ToList(pbmc_small)
class(pbmc.list)
attributes(pbmc.list)
str(pbmc.list$reductions)
IsS4List(pbmc.list)
pbmc2 <- ListToS4(pbmc.list)
pbmc2
class(pbmc2)
Reductions(pbmc2)
validObject(pbmc2)
Set If or If Not NA
Description
Set a default value depending on if an object is NA
Usage
x %NA% y
x %na% y
x %!NA% y
x %!na% y
Arguments
x |
An object to test |
y |
A default value |
Value
For %NA%
: y
if x
is NA
;
otherwise x
For %!NA%
: y
if x
is not
NA
; otherwise x
Examples
# Set if NA
1 %NA% 2
NA %NA% 2
# Set if *not* NA
1 %!NA% 2
NA %!NA% 2
Set If or If Not NULL
Description
Set a default value depending on if an object is NULL
Usage
x %||% y
x %iff% y
Arguments
x |
An object to test |
y |
A default value |
Value
For %||%
: y
if x
is NULL
;
otherwise x
For %iff%
: y
if x
is not
NULL
; otherwise x
Author(s)
For %||%
: rlang developers
See Also
Examples
# Set if NULL
1 %||% 2
NULL %||% 2
# Set if *not* NULL
1 %iff% 2
NULL %iff% 2
The Seurat Class
Description
The Seurat object is the center of each single cell analysis. It stores all information associated with the dataset, including data, annotations, analyses, etc. All that is needed to construct a Seurat object is an expression matrix (rows are genes, columns are cells), which should be log-scale
Details
Each Seurat object has a number of slots which store information. Key slots to access are listed below.
Slots
raw.data
The raw project data
data
The normalized expression matrix (log-scale)
scale.data
scaled (default is z-scoring each gene) expression matrix; used for dimensional reduction and heatmap visualization
var.genes
Vector of genes exhibiting high variance across single cells
is.expr
Expression threshold to determine if a gene is expressed (0 by default)
ident
THe 'identity class' for each cell
meta.data
Contains meta-information about each cell, starting with number of genes detected (nFeature) and the original identity class (orig.ident); more information is added using
AddMetaData
project.name
Name of the project (for record keeping)
dr
List of stored dimensional reductions; named by technique
assay
List of additional assays for multimodal analysis; named by technique
hvg.info
The output of the mean/variability analysis for all genes
imputed
Matrix of imputed gene scores
cell.names
Names of all single cells (column names of the expression matrix)
cluster.tree
List where the first element is a phylo object containing the phylogenetic tree relating different identity classes
snn
Spare matrix object representation of the SNN graph
calc.params
Named list to store all calculation-related parameter choices
kmeans
Stores output of gene-based clustering from
DoKMeans
spatial
Stores internal data and calculations for spatial mapping of single cells
misc
Miscellaneous spot to store any data alongside the object (for example, gene lists)
version
Version of package used in object creation
V3 Assay Overview
Description
Overview of an Assay
object
Usage
## S4 method for signature 'Assay'
show(object)
Value
Prints summary to stdout
and invisibly
returns NULL
See Also
Examples
rna <- pbmc_small[["RNA"]]
rna
Dimensional Reduction Overview
Description
Overview of a DimReduc
object
Usage
## S4 method for signature 'DimReduc'
show(object)
Arguments
object |
A dimensional reduction |
Value
Prints summary to stdout
and invisibly
returns NULL
See Also
Examples
pca <- pbmc_small[["pca"]]
pca
Graph Object Overview
Description
Overview of a Graph
Object
Usage
## S4 method for signature 'Graph'
show(object)
Value
Prints summary to stdout
and invisibly
returns NULL
Examples
pbmc_small[["RNA_snn"]]
LogMap
Object Overview
Description
Overview of a LogMap
object
Usage
## S4 method for signature 'LogMap'
show(object)
Arguments
object |
A |
Value
Prints summary to stdout
and invisibly
returns NULL
Seurat Object Overview
Description
Overview of a Seurat
object
Usage
## S4 method for signature 'Seurat'
show(object)
Value
Prints summary to stdout
and invisibly
returns NULL
Examples
pbmc_small
Command Log Overview
Description
Overview of a SeuratCommand
object
Usage
## S4 method for signature 'SeuratCommand'
show(object)
Value
Prints summary to stdout
and invisibly
returns NULL
Examples
cmd <- pbmc_small[["NormalizeData.RNA"]]
cmd
V5 Assay Overview
Description
Overview of a StdAssay
object
Usage
## S4 method for signature 'StdAssay'
show(object)
Arguments
object |
A v5 Assay |
Value
Prints summary to stdout
and invisibly
returns NULL
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
split.StdAssay()
,
subset.StdAssay()
Old Seurat Object Overview
Description
Overview of a seurat
object overview
Usage
## S4 method for signature 'seurat'
show(object)
Arguments
object |
An old seurat object |
Value
Prints summary to stdout
and invisibly
returns NULL
Split an Assay
Description
Split an Assay
Usage
## S3 method for class 'Assay'
split(x, f, drop = FALSE, layers = NA, ...)
Arguments
x |
An |
f |
a ‘factor’ in the sense that |
drop |
logical indicating if levels that do not occur should be dropped
(if |
layers |
Names of layers to include in the split; pass |
... |
Ignored |
Value
Returns a v5 assay with splitted layers
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
subset.Assay()
Split an Assay
Description
Split an Assay
Usage
## S3 method for class 'Assay5'
split(
x,
f,
drop = FALSE,
layers = c("counts", "data"),
ret = c("assay", "multiassays", "layers"),
...
)
Arguments
x |
An |
f |
a ‘factor’ in the sense that |
drop |
logical indicating if levels that do not occur should be dropped
(if |
layers |
Names of layers to include in the split; pass |
ret |
Type of return value; choose from: |
... |
Ignored |
Value
Depends on the value of ret
:
-
“
assay
”:x
with the layers requested inlayers
split based onf
; all other layers are left as-is -
“
multiassay
”: a list ofAssay5
objects; the list contains one value per split and each assay contains only the layers requested inlayers
with the key set to the split -
“
layers
”: a list of matrices of lengthlength(assays) * length(unique(f))
; the list is named as “layer.split
”
Progress Updates with progressr
This function uses
progressr to
render status updates and progress bars. To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
subset.Assay5()
Split an Assay
Description
Split an Assay
Usage
## S3 method for class 'Seurat'
split(x, f, drop = FALSE, assay = NULL, layers = NA, ...)
Arguments
x |
An |
f |
a ‘factor’ in the sense that |
drop |
logical indicating if levels that do not occur should be dropped
(if |
layers |
Names of layers to include in the split; pass |
... |
Ignored |
Value
Depends on the value of ret
:
-
“
assay
”:x
with the layers requested inlayers
split based onf
; all other layers are left as-is -
“
multiassay
”: a list ofAssay5
objects; the list contains one value per split and each assay contains only the layers requested inlayers
with the key set to the split -
“
layers
”: a list of matrices of lengthlength(assays) * length(unique(f))
; the list is named as “layer.split
”
Progress Updates with progressr
This function uses
progressr to
render status updates and progress bars. To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
Split an Assay
Description
Split an Assay
Usage
## S3 method for class 'StdAssay'
split(
x,
f,
drop = FALSE,
layers = c("counts", "data"),
ret = c("assay", "multiassays", "layers"),
...
)
## S4 method for signature 'StdAssay'
split(
x,
f,
drop = FALSE,
layers = c("counts", "data"),
ret = c("assay", "multiassays", "layers"),
...
)
Arguments
x |
An |
f |
a ‘factor’ in the sense that |
drop |
logical indicating if levels that do not occur should be dropped
(if |
layers |
Names of layers to include in the split; pass |
ret |
Type of return value; choose from: |
... |
Ignored |
Value
Depends on the value of ret
:
-
“
assay
”:x
with the layers requested inlayers
split based onf
; all other layers are left as-is -
“
multiassay
”: a list ofAssay5
objects; the list contains one value per split and each assay contains only the layers requested inlayers
with the key set to the split -
“
layers
”: a list of matrices of lengthlength(assays) * length(unique(f))
; the list is named as “layer.split
”
Progress Updates with progressr
This function uses
progressr to
render status updates and progress bars. To enable progress updates, wrap
the function call in with_progress
or run
handlers(global = TRUE)
before running
this function. For more details about progressr, please read
vignette("progressr-intro")
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
subset.StdAssay()
Subset an Assay
Description
Subset an Assay
Usage
## S3 method for class 'Assay'
subset(x, cells = NULL, features = NULL, ...)
Arguments
x |
An |
cells |
Cell names |
features |
Feature names |
... |
Ignored |
Value
x
with just the cells and features specified by
cells
and features
See Also
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
Examples
rna <- pbmc_small[["RNA"]]
rna2 <- subset(rna, features = VariableFeatures(rna))
rna2
Subset an Assay
Description
Subset an Assay
Usage
## S3 method for class 'Assay5'
subset(x, cells = NULL, features = NULL, layers = NULL, ...)
Arguments
x |
An |
cells |
Cell names |
features |
Feature names |
layers |
Layer to keep; defaults to all layers |
... |
Ignored |
Value
x
with just the cells and features specified by
cells
and features
for the layers specified by layers
See Also
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
Subset a Dimensional Reduction
Description
Subset a DimReduc
object
Usage
## S3 method for class 'DimReduc'
subset(x, cells = NULL, features = NULL, ...)
Arguments
x |
A |
cells , features |
Cells and features to keep during the subset |
... |
Ignored |
Value
x
for cells cells
and features features
See Also
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
Subset Seurat
Objects
Description
Subset Seurat
Objects
Usage
## S3 method for class 'Seurat'
subset(
x,
subset,
cells = NULL,
features = NULL,
idents = NULL,
return.null = FALSE,
...
)
## S3 method for class 'Seurat'
x[i, j, ...]
Arguments
x |
A |
subset |
Logical expression indicating features/variables to keep |
cells , j |
A vector of cell names or indices to keep |
features , i |
A vector of feature names or indices to keep |
idents |
A vector of identity classes to keep |
return.null |
If no cells are requested, return a |
... |
Arguments passed to |
Value
subset
: A subsetted Seurat
object
[
: object x
with features i
and cells j
See Also
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
Examples
# `subset` examples
subset(pbmc_small, subset = MS4A1 > 4)
subset(pbmc_small, subset = `DLGAP1-AS1` > 2)
subset(pbmc_small, idents = '0', invert = TRUE)
subset(pbmc_small, subset = MS4A1 > 3, slot = 'counts')
subset(pbmc_small, features = VariableFeatures(object = pbmc_small))
# `[` examples
pbmc_small[VariableFeatures(object = pbmc_small), ]
pbmc_small[, 1:10]
Subset an Assay
Description
Subset an Assay
Usage
## S3 method for class 'StdAssay'
subset(x, cells = NULL, features = NULL, layers = NULL, ...)
Arguments
x |
An |
cells |
Cell names |
features |
Feature names |
layers |
Layer to keep; defaults to all layers |
... |
Ignored |
Value
x
with just the cells and features specified by
cells
and features
for the layers specified by layers
See Also
v5 Standard Assay object, validity, and interaction methods
$.StdAssay()
,
.DollarNames.StdAssay()
,
StdAssay-class
,
StdAssay-validity
,
[.StdAssay()
,
[[.StdAssay()
,
dim.StdAssay()
,
dimnames.StdAssay()
,
show,StdAssay-method
,
split.StdAssay()
V5 Assay Summaries
Description
Summary maths for StdAssay
Objects
Usage
## S4 method for signature 'StdAssay'
colMeans(x, na.rm = FALSE, dims = 1, layer = NULL, ...)
## S4 method for signature 'StdAssay'
colSums(x, na.rm = FALSE, dims = 1, layer = NULL, ...)
## S4 method for signature 'StdAssay'
rowMeans(x, na.rm = FALSE, dims = 1, layer = NULL, ...)
## S4 method for signature 'StdAssay'
rowSums(x, na.rm = FALSE, dims = 1, layer = NULL, ...)
Arguments
x |
an array of two or more dimensions, containing numeric,
complex, integer or logical values, or a numeric data frame. For
|
na.rm |
logical. Should missing values (including |
dims |
integer: Which dimensions are regarded as ‘rows’ or
‘columns’ to sum over. For |
layer |
Name of layer to run function on |
... |
Ignored |
Value
The results of the summary math function for the layer specified