Title: | 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. |
Authors: | Paul Hoffman [aut] , Rahul Satija [aut, cre] , David Collins [aut] , Yuhan Hao [aut] , Austin Hartman [aut] , Gesmira Molla [aut] , Andrew Butler [aut] , Tim Stuart [aut] , Madeline Kowalski [ctb] , Saket Choudhary [ctb] , Skylar Li [ctb], Longda Jiang [ctb] , Jeff Farrell [ctb], Shiwei Zheng [ctb] , Christoph Hafemeister [ctb] , Patrick Roelli [ctb] |
Maintainer: | Rahul Satija <[email protected]> |
License: | MIT + file LICENSE |
Version: | 5.0.2 |
Built: | 2024-11-04 05:27:38 UTC |
Source: | https://github.com/satijalab/seurat-object |
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.
Maintainer: Rahul Satija [email protected] (ORCID)
Authors:
Paul Hoffman [email protected] (ORCID)
David Collins [email protected] (ORCID)
Yuhan Hao [email protected] (ORCID)
Austin Hartman [email protected] (ORCID)
Gesmira Molla [email protected] (ORCID)
Andrew Butler [email protected] (ORCID)
Tim Stuart [email protected] (ORCID)
Other contributors:
Madeline Kowalski [email protected] (ORCID) [contributor]
Saket Choudhary [email protected] (ORCID) [contributor]
Skylar Li [email protected] [contributor]
Longda Jiang [email protected] (ORCID) [contributor]
Jeff Farrell [email protected] [contributor]
Shiwei Zheng [email protected] (ORCID) [contributor]
Christoph Hafemeister [email protected] (ORCID) [contributor]
Patrick Roelli [email protected] [contributor]
Useful links:
Report bugs at https://github.com/satijalab/seurat-object/issues
Autocompletion for $
access on a
SeuratCommand
object
## S3 method for class 'SeuratCommand' .DollarNames(x, pattern = "")
## S3 method for class 'SeuratCommand' .DollarNames(x, pattern = "")
x |
A |
pattern |
A regular expression. Only matching names are returned. |
The parameter name matches for pattern
Command log object and interaction methods
$.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Get and set layer data
## 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
## 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
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 |
[
: The layer data for layer i
[<-
: x
with layer data value
saved as i
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
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]
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]
Get and set layer data
## 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
## 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
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 |
[
: The layer data for layer i
[<-
: x
with layer data value
saved as i
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Pull feature loadings from a dimensional reduction
## S3 method for class 'DimReduc' x[i, j, drop = FALSE, ...]
## S3 method for class 'DimReduc' x[i, j, drop = FALSE, ...]
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 |
[
does not distinguish between projected and unprojected feature
loadings; to select whether projected or unprojected loadings should be
pulled, please use Loadings
Feature loadings for features i
and dimensions j
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
pca <- pbmc_small[["pca"]] pca[1:10, 1:5]
pca <- pbmc_small[["pca"]] pca[1:10, 1:5]
Access data from a SeuratCommand
object
## S3 method for class 'SeuratCommand' x[i, ...]
## S3 method for class 'SeuratCommand' x[i, ...]
x |
A |
i |
The name of a command log slot |
... |
Ignored |
[
: Slot i
from x
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
as.list.SeuratCommand()
cmd <- pbmc_small[["NormalizeData.RNA"]] cmd["call.string"]
cmd <- pbmc_small[["NormalizeData.RNA"]] cmd["call.string"]
Get and set feature-level meta data
## 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
## 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
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 |
[[
: 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
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
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)
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)
Get and set feature-level meta data
## 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, ...)
## 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, ...)
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 |
[[
: 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
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Pull cell embeddings from a dimensional reduction
## S3 method for class 'DimReduc' x[[i, j, drop = FALSE, ...]]
## S3 method for class 'DimReduc' x[[i, j, drop = FALSE, ...]]
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 |
Cell embeddings for cells i
and dimensions j
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
pca <- pbmc_small[["pca"]] pca[[1:10, 1:5]]
pca <- pbmc_small[["pca"]] pca[[1:10, 1:5]]
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
## 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, ...)
## 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, ...)
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 |
Varies based on the value of i
:
If i
is missing, a data frame with cell-level meta data
If i
is a vector with cell-level meta data names, a data frame
(or vector of drop = TRUE
) with cell-level meta data requested
If i
is a one-length character with the
name of a subobject, the
subobject specified by i
head
: The first n
rows of cell-level metadata
tail
: The last n
rows of cell-level metadata
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()
# 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)
# 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)
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
## 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
## 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
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) |
x
with value
added as i
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
## S4 replacement method for signature 'Seurat,character,missing,NULL' x[[i, j, ...]] <- value
## S4 replacement method for signature 'Seurat,character,missing,NULL' x[[i, j, ...]] <- value
x |
A |
i |
Name(s) of subobject(s) or cell-level meta data to remove |
j |
Ignored |
... |
Ignored |
value |
NULL |
x
with i
removed from the object
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()
Get and set layer data
## S3 method for class 'Assay' x$i ## S3 replacement method for class 'Assay' x$i <- value
## S3 method for class 'Assay' x$i ## S3 replacement method for class 'Assay' x$i <- value
x |
An |
i |
Name of layer data to get or set |
value |
A matrix-like object to add as a new layer |
$: Layer data for layer i
$<-
: x
with layer data value
saved as i
v3 Assay object, validity, and interaction methods:
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
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]
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]
Get and set layer data
## S3 method for class 'Assay5' x$i ## S3 replacement method for class 'Assay5' x$i <- value
## S3 method for class 'Assay5' x$i ## S3 replacement method for class 'Assay5' x$i <- value
x |
An |
i |
Name of layer data to get or set |
value |
A matrix-like object to add as a new layer |
$: Layer data for layer i
$<-
: x
with layer data value
saved as i
v5 Assay object, validity, and interaction methods:
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Get and set cell-level meta data
## 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
## 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
x |
A |
i |
Name of cell-level meta data |
... |
Ignored |
value |
A vector to add as cell-level meta data |
j |
Ignored |
$: 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
Seurat object, validity, and interaction methods
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
# 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"]])
# 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"]])
Pull parameter values from a SeuratCommand
object
## S3 method for class 'SeuratCommand' x$i
## S3 method for class 'SeuratCommand' x$i
x |
A |
i |
A parameter name |
The value for parameter i
Command log object and interaction methods
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
cmd <- pbmc_small[["NormalizeData.RNA"]] cmd$normalization.method
cmd <- pbmc_small[["NormalizeData.RNA"]] cmd$normalization.method
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"]]
)
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)
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)
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 |
object
with metadata added
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[[]])
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[[]])
Convert Segmentation Layers
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, ...)
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, ...)
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 |
as.Centroids
: A
Centroids
object
as.Segmentation
: A
Segmentation
object
Graph
ObjectConvert a matrix
(or Matrix
) to
a Graph
object
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, ...)
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, ...)
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 |
A Graph
object
Other graph:
Graph-class
# 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)
# 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)
SeuratCommand
to a listCoerce a SeuratCommand
to a list
## S3 method for class 'SeuratCommand' as.list(x, complete = FALSE, ...)
## S3 method for class 'SeuratCommand' as.list(x, complete = FALSE, ...)
x |
A |
complete |
Include slots besides just parameters (eg. call string, name, timestamp) |
... |
Ignored |
A list with the parameters and, if complete = TRUE
,
the call string, name, and timestamp
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
cmd <- pbmc_small[["NormalizeData.RNA"]] as.list(cmd) as.list(cmd, complete = TRUE)
cmd <- pbmc_small[["NormalizeData.RNA"]] as.list(cmd) as.list(cmd, complete = TRUE)
Coerce a logical map to a matrix; this removes all logical map class capabilities from the object and returns a base-R matrix object
## S3 method for class 'LogMap' as.matrix(x, ...)
## S3 method for class 'LogMap' as.matrix(x, ...)
x |
A |
... |
Ignored |
A base-R matrix created from x
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
map <- LogMap(letters[1:10]) map[['obs']] <- c(1, 3, 7) mat <- as.matrix(map) mat class(mat)
map <- LogMap(letters[1:10]) map[['obs']] <- c(1, 3, 7) mat <- as.matrix(map) mat class(mat)
Neighbor
ObjectConvert objects to Neighbor
objects
as.Neighbor(x, ...) ## S3 method for class 'Graph' as.Neighbor(x, ...)
as.Neighbor(x, ...) ## S3 method for class 'Graph' as.Neighbor(x, ...)
x |
An object to convert to |
... |
Arguments passed to other methods |
A Neighbor
object
Seurat
ObjectConvert objects to Seurat objects
as.Seurat(x, ...)
as.Seurat(x, ...)
x |
An object to convert to class |
... |
Arguments passed to other methods |
A Seurat
object generated from x
Convert dense objects to sparse representations
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, ...)
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, ...)
x |
An object |
... |
Arguments passed to other methods |
row.names |
|
A sparse representation of the input data
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.
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]*_$
”)
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
Validation of Assay
objects is handled by
validObject
data
Validationblah
counts
Validationblah
scale.data
Validationblah
blah
blah
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “''
”) where nchar() == 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]*_$
”
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
rna <- pbmc_small[["RNA"]] validObject(rna)
rna <- pbmc_small[["RNA"]] validObject(rna)
Assay
ObjectThe v5 Assay
is the typical Assay
class used in Seurat
v5; ...
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
and features
slots. Cell and feature
membership is recorded in the cells
and features
slots,
respectively
cells
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]*_$
”)
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
Validation of Assay5
objects is handled by
validObject
blah
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “''
”) where nchar() == 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]*_$
”
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
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
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(), ... )
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(), ... )
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 |
GetAssayData
: returns the specified assay data
SetAssayData
: object
with the assay data set
GetAssayData
and SetAssayData
have been superseded. To fetch
expression matrices, use LayerData
; to set expression data,
use LayerData<-
# 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 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)
List the names of Assay
, DimReduc
,
Graph
, Neighbor
objects
Assays(object, ...) Graphs(object, slot = NULL) Neighbors(object, slot = NULL) Reductions(object, slot = NULL) ## S3 method for class 'Seurat' Assays(object, slot = deprecated(), ...)
Assays(object, ...) Graphs(object, slot = NULL) Neighbors(object, slot = NULL) Reductions(object, slot = NULL) ## S3 method for class 'Seurat' Assays(object, slot = deprecated(), ...)
object |
A |
... |
Ignored |
slot |
Name of component object to return |
If slot
is NULL
, the names of all component objects
in this Seurat
object. Otherwise, the specific object specified
Assays(pbmc_small) Graphs(pbmc_small) Reductions(object = pbmc_small)
Assays(pbmc_small) Graphs(pbmc_small) Reductions(object = pbmc_small)
Helper function to attach required packages. Detects if a package is already
attached and if so, skips it. Should be called in .onAttach
AttachDeps(deps)
AttachDeps(deps)
deps |
A character vector of packages to attach |
Invisibly returns NULL
AttachDeps
has been superseded as of SeuratObject v5.0.0;
as an alternative, list dependencies in the Depends
section of
DESCRIPTION
# Use in your .onAttach hook if (FALSE) { .onAttach <- function(libname, pkgname) { AttachDeps(c("SeuratObject", "rlang")) } }
# Use in your .onAttach hook if (FALSE) { .onAttach <- function(libname, pkgname) { AttachDeps(c("SeuratObject", "rlang")) } }
Get, Set, and Query Segmentation Boundaries
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, ...)
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, ...)
object |
An object |
... |
Arguments passed to other methods |
value |
The name of a segmentation boundary to set as default |
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 layers in v5 assays to other classes
CastAssay(object, to, ...) ## S3 method for class 'Assay5' CastAssay(object, to, layers = NA, verbose = TRUE, ...)
CastAssay(object, to, ...) ## S3 method for class 'Assay5' CastAssay(object, to, layers = NA, verbose = TRUE, ...)
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 |
object
with the layers cast to class specified by to
Get the cell and feature names of an object
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, ...)
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, ...)
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
|
Cell
: A vector of cell names
Features
: A vector of feature names
dimnames.Assay()
,
dimnames.Assay5()
,
dimnames.Seurat()
Cells(x = pbmc_small)
Cells(x = pbmc_small)
Get cell names grouped by identity class
CellsByIdentities(object, idents = NULL, cells = NULL, return.null = FALSE)
CellsByIdentities(object, idents = NULL, cells = NULL, return.null = FALSE)
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 |
A named list where names are identity classes and values are vectors of cells belonging to that class
CellsByIdentities(object = pbmc_small)
CellsByIdentities(object = pbmc_small)
Get a vector of cell names associated with an image (or set of images)
CellsByImage(object, images = NULL, unlist = FALSE)
CellsByImage(object, images = NULL, unlist = FALSE)
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. |
A vector of cell names
## Not run: CellsByImage(object = object, images = "slice1") ## End(Not run)
## Not run: CellsByImage(object = object, images = "slice1") ## End(Not run)
Centroids
ClassThe Centroids
Class
cells
(character [n]
) A vector of cell
names; there should be as many cell names as there are points and no
duplicate names
nsides
(integer [1L]
) The number of sides
to draw when plotting centroids; must be either 0L
for circles or
greater than 3
radius
(numeric [1L]
) The radius of the
shape when plotting the centroids
theta
(numeric [1L]
) The angle in degrees
to adjust the shape when plotting the centroids
Centroids
methods: Centroids-methods
Segmentation layer classes:
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Centroids
MethodsMethods for Centroids
objects
## 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)
## 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)
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 |
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
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
Segmentation layer classes:
Centroids-class
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Call gc
only when desired
CheckGC(option = "SeuratObject.memsafe")
CheckGC(option = "SeuratObject.memsafe")
option |
... |
Invisibly returns NULL
Check layers names for the input list
CheckLayersName(matrix.list, layers.type = c("counts", "data"))
CheckLayersName(matrix.list, layers.type = c("counts", "data"))
matrix.list |
A list of matrices |
layers.type |
layers type, such as counts or data |
Pull information on previously run commands in the Seurat object.
Command(object, ...) ## S3 method for class 'Seurat' Command(object, command = NULL, value = NULL, ...)
Command(object, ...) ## S3 method for class 'Seurat' Command(object, command = NULL, value = NULL, ...)
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 |
Either a SeuratCommand object or the requested parameter value
Create an Assay5
object from a feature expression matrix;
the expected format of the matrix is features x cells
CreateAssay5Object( counts = NULL, data = NULL, min.cells = 0, min.features = 0, csum = NULL, fsum = NULL, ... )
CreateAssay5Object( counts = NULL, data = NULL, min.cells = 0, min.features = 0, csum = NULL, fsum = NULL, ... )
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 |
An Assay5
object
Create an Assay object from a feature (e.g. gene) expression matrix. The expected format of the input matrix is features x cells.
CreateAssayObject( counts, data, min.cells = 0, min.features = 0, key = NULL, check.matrix = FALSE, ... )
CreateAssayObject( counts, data, min.cells = 0, min.features = 0, key = NULL, check.matrix = FALSE, ... )
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 |
Non-unique cell or feature names are not allowed. Please make unique before calling this function.
A Assay
object
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
## 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)
## 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)
Centroids
ObjectsCreate a Centroids
Objects
CreateCentroids(coords, nsides, radius, theta)
CreateCentroids(coords, nsides, radius, theta)
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 |
A Centroids
object
Create a DimReduc object
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() )
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() )
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 |
A DimReduc
object
Dimensional reduction object, validity, and interaction methods
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
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" )
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
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, ... )
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, ... )
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 |
A FOV
object
Molecules
ObjectCreate a Molecules
Object
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, ...)
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, ...)
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 |
A Molecules
object
Segmentation
ObjectsCreate a Segmentation
Objects
CreateSegmentation(coords) ## S3 method for class 'data.frame' CreateSegmentation(coords) ## S3 method for class 'Segmentation' CreateSegmentation(coords)
CreateSegmentation(coords) ## S3 method for class 'data.frame' CreateSegmentation(coords) ## S3 method for class 'Segmentation' CreateSegmentation(coords)
coords |
The coordinates of cell segmentations |
A Segmentation
object
Seurat
objectCreate a Seurat
object from raw data
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", ... )
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", ... )
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 |
A Seurat
object
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.
## 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)
## 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
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"), ...)
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"), ...)
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 |
object
cropped to the region specified by x
and y
Get and set the default assay
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
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
object |
An object |
... |
Arguments passed to other methods |
value |
Name of assay to set as default |
DefaultAssay
: The name of the default assay
DefaultAssay<-
: An object with the default assay updated
# 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)
# 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)
DimReduc
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)
DefaultDimReduc(object, assay = NULL)
DefaultDimReduc(object, assay = NULL)
object |
A |
assay |
Name of assay to use; defaults to the default assay of the object |
The default DimReduc
, if possible
DefaultDimReduc(pbmc_small)
DefaultDimReduc(pbmc_small)
Get and Set the Default FOV
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
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
object |
A |
... |
Arguments passed to other methods |
value |
The name of the |
assay |
Name of assay to get or set default |
DefaultFOV
: The name of the default FOV
DefaultFOV<-
: object
with the default FOV set
to value
Get and set the default layer
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
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
object |
An object |
... |
Arguments passed to other methods |
value |
Name of layer to set as default |
DefaultLayer
: The name of the default layer
DefaultLayer<-
: An object with the default layer updated
Feature and Cell Numbers
## S3 method for class 'Assay' dim(x)
## S3 method for class 'Assay' dim(x)
x |
An |
A two-length numeric vector with the total number of
features and cells in x
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
,
subset.Assay()
rna <- pbmc_small[["RNA"]] dim(rna)
rna <- pbmc_small[["RNA"]] dim(rna)
Feature and Cell Numbers
## S3 method for class 'Assay5' dim(x)
## S3 method for class 'Assay5' dim(x)
x |
An |
A two-length numeric vector with the total number of
features and cells in x
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
,
subset.Assay5()
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
)
## 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)
## 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)
x |
A |
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
Cells
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
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))
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
## S3 method for class 'Seurat' dim(x)
## S3 method for class 'Seurat' dim(x)
x |
A |
A two-length numeric vector with the total number of
features and cells in x
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
# Get the number of features in an object nrow(pbmc_small) # Get the number of cells in an object ncol(pbmc_small)
# Get the number of features in an object nrow(pbmc_small) # Get the number of cells in an object ncol(pbmc_small)
Get and set feature and cell names in v5 Assays
## S3 method for class 'Assay' dimnames(x) ## S3 replacement method for class 'Assay' dimnames(x) <- value
## S3 method for class 'Assay' dimnames(x) ## S3 replacement method for class 'Assay' dimnames(x) <- value
x |
An |
value |
A two-length list where the first entry is the existing feature
names for |
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]]
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()
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))
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))
Get and set feature and cell names in v5 Assays
## S3 method for class 'Assay5' dimnames(x) ## S3 replacement method for class 'Assay5' dimnames(x) <- value
## S3 method for class 'Assay5' dimnames(x) ## S3 replacement method for class 'Assay5' dimnames(x) <- value
x |
An |
value |
A two-length list with updated feature and/or cells names |
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
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()
Get and set feature and cell inames in Seurat
objects
## S3 method for class 'Seurat' dimnames(x) ## S3 replacement method for class 'Seurat' dimnames(x) <- value
## S3 method for class 'Seurat' dimnames(x) ## S3 replacement method for class 'Seurat' dimnames(x) <- value
x |
A |
value |
A two-length list with updated feature and/or cells names |
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
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()
# 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))
# 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))
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.
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
object
global
Is this DimReduc
global/persistent? If so, it will not be
removed when removing its associated assay
stdev
A vector of standard deviations
jackstraw
A JackStrawData-class
object associated with
this DimReduc
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]*_$
”)
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Validation of DimReduc
objects is handled by
validObject
The cell embeddings matrix must be a numeric matrix of dimensions
by
; 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
blah
blah
Keys must be a one-length character vector; a key must be composed of one of the following:
An empty string (eg. “''
”) where nchar() == 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]*_$
”
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
Distances(object, ...) ## S3 method for class 'Neighbor' Distances(object, ...)
Distances(object, ...) ## S3 method for class 'Neighbor' Distances(object, ...)
object |
An object |
... |
Arguments passed to other methods |
The distance matrix
Remove any unused values from a logical map
## S3 method for class 'LogMap' droplevels(x, ...)
## S3 method for class 'LogMap' droplevels(x, ...)
x |
A |
... |
Ignored |
x
with values not present in any
observation removed
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
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[[]]
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[[]]
Get Cell Embeddings
Embeddings(object, ...) ## S3 method for class 'DimReduc' Embeddings(object, ...) ## S3 method for class 'Seurat' Embeddings(object, reduction = "pca", ...)
Embeddings(object, ...) ## S3 method for class 'DimReduc' Embeddings(object, ...) ## S3 method for class 'Seurat' Embeddings(object, reduction = "pca", ...)
object |
An object |
... |
Arguments passed to other methods |
reduction |
Name of reduction to pull cell embeddings for |
The embeddings matrix
# 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]
# 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]
Create empty 0x0 matrices of varying types
EmptyMatrix(repr = "C", type = "d")
EmptyMatrix(repr = "C", type = "d")
repr |
Representation of empty matrix; choose from:
|
type |
Type of resulting matrix to return, choose from:
Note, when |
A 0x0 matrix of the specified representation and type
EmptyMatrix() EmptyMatrix("spam")
EmptyMatrix() EmptyMatrix("spam")
Retrieves data (feature expression, PCA scores, metrics, etc.) for a set of cells in a Seurat object
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(), ... )
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(), ... )
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 |
A data frame with cells as rows and cellular data as columns
pc1 <- FetchData(object = pbmc_small, vars = 'PC_1') head(x = pc1) head(x = FetchData(object = pbmc_small, vars = c('groups', 'ident')))
pc1 <- FetchData(object = pbmc_small, vars = 'PC_1') head(x = pc1) head(x = FetchData(object = pbmc_small, vars = c('groups', 'ident')))
Get the names of objects within a Seurat
object that are of a
certain class
FilterObjects(object, classes.keep = c("Assay", "StdAssay", "DimReduc"))
FilterObjects(object, classes.keep = c("Assay", "StdAssay", "DimReduc"))
object |
A |
classes.keep |
A vector of names of classes to get |
A vector with the names of objects within the Seurat
object
that are of class classes.keep
FilterObjects
was deprecated in version 5.0.0; use .FilterObjects
instead
FilterObjects(pbmc_small)
FilterObjects(pbmc_small)
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
molecules
A named list of
Molecules
objects defining
spatially-resolved molecular coordinates
boundaries
A named list of
Segmentation
and
Centroids
objects defining
spatially-resolved boundaries
assay
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]*_$
”)
FOV
MethodsMethods for FOV
objects
## 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)
## 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)
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 |
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
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
is NULL
, returns x
with the boundary
i
removed; also allows removing molecules
; does not allow
removing the default segmentation
If value
is a Molecules
, returns x
with
value
stored in molecules
; requires that i
is
“molecules”
Otherwise, stores value
as a segmentation boundary named i
show
: Invisibly returns NULL
Validation of FOV
objects is handled by
validObject
blah
blah
Get image data
GetImage(object, mode = c("grob", "raster", "plotly", "raw"), ...) ## S3 method for class 'Seurat' GetImage( object, mode = c("grob", "raster", "plotly", "raw"), image = NULL, ... )
GetImage(object, mode = c("grob", "raster", "plotly", "raw"), ...) ## S3 method for class 'Seurat' GetImage( object, mode = c("grob", "raster", "plotly", "raw"), image = NULL, ... )
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 |
Image data, varying depending on the value of mode
:
An object representing image data inheriting from grob
objects
(eg. rastergrob
)
An object of class raster
A list with image data suitable for Plotly rendering, see
plotly::layout
for more details
The raw image data as stored in the object
Get tissue coordinates
GetTissueCoordinates(object, ...) ## S3 method for class 'Seurat' GetTissueCoordinates(object, image = NULL, ...)
GetTissueCoordinates(object, ...) ## S3 method for class 'Seurat' GetTissueCoordinates(object, image = NULL, ...)
object |
An object |
... |
Arguments passed to other methods |
image |
Name of |
A data frame with tissue coordinates
The Graph class inherits from dgCMatrix
.
We do this to enable future expandability of graphs.
assay.used
Optional name of assay used to generate Graph
object
Other graph:
as.Graph()
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
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 = NULL, strip = TRUE, ...) ## S3 method for class 'Assay5' VariableFeatures( object, method = NULL, layer = NA, simplify = TRUE, nfeatures = Inf, selection.method = deprecated(), ... ) ## S3 replacement method for class 'Assay5' VariableFeatures(object, method = "custom", layer = NULL, ...) <- value
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 = NULL, strip = TRUE, ...) ## S3 method for class 'Assay5' VariableFeatures( object, method = NULL, layer = NA, simplify = TRUE, nfeatures = Inf, selection.method = deprecated(), ... ) ## S3 replacement method for class 'Assay5' VariableFeatures(object, method = "custom", layer = NULL, ...) <- value
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 |
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 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 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
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
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 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 |
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
# 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)
# 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)
List the names of SpatialImage
objects present in a Seurat
object. If assay
is provided, limits search to images associated with
that assay
Images(object, assay = NULL)
Images(object, assay = NULL)
object |
A |
assay |
Name of assay to limit search to |
A list of image names
## Not run: Images(object) ## End(Not run)
## Not run: Images(object) ## End(Not run)
Get Neighbor algorithm index
Index(object, ...) Index(object, ...) <- value ## S3 method for class 'Neighbor' Index(object, ...) ## S3 replacement method for class 'Neighbor' Index(object, ...) <- value
Index(object, ...) Index(object, ...) <- value ## S3 method for class 'Neighbor' Index(object, ...) ## S3 replacement method for class 'Neighbor' Index(object, ...) <- value
object |
An object |
... |
Arguments passed to other methods |
value |
The index to store |
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
Indices(object, ...) ## S3 method for class 'Neighbor' Indices(object, ...)
Indices(object, ...) ## S3 method for class 'Neighbor' Indices(object, ...)
object |
An object |
... |
Arguments passed to other methods |
A matrix with the nearest neighbor indices
Identify values in a logical map that are common to every observation
## S3 method for class 'LogMap' intersect(x, y = missing_arg(), ...)
## S3 method for class 'LogMap' intersect(x, y = missing_arg(), ...)
x |
A |
y |
Ignored |
... |
Ignored |
The values of x
that are present in every observation
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
labels.LogMap()
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)
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)
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
IsGlobal(object, ...) ## Default S3 method: IsGlobal(object, ...) ## S3 method for class 'DimReduc' IsGlobal(object, ...)
IsGlobal(object, ...) ## Default S3 method: IsGlobal(object, ...) ## S3 method for class 'DimReduc' IsGlobal(object, ...)
object |
An object |
... |
Arguments passed to other methods |
TRUE
if the object is global/persistent otherwise FALSE
IsGlobal(pbmc_small[['pca']])
IsGlobal(pbmc_small[['pca']])
Takes a matrix and asks if it's empty (either 0x0 or 1x1 with a value of NA)
IsMatrixEmpty(x) ## Default S3 method: IsMatrixEmpty(x)
IsMatrixEmpty(x) ## Default S3 method: IsMatrixEmpty(x)
x |
A matrix |
Whether or not x
is empty
IsMatrixEmpty(new("matrix")) IsMatrixEmpty(matrix()) IsMatrixEmpty(matrix(1:3))
IsMatrixEmpty(new("matrix")) IsMatrixEmpty(matrix()) IsMatrixEmpty(matrix(1:3))
Check to see if a list has names; also check to enforce that all names are present and unique
IsNamedList(x, all.unique = TRUE, allow.empty = FALSE, pass.zero = FALSE)
IsNamedList(x, all.unique = TRUE, allow.empty = FALSE, pass.zero = FALSE)
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 |
TRUE
if ..., otherwise FALSE
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)
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)
The JackStrawData is used to store the results of a JackStraw computation.
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
MethodsMethods for JackStrawData
objects for generics defined in
other packages
## 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)
## 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)
x , object
|
A |
pattern |
A regular expression. Only matching names are returned. |
i |
A |
... |
Ignored |
$
: 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
.DollarNames(JackStrawData)
: Autocompletion for $
access on a
JackStrawData
object
$
: Access data from a JackStrawData
object
as.logical(JackStrawData)
: Have empirical p-values for a
JackStrawData
object been calculated
show(JackStrawData)
: Overview of a JackStrawData
object
Split and Join Layers Together
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, ...)
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, ...)
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 |
object
with the layers specified joined
Get and set JackStraw information
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
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
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' |
JS
: either a JackStrawData
object or the
specified jackstraw data
JS<-
: object
with the update jackstraw information
Get and set object keys
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, ...)
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, ...)
object |
An object |
... |
Arguments passed to other methods |
value |
Key value |
Key
: the object key
Keys
: a named vector of keys of sub-objects
Key<-
: object
with an updated key
# 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)
# 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)
Identify the observations that contain a specific value in a logical map
## S3 method for class 'LogMap' labels( object, values, select = c("first", "last", "common", "all"), simplify = TRUE, ... )
## S3 method for class 'LogMap' labels( object, values, select = c("first", "last", "common", "all"), simplify = TRUE, ... )
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 |
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
Logical map objects, validity, and interaction methods:
LogMap
,
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
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'))
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'))
Query and Manipulate Assay Layers
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, ...)
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, ...)
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 |
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
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, ...)
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, ...)
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 |
Loadings
: the feature loadings for object
Loadings<-
: object
with the updated loadings
# 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]
# 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 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 [[<-
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
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
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 |
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
.Data
A logical matrix with at least one row
Logical map objects, validity, and interaction methods:
LogMap-validity
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
# 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
# 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
Validation of LogMap
objects is handled by
validObject
Logical maps must be a logical matrix containing only TRUE or FALSE values
All values must be named within the rownames of the object. Duplicate or
empty (""
) values are not allowed
All observations must be named within the column names of the object.
Duplicate or empty (""
) observations are not allowed
Logical map objects, validity, and interaction methods:
LogMap
,
as.matrix.LogMap()
,
droplevels.LogMap()
,
intersect.LogMap()
,
labels.LogMap()
map <- LogMap(letters[1:10]) map[['obs']] <- c(1, 3, 7) map[['entry']] <- c(2, 7, 10) validObject(map)
map <- LogMap(letters[1:10]) map[['obs']] <- c(1, 3, 7) map[['entry']] <- c(2, 7, 10) validObject(map)
Logs command run, storing the name, timestamp, and argument list. Stores in the Seurat object
LogSeuratCommand(object, return.command = FALSE)
LogSeuratCommand(object, return.command = FALSE)
object |
Name of Seurat object |
return.command |
Return a |
If return.command
, returns a SeuratCommand
object; otherwise, returns the Seurat object with command stored
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
SeuratCommand-class
,
[.SeuratCommand()
,
as.list.SeuratCommand()
Merge one or more v3 assays together
## S3 method for class 'Assay' merge( x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, labels = NULL, collapse = TRUE, ... )
## S3 method for class 'Assay' merge( x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, labels = NULL, collapse = TRUE, ... )
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 |
A new assay with data merged from c(x, y)
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
split.Assay()
,
subset.Assay()
Merge one or more v5 assays together
## S3 method for class 'Assay5' merge(x, y, labels = NULL, add.cell.ids = NULL, collapse = FALSE, ...)
## S3 method for class 'Assay5' merge(x, y, labels = NULL, add.cell.ids = NULL, collapse = FALSE, ...)
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 |
Note: collapsing layers is currently not supported
A new v5 assay with data merged from c(x, y)
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
split.Assay5()
,
subset.Assay5()
Merge two or more dimensional reduction together
## S3 method for class 'DimReduc' merge(x = NULL, y = NULL, add.cell.ids = NULL, ...)
## S3 method for class 'DimReduc' merge(x = NULL, y = NULL, add.cell.ids = NULL, ...)
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 |
A new DimReduc
object with data merged from c(x, y)
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
print.DimReduc()
,
subset.DimReduc()
Merge Seurat Objects
## 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"), ... )
## 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"), ... )
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 |
merge
: Merged object
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).
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
names.Seurat()
,
subset.Seurat()
# `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' 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))
Get and set miscellaneous data
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
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
object |
An object |
... |
Arguments passed to other methods |
value |
Data to add |
slot |
Name of specific bit of meta data to pull |
Miscellaneous data
An object with miscellaneous data added
# Get the misc info Misc(object = pbmc_small, slot = "example") # Add misc info Misc(object = pbmc_small, slot = "example") <- "testing_misc"
# Get the misc info Misc(object = pbmc_small, slot = "example") # Add misc info Misc(object = pbmc_small, slot = "example") <- "testing_misc"
The Spatial Molecules Class
.Data
A list of SpatialPoints
objects
key
The key for the Molecules
Molecules
methods: Molecules-methods
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-methods
,
Segmentation-class
,
Segmentation-methods
Molecules
MethodsMethods for Molecules
objects
## 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)
## 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)
x , object
|
A |
... |
Arguments passed to other methods |
features |
A vector of molecule names to keep; if |
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
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
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Segmentation-class
,
Segmentation-methods
Get the names of subobjects within a Seurat
object
## S3 method for class 'Seurat' names(x)
## S3 method for class 'Seurat' names(x)
x |
A |
The names of all of the following subobjects within x
:
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
subset.Seurat()
names(pbmc_small)
names(pbmc_small)
The Neighbor class is used to store the results of neighbor finding algorithms
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
MethodsMethods for Neighbor
objects for generics defined in
other packages
## S3 method for class 'Neighbor' dim(x) ## S4 method for signature 'Neighbor' show(object)
## S3 method for class 'Neighbor' dim(x) ## S4 method for signature 'Neighbor' show(object)
x , object
|
A |
dim
Dimensions of the indices matrix
show
: Prints summary to stdout
and
invisibly returns NULL
dim(Neighbor)
: Dimensions of the neighbor indices
show(Neighbor)
: Overview of a Neighbor
object
Spatial
Objects Over One AnotherCreate 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
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, ...)
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, ...)
x |
Query |
y |
Target |
invert |
Invert the overlay and return only the components of |
... |
Ignored |
x
with only the components that fall within the
bounds of y
This function requires the sf package to be installed
Check the existence of a package
PackageCheck(..., error = TRUE)
PackageCheck(..., error = TRUE)
... |
Package names |
error |
If true, throw an error if the package doesn't exist |
Invisibly returns boolean denoting if the package is installed
PackageCheck
was deprecated in version 5.0.0; please use
rlang::check_installed()
instead
PackageCheck("SeuratObject", error = FALSE)
PackageCheck("SeuratObject", error = FALSE)
A subsetted version of 10X Genomics' 3k PBMC dataset
pbmc_small
pbmc_small
A Seurat object with the following slots filled
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
Cell level metadata
Current default assay
Current default idents
Neighbor graphs computed, currently stores the SNN
Dimensional reductions: currently PCA and tSNE
Seurat version used to create the object
Command history
https://support.10xgenomics.com/single-cell-gene-expression/datasets/1.1.0/pbmc3k
Prints a set of features that most strongly define a set of components; note: requires feature loadings to be present in order to work
## S3 method for class 'DimReduc' print(x, dims = 1:5, nfeatures = 20, projected = FALSE, ...)
## S3 method for class 'DimReduc' print(x, dims = 1:5, nfeatures = 20, projected = FALSE, ...)
x |
A |
dims |
Number of dimensions to display |
nfeatures |
Number of genes to display |
projected |
Use projected slot |
... |
Ignored |
Displays set of features defining the components and
invisibly returns x
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
subset.DimReduc()
pca <- pbmc_small[["pca"]] print(pca)
pca <- pbmc_small[["pca"]] print(pca)
Get and set project information
Project(object, ...) Project(object, ...) <- value ## S3 method for class 'Seurat' Project(object, ...) ## S3 replacement method for class 'Seurat' Project(object, ...) <- value
Project(object, ...) Project(object, ...) <- value ## S3 method for class 'Seurat' Project(object, ...) ## S3 replacement method for class 'Seurat' Project(object, ...) <- value
object |
An object |
... |
Arguments passed to other methods |
value |
Project information to set |
Project information
An object with project information added
Get the spot radius from an image
Radius(object, ...)
Radius(object, ...)
object |
An image object |
... |
Arguments passed to other methods |
The radius size
Make a name from randomly sampled characters, pasted together with no spaces
RandomName(length = 5L, chars = letters, ...)
RandomName(length = 5L, chars = letters, ...)
length |
How long should the name be |
chars |
A vector of 1-length characters to use to generate the name |
... |
Extra parameters passed to |
A character with nchar == length
of randomly sampled letters
set.seed(42L) RandomName() RandomName(7L, replace = TRUE)
set.seed(42L) RandomName() RandomName(7L, replace = TRUE)
Seurat
objectRename assays in a Seurat
object
RenameAssays( object, assay.name = NULL, new.assay.name = NULL, verbose = TRUE, ... )
RenameAssays( object, assay.name = NULL, new.assay.name = NULL, verbose = TRUE, ... )
object |
A |
assay.name |
original name of assay |
new.assay.name |
new name of assay |
verbose |
Whether to print messages |
... |
Named arguments as |
object
with assays renamed
RenameAssays(object = pbmc_small, RNA = 'rna')
RenameAssays(object = pbmc_small, RNA = 'rna')
Change the cell names in all the different parts of an object. Can be useful before combining multiple objects.
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(), ... )
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(), ... )
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 |
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.
An object with new cell names
# 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 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))
Merge two or more sparse matrices by rowname.
RowMergeSparseMatrices(mat1, mat2)
RowMergeSparseMatrices(mat1, mat2)
mat1 |
First matrix |
mat2 |
Second matrix or list of matrices |
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.
Returns a sparse matrix
Seurat
Objects from Rds filesSave and Load Seurat
Objects from Rds files
SaveSeuratRds( object, file = NULL, move = TRUE, destdir = deprecated(), relative = FALSE, ... ) LoadSeuratRds(file, ...)
SaveSeuratRds( object, file = NULL, move = TRUE, destdir = deprecated(), relative = FALSE, ... ) LoadSeuratRds(file, ...)
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
|
Invisibly returns file
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")
This function requires the fs package to be installed
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"]] } }
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"]] } }
Segmentation
ClassThe Segmentation
Class
Segmentation
methods: Segmentation-methods
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-methods
Segmentation
MethodsMethods for Segmentation
objects
## 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)
## 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)
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 |
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
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
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")
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")
Segmentation layer classes:
Centroids-class
,
Centroids-methods
,
Molecules-class
,
Molecules-methods
,
Segmentation-class
NULL
Set a default value depending on if an object is NULL
x %||% y x %iff% y
x %||% y x %iff% y
x |
An object to test |
y |
A default value |
For %||%
: y
if x
is NULL
;
otherwise x
For %iff%
: y
if x
is not
NULL
; otherwise x
For %||%
: rlang developers
# Set if NULL 1 %||% 2 NULL %||% 2 # Set if *not* NULL 1 %iff% 2 NULL %iff% 2
# Set if NULL 1 %||% 2 NULL %||% 2 # Set if *not* NULL 1 %iff% 2 NULL %iff% 2
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.
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
objects
neighbors
...
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
object
tools
A list of miscellaneous data generated by other tools, should be
filled by developers only using Tool<-
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
Validation of Seurat
objects is handled by
validObject
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
,
subset.Seurat()
SeuratCommand
ClassThe SeuratCommand
is used for logging commands that are run
on a Seurat
object; it stores parameters and timestamps
name
Command name
time.stamp
Timestamp of when command was tun
assay.used
Optional name of assay used to generate
SeuratCommand
object
call.string
String of the command call
params
List of parameters used in the command call
Command log object and interaction methods
$.SeuratCommand()
,
.DollarNames.SeuratCommand()
,
LogSeuratCommand()
,
[.SeuratCommand()
,
as.list.SeuratCommand()
LogMap
Object OverviewOverview of a LogMap
object
## S4 method for signature 'LogMap' show(object)
## S4 method for signature 'LogMap' show(object)
object |
A |
Prints summary to stdout
and invisibly
returns NULL
Simplify Geometry
Simplify segmentations by reducing the number of vertices
Simplify(coords, tol, topologyPreserve = TRUE) ## S3 method for class 'Spatial' Simplify(coords, tol, topologyPreserve = TRUE)
Simplify(coords, tol, topologyPreserve = TRUE) ## S3 method for class 'Spatial' Simplify(coords, tol, topologyPreserve = TRUE)
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 |
A simplified version of coords
A 'Segmentation' object with simplified segmentation vertices
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
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
object
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]*_$
”)
SpatialImage-methods
for a list of required and
provided methods
SpatialImage
methodsMethods 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
## 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)
## 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)
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 |
[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
Cells(SpatialImage)
: Get the cell names from an image
([Override])
DefaultAssay(SpatialImage)
: Get the associated assay of a
SpatialImage
-derived object
DefaultAssay(SpatialImage) <- value
: Set the associated assay of a
SpatialImage
-derived object
GetImage(SpatialImage)
: Get the image data from a
SpatialImage
-derived object
GetTissueCoordinates(SpatialImage)
: Get tissue coordinates for a
SpatialImage
-derived object ([Override])
IsGlobal(SpatialImage)
: Globality test for
SpatialImage
-derived object
Key(SpatialImage)
: Get the key for a
SpatialImage
-derived object
Key(SpatialImage) <- value
: Set the key for a
SpatialImage
-derived object
Radius(SpatialImage)
: Get the spot radius size
RenameCells(SpatialImage)
: Rename cells in a
SpatialImage
-derived object ([Override])
[
: Subset a SpatialImage
-derived object
dim(SpatialImage)
: Get the plotting dimensions of an image
([Override])
subset(SpatialImage)
: Subset a SpatialImage
-derived object
([Override])
show(SpatialImage)
: Overview of a SpatialImage
-derived
object
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 a grob
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 returns
subset(x = x, cells = i)
. If overridden, should only accept i
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
Split an Assay
## S3 method for class 'Assay' split(x, f, drop = FALSE, layers = NA, ...)
## S3 method for class 'Assay' split(x, f, drop = FALSE, layers = NA, ...)
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 |
Returns a v5 assay with splitted layers
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
## S3 method for class 'Assay5' split( x, f, drop = FALSE, layers = c("counts", "data"), ret = c("assay", "multiassays", "layers"), ... )
## S3 method for class 'Assay5' split( x, f, drop = FALSE, layers = c("counts", "data"), ret = c("assay", "multiassays", "layers"), ... )
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 |
Depends on the value of ret
:
“assay
”: x
with the layers requested in
layers
split based on f
; all other layers are left as-is
“multiassay
”: a list of Assay5
objects;
the list contains one value per split and each assay contains only the
layers requested in layers
with the key set to the split
“layers
”: a list of matrices of length
length(assays) * length(unique(f))
; the list is named as
“layer.split
”
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")
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
subset.Assay5()
Get the standard deviations for an object
Stdev(object, ...) ## S3 method for class 'DimReduc' Stdev(object, ...) ## S3 method for class 'Seurat' Stdev(object, reduction = "pca", ...)
Stdev(object, ...) ## S3 method for class 'DimReduc' Stdev(object, ...) ## S3 method for class 'Seurat' Stdev(object, reduction = "pca", ...)
object |
An object |
... |
Arguments passed to other methods |
reduction |
Name of reduction to use |
The standard deviations
# 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")
# 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
StitchMatrix(x, y, rowmap, colmap, ...)
StitchMatrix(x, y, rowmap, colmap, ...)
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 |
A single matrix of type class(x)
consisting of all values
in component matrices
Subset an Assay
## S3 method for class 'Assay' subset(x, cells = NULL, features = NULL, ...)
## S3 method for class 'Assay' subset(x, cells = NULL, features = NULL, ...)
x |
An |
cells |
Cell names |
features |
Feature names |
... |
Ignored |
x
with just the cells and features specified by
cells
and features
v3 Assay object, validity, and interaction methods:
$.Assay()
,
Assay-class
,
Assay-validity
,
CreateAssayObject()
,
[.Assay()
,
[[.Assay()
,
dim.Assay()
,
dimnames.Assay()
,
merge.Assay()
,
split.Assay()
rna <- pbmc_small[["RNA"]] rna2 <- subset(rna, features = VariableFeatures(rna)) rna2
rna <- pbmc_small[["RNA"]] rna2 <- subset(rna, features = VariableFeatures(rna)) rna2
Subset an Assay
## S3 method for class 'Assay5' subset(x, cells = NULL, features = NULL, layers = NULL, ...)
## S3 method for class 'Assay5' subset(x, cells = NULL, features = NULL, layers = NULL, ...)
x |
An |
cells |
Cell names |
features |
Feature names |
layers |
Layer to keep; defaults to all layers |
... |
Ignored |
x
with just the cells and features specified by
cells
and features
for the layers specified by layers
v5 Assay object, validity, and interaction methods:
$.Assay5()
,
Assay5-class
,
Assay5-validity
,
[.Assay5()
,
[[.Assay5()
,
dim.Assay5()
,
dimnames.Assay5()
,
merge.Assay5()
,
split.Assay5()
Subset a DimReduc
object
## S3 method for class 'DimReduc' subset(x, cells = NULL, features = NULL, ...)
## S3 method for class 'DimReduc' subset(x, cells = NULL, features = NULL, ...)
x |
A |
cells , features
|
Cells and features to keep during the subset |
... |
Ignored |
x
for cells cells
and features features
Dimensional reduction object, validity, and interaction methods
CreateDimReducObject()
,
DimReduc-class
,
DimReduc-validity
,
[.DimReduc()
,
[[.DimReduc()
,
dim.DimReduc()
,
merge.DimReduc()
,
print.DimReduc()
Seurat
ObjectsSubset Seurat
Objects
## 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, ...]
## 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, ...]
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 |
subset
: A subsetted Seurat
object
[
: object x
with features i
and cells j
Seurat object, validity, and interaction methods
$.Seurat()
,
Seurat-class
,
Seurat-validity
,
[[.Seurat()
,
[[<-,Seurat
,
[[<-,Seurat,NULL
,
dim.Seurat()
,
dimnames.Seurat()
,
merge.Seurat()
,
names.Seurat()
# `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` 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]
Get the offset angle
Theta(object)
Theta(object)
object |
An object |
Use Tool
to get tool data. If no additional arguments are provided,
will return a vector with the names of tools in the object.
Tool(object, ...) Tool(object, ...) <- value ## S3 method for class 'Seurat' Tool(object, slot = NULL, ...) ## S3 replacement method for class 'Seurat' Tool(object, ...) <- value
Tool(object, ...) Tool(object, ...) <- value ## S3 method for class 'Seurat' Tool(object, slot = NULL, ...) ## S3 replacement method for class 'Seurat' Tool(object, ...) <- value
object |
An object |
... |
Arguments passed to other methods |
value |
Information to be added to tool list |
slot |
Name of tool to pull |
If no additional arguments, returns the names of the tools in the object; otherwise returns the data placed by the tool requested
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
# 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")
# 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")
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.
UpdateSeuratObject(object)
UpdateSeuratObject(object)
object |
Seurat object |
Returns a Seurat object compatible with latest changes
## Not run: updated_seurat_object = UpdateSeuratObject(object = old_seurat_object) ## End(Not run)
## Not run: updated_seurat_object = UpdateSeuratObject(object = old_seurat_object) ## End(Not run)
Update slots in an object
UpdateSlots(object)
UpdateSlots(object)
object |
An object to update |
object
with the latest slot definitions
Get Version Information
Version(object, ...) ## S3 method for class 'Seurat' Version(object, ...)
Version(object, ...) ## S3 method for class 'Seurat' Version(object, ...)
object |
An object |
... |
Arguments passed to other methods |
Version(pbmc_small)
Version(pbmc_small)
Returns a list of cells that match a particular set of criteria such as identity class, high/low values for particular PCs, etc.
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, ... )
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, ... )
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 |
A vector of cell names
WhichCells(pbmc_small, idents = 2) WhichCells(pbmc_small, expression = MS4A1 > 3) levels(pbmc_small) WhichCells(pbmc_small, idents = c(1, 2), invert = TRUE)
WhichCells(pbmc_small, idents = 2) WhichCells(pbmc_small, expression = MS4A1 > 3) levels(pbmc_small) WhichCells(pbmc_small, idents = c(1, 2), invert = TRUE)