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> for more details. |
Authors: | Rahul Satija [aut] , Andrew Butler [aut] , Paul Hoffman [aut, cre] , Tim Stuart [aut] , Jeff Farrell [ctb], Shiwei Zheng [ctb] , Christoph Hafemeister [ctb] , Patrick Roelli [ctb], Yuhan Hao [ctb] |
Maintainer: | Paul Hoffman <[email protected]> |
License: | MIT + file LICENSE |
Version: | 4.1.4 |
Built: | 2024-11-09 05:08:27 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 for more details.
Maintainer: Paul Hoffman [email protected] (ORCID)
Authors:
Rahul Satija [email protected] (ORCID)
Andrew Butler [email protected] (ORCID)
Tim Stuart [email protected] (ORCID)
Other contributors:
Jeff Farrell [email protected] [contributor]
Shiwei Zheng [email protected] (ORCID) [contributor]
Christoph Hafemeister [email protected] (ORCID) [contributor]
Patrick Roelli [email protected] [contributor]
Yuhan Hao [email protected] (ORCID) [contributor]
Useful links:
Report bugs at https://github.com/mojaveazure/seurat-object/issues
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 '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 '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[[]])
Aggregate Molecules into an Expression Matrix
## S3 method for class 'FOV' aggregate(x, by = NULL, set = NULL, drop = TRUE, ...) ## S3 method for class 'Molecules' aggregate(x, by, drop = TRUE, ...)
## S3 method for class 'FOV' aggregate(x, by = NULL, set = NULL, drop = TRUE, ...) ## S3 method for class 'Molecules' aggregate(x, by, drop = TRUE, ...)
x |
An object with spatially-resolved molecule information |
by |
Name of a
|
set |
Name of molecule set to aggregate |
drop |
Drop molecules not present in a segmentation; if |
... |
Arguments passed to other methods |
An expression matrix
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 uses
future to enable
parallelization. Parallelization strategies can be set using
plan
. Common plans include “sequential
”
for non-parallelized processing or “multisession
” for parallel
evaluation using multiple R sessions; for other plans, see the
“Implemented evaluation strategies” section of
?future::plan
. For a more thorough introduction
to future, see
vignette("future-1-overview")
Convert Segmentation Layers
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 |
... |
Arguments passed to other methods (ignored for now) |
weighted |
If TRUE, fill entries in Graph matrix with value from the nn.dist slot of the Neighbor object |
A Graph
object
# 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)
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
key
Key for the Assay
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
Utility slot for storing additional data associated with the assay
Assay
MethodsMethods for Assay
objects for generics defined in
other packages
## S3 method for class 'Assay' x[i, j, ...] ## S3 method for class 'Assay' x[[i, ..., drop = FALSE]] ## S3 method for class 'Assay' dim(x) ## S3 method for class 'Assay' dimnames(x) ## S3 method for class 'Assay' head(x, n = 10L, ...) ## S3 method for class 'Assay' merge(x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, ...) ## S3 method for class 'Assay' subset(x, cells = NULL, features = NULL, ...) ## S3 method for class 'Assay' tail(x, n = 10L, ...) ## S4 replacement method for signature 'Assay,ANY,ANY,ANY' x[[i, j, ...]] <- value ## S4 method for signature 'Assay' colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' show(object)
## S3 method for class 'Assay' x[i, j, ...] ## S3 method for class 'Assay' x[[i, ..., drop = FALSE]] ## S3 method for class 'Assay' dim(x) ## S3 method for class 'Assay' dimnames(x) ## S3 method for class 'Assay' head(x, n = 10L, ...) ## S3 method for class 'Assay' merge(x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, ...) ## S3 method for class 'Assay' subset(x, cells = NULL, features = NULL, ...) ## S3 method for class 'Assay' tail(x, n = 10L, ...) ## S4 replacement method for signature 'Assay,ANY,ANY,ANY' x[[i, j, ...]] <- value ## S4 method for signature 'Assay' colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Assay' show(object)
x , object
|
An |
i , features
|
For |
j , cells
|
Cell names or indices |
... |
Arguments passed to other methods |
drop |
See |
n |
an integer vector of length up to |
y |
A vector or list of one or more objects to merge |
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 |
value |
Additional metadata to add |
na.rm |
logical. Should missing values (including |
dims |
completely ignored by the |
slot |
Name of assay expression matrix to calculate column/row means/sums on |
[
: The data
slot for features i
and cells
j
[[
: The feature-level metadata for i
dim
: The number of features (nrow
) and cells
(ncol
)
dimnames
: Feature (row) and cell (column) names
head
: The first n
rows of feature-level metadata
merge
: Merged object
subset
: A subsetted Assay
tail
: The last n
rows of feature-level metadata
[[<-
: x
with metadata value
added as i
colMeans
: The column (cell-wise) means of slot
colSums
: The column (cell-wise) sums of slot
rowMeans
: The row (feature-wise) means of slot
rowSums
: The row (feature-wise) sums of slot
show
: Prints summary to stdout
and
invisibly returns NULL
[
: Get expression data from an Assay
[[
: Get feature-level metadata
dim(Assay)
: Number of cells and features for an Assay
dimnames(Assay)
: Cell- and feature-names for an Assay
head(Assay)
: Get the first rows of feature-level metadata
merge(Assay)
: Merge Assay
objects
subset(Assay)
: Subset an Assay
tail(Assay)
: Get the last rows of feature-level metadata
`[[`(x = Assay, i = ANY, j = ANY) <- value
: Add feature-level metadata
colMeans(Assay)
: Calculate colMeans
on an
Assay
colSums(Assay)
: Calculate colSums
on an
Assay
rowMeans(Assay)
: Calculate rowMeans
on an
Assay
rowSums(Assay)
: Calculate rowSums
on an
Assay
show(Assay)
: Overview of an Assay
object
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, slot, ...) SetAssayData(object, slot, new.data, ...) ## S3 method for class 'Seurat' GetAssayData(object, slot = "data", assay = NULL, ...) ## S3 method for class 'Seurat' SetAssayData(object, slot = "data", new.data, assay = NULL, ...) ## S3 method for class 'Assay' GetAssayData(object, slot = c("data", "scale.data", "counts"), ...) ## S3 method for class 'Assay' SetAssayData(object, slot = c("data", "scale.data", "counts"), new.data, ...)
GetAssayData(object, slot, ...) SetAssayData(object, slot, new.data, ...) ## S3 method for class 'Seurat' GetAssayData(object, slot = "data", assay = NULL, ...) ## S3 method for class 'Seurat' SetAssayData(object, slot = "data", new.data, assay = NULL, ...) ## S3 method for class 'Assay' GetAssayData(object, slot = c("data", "scale.data", "counts"), ...) ## S3 method for class 'Assay' SetAssayData(object, slot = c("data", "scale.data", "counts"), new.data, ...)
object |
An object |
slot |
Specific assay data to get or set |
... |
Arguments passed to other methods |
new.data |
New assay data to add |
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
# Get assay data from the default assay in a Seurat object GetAssayData(object = pbmc_small, slot = "data")[1:5,1:5] # Set an Assay slot through the Seurat object count.data <- GetAssayData(object = pbmc_small[["RNA"]], slot = "counts") count.data <- as.matrix(x = count.data + 1) new.seurat.object <- SetAssayData( object = pbmc_small, slot = "counts", new.data = count.data, assay = "RNA" ) # Get the data directly from an Assay object GetAssayData(pbmc_small[["RNA"]], slot = "data")[1:5,1:5] # Set an Assay slot directly count.data <- GetAssayData(pbmc_small[["RNA"]], slot = "counts") count.data <- as.matrix(x = count.data + 1) new.assay <- SetAssayData(pbmc_small[["RNA"]], slot = "counts", new.data = count.data)
# Get assay data from the default assay in a Seurat object GetAssayData(object = pbmc_small, slot = "data")[1:5,1:5] # Set an Assay slot through the Seurat object count.data <- GetAssayData(object = pbmc_small[["RNA"]], slot = "counts") count.data <- as.matrix(x = count.data + 1) new.seurat.object <- SetAssayData( object = pbmc_small, slot = "counts", new.data = count.data, assay = "RNA" ) # Get the data directly from an Assay object GetAssayData(pbmc_small[["RNA"]], slot = "data")[1:5,1:5] # Set an Assay slot directly count.data <- GetAssayData(pbmc_small[["RNA"]], slot = "counts") count.data <- as.matrix(x = count.data + 1) new.assay <- SetAssayData(pbmc_small[["RNA"]], slot = "counts", new.data = count.data)
List the names of Assay
, DimReduc
,
Graph
, Neighbor
objects
Assays(object, slot = NULL) Graphs(object, slot = NULL) Neighbors(object, slot = NULL) Reductions(object, slot = NULL)
Assays(object, slot = NULL) Graphs(object, slot = NULL) Neighbors(object, slot = NULL) Reductions(object, slot = NULL)
object |
A |
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(object = pbmc_small) Graphs(pbmc_small) Reductions(object = pbmc_small)
Assays(object = 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
# 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
Get the cell and feature names of an object
Cells(x, ...) Features(x, ...) ## Default S3 method: Cells(x, ...) ## 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 'DimReduc' Cells(x, ...) ## S3 method for class 'Neighbor' Cells(x, ...)
x |
An object |
... |
Arguments passed to other methods |
Cell
: A vector of cell names
Features
: A vector of feature names
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 request, 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:
Molecules-class
,
Segmentation-class
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
Call gc
only when desired
CheckGC(option = "SeuratObject.memsafe")
CheckGC(option = "SeuratObject.memsafe")
option |
... |
Invisibly returns NULL
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 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, check.matrix = FALSE, ... )
CreateAssayObject( counts, data, min.cells = 0, min.features = 0, 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. |
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
## 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
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, project = "CreateSeuratObject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, ... ) ## Default S3 method: CreateSeuratObject( counts, project = "SeuratProject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, min.cells = 0, min.features = 0, row.names = NULL, ... ) ## S3 method for class 'Assay' CreateSeuratObject( counts, project = "SeuratProject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, ... )
CreateSeuratObject( counts, project = "CreateSeuratObject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, ... ) ## Default S3 method: CreateSeuratObject( counts, project = "SeuratProject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, min.cells = 0, min.features = 0, row.names = NULL, ... ) ## S3 method for class 'Assay' CreateSeuratObject( counts, project = "SeuratProject", assay = "RNA", names.field = 1, names.delim = "_", meta.data = NULL, ... )
counts |
Either a |
project |
Project name for the |
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 |
... |
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. |
row.names |
When |
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:
|
... |
... |
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 '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 '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
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
key
Key for the DimReduc
, must be alphanumeric characters
followed by an underscore
jackstraw
A JackStrawData-class
object associated with
this DimReduc
misc
Utility slot for storing additional data associated with the
DimReduc
(e.g. the total variance of the PCA)
DimReduc
MethodsMethods for DimReduc
objects for generics defined in
other packages
## S3 method for class 'DimReduc' x[i, j, drop = FALSE, ...] ## S3 method for class 'DimReduc' x[[i, j, drop = FALSE, ...]] ## 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' merge(x = NULL, y = NULL, add.cell.ids = NULL, ...) ## S3 method for class 'DimReduc' names(x) ## S3 method for class 'DimReduc' print(x, dims = 1:5, nfeatures = 20, projected = FALSE, ...) ## S3 method for class 'DimReduc' subset(x, cells = NULL, features = NULL, ...) ## S4 method for signature 'DimReduc' show(object)
## S3 method for class 'DimReduc' x[i, j, drop = FALSE, ...] ## S3 method for class 'DimReduc' x[[i, j, drop = FALSE, ...]] ## 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' merge(x = NULL, y = NULL, add.cell.ids = NULL, ...) ## S3 method for class 'DimReduc' names(x) ## S3 method for class 'DimReduc' print(x, dims = 1:5, nfeatures = 20, projected = FALSE, ...) ## S3 method for class 'DimReduc' subset(x, cells = NULL, features = NULL, ...) ## S4 method for signature 'DimReduc' show(object)
x , object
|
A |
i |
For |
j |
Dimensions to pull for |
drop |
See |
... |
Arguments passed to other methods |
y |
A vector or list of one or more objects to merge |
add.cell.ids |
A character vector of |
dims |
Number of dimensions to display |
nfeatures |
Number of genes to display |
projected |
Use projected slot |
cells , features
|
Cells and features to keep during the subset |
[
: Feature loadings for features i
and dimensions
j
[[
: Cell embeddings for cells i
and dimensions j
dim
: The number of cells (nrow
) and dimensions
(ncol
)
dimnames
: The cell (row) and dimension (column) names
length
: The number of dimensions
names
: The names for the dimensions (eg. “PC_1”)
print
: Displays set of features defining the components and
invisibly returns x
subset
: x
for cells cells
and features
features
show
: Prints summary to stdout
and
invisibly returns NULL
[
: Pull feature loadings
[[
: Pull cell embeddings
dim(DimReduc)
: The number of cells and dimensions for a
DimReduc
dimnames(DimReduc)
: The cell and dimension names for a
DimReduc
object
length(DimReduc)
: The number of dimensions for a DimReduc
object
merge(DimReduc)
: Merge two or more DimReduc
objects
together
names(DimReduc)
: The dimension names for a DimReduc
object
print(DimReduc)
: Prints a set of features that most strongly
define a set of components; note: requires feature loadings to be
present in order to work
subset(DimReduc)
: Subset a DimReduc
object
show(DimReduc)
: Show basic summary of a DimReduc
object
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
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]
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, slot = c("embeddings", "loadings", "projected"), ... ) ## S3 method for class 'Seurat' FetchData(object, vars, cells = NULL, slot = "data", ...)
FetchData(object, ...) ## S3 method for class 'DimReduc' FetchData( object, vars, cells = NULL, slot = c("embeddings", "loadings", "projected"), ... ) ## S3 method for class 'Seurat' FetchData(object, vars, cells = NULL, slot = "data", ...)
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) |
slot |
Slot to pull feature data for |
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", "DimReduc"))
FilterObjects(object, classes.keep = c("Assay", "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(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
(list
) A named list of
Molecules
objects defining
spatially-resolved molecular coordinates
boundaries
([named]list
{Segmentation
,
Centroids
}) A named list of
Segmentation
and
Centroids
objects defining
spatially-resolved boundaries
assay
(character [1L]
) A character
naming the associated assay of the spatial coordinates
key
(character [1L]
) The key
for the spatial coordinates
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
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
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, selection.method, status = FALSE, ...) VariableFeatures(object, selection.method = NULL, ...) VariableFeatures(object, ...) <- value SVFInfo(object, selection.method, status, ...) SpatiallyVariableFeatures(object, selection.method, ...) ## S3 method for class 'Seurat' HVFInfo(object, selection.method = NULL, status = FALSE, assay = NULL, ...) ## S3 method for class 'Seurat' VariableFeatures(object, selection.method = NULL, assay = NULL, ...) ## S3 replacement method for class 'Seurat' VariableFeatures(object, assay = NULL, ...) <- value ## S3 method for class 'Seurat' SVFInfo( object, selection.method = c("markvariogram", "moransi"), status = FALSE, assay = NULL, ... ) ## S3 method for class 'Seurat' SpatiallyVariableFeatures( object, selection.method = "markvariogram", assay = NULL, decreasing = TRUE, ... ) ## S3 method for class 'Assay' HVFInfo(object, selection.method, status = FALSE, ...) ## S3 method for class 'Assay' SpatiallyVariableFeatures( object, selection.method = "markvariogram", decreasing = TRUE, ... ) ## S3 method for class 'Assay' SVFInfo( object, selection.method = c("markvariogram", "moransi"), status = FALSE, ... ) ## S3 method for class 'Assay' VariableFeatures(object, selection.method = NULL, ...) ## S3 replacement method for class 'Assay' VariableFeatures(object, ...) <- value
HVFInfo(object, selection.method, status = FALSE, ...) VariableFeatures(object, selection.method = NULL, ...) VariableFeatures(object, ...) <- value SVFInfo(object, selection.method, status, ...) SpatiallyVariableFeatures(object, selection.method, ...) ## S3 method for class 'Seurat' HVFInfo(object, selection.method = NULL, status = FALSE, assay = NULL, ...) ## S3 method for class 'Seurat' VariableFeatures(object, selection.method = NULL, assay = NULL, ...) ## S3 replacement method for class 'Seurat' VariableFeatures(object, assay = NULL, ...) <- value ## S3 method for class 'Seurat' SVFInfo( object, selection.method = c("markvariogram", "moransi"), status = FALSE, assay = NULL, ... ) ## S3 method for class 'Seurat' SpatiallyVariableFeatures( object, selection.method = "markvariogram", assay = NULL, decreasing = TRUE, ... ) ## S3 method for class 'Assay' HVFInfo(object, selection.method, status = FALSE, ...) ## S3 method for class 'Assay' SpatiallyVariableFeatures( object, selection.method = "markvariogram", decreasing = TRUE, ... ) ## S3 method for class 'Assay' SVFInfo( object, selection.method = c("markvariogram", "moransi"), status = FALSE, ... ) ## S3 method for class 'Assay' VariableFeatures(object, selection.method = NULL, ...) ## S3 replacement method for class 'Assay' VariableFeatures(object, ...) <- value
object |
An object |
selection.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 |
decreasing |
Return features in decreasing order (most spatially variable first). |
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"]], selection.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"]], selection.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, ...) <- 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, ...) <- 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 |
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
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)
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
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
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, ...) Key(object, ...) <- value Keys(object, ...) ## S3 method for class 'Assay' Key(object, ...) ## S3 replacement method for class 'Assay' 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, ...) Key(object, ...) <- value Keys(object, ...) ## S3 method for class 'Assay' Key(object, ...) ## S3 replacement method for class 'Assay' 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
Key<-
: object
with an updated key
Keys
: a named vector of keys of sub-objects
# 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)
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 ## S4 method for signature 'LogMap' show(object)
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 ## S4 method for signature 'LogMap' show(object)
y |
A character vector |
x , object
|
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
# 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 # 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
# 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 # 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
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 SeuratCommand object instead |
If return.command
, returns a SeuratCommand object. Otherwise,
returns the Seurat object with command stored
Match Cells
MatchCells(new, orig, ordered = FALSE) ## S3 method for class 'character' MatchCells(new, orig, ordered = FALSE) ## S3 method for class ''NULL'' MatchCells(new, orig, ordered = FALSE) ## S3 method for class 'numeric' MatchCells(new, orig, ordered = FALSE)
MatchCells(new, orig, ordered = FALSE) ## S3 method for class 'character' MatchCells(new, orig, ordered = FALSE) ## S3 method for class ''NULL'' MatchCells(new, orig, ordered = FALSE) ## S3 method for class 'numeric' MatchCells(new, orig, ordered = FALSE)
new |
A vector of new cells |
orig |
A vector of existing cells |
ordered |
Sort the result to the same order as |
A numeric vector with new cells in order of the original cells; if
no match can be found, returns NULL
Get and set miscellaneous data
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 '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 '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
,
Segmentation-class
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
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
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("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
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 |
The radius size
Make a name from randomly sampled lowercase letters, pasted together with no spaces or other characters
RandomName(length = 5L, ...)
RandomName(length = 5L, ...)
length |
How long should the name be |
... |
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, ...)
RenameAssays(object, ...)
object |
A |
... |
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 '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 = NULL, new.names = NULL, for.merge = FALSE, ... )
RenameCells(object, ...) ## S3 method for class 'Assay' 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 = NULL, new.names = NULL, for.merge = FALSE, ... )
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 |
Only rename slots needed for merging Seurat objects. Currently only renames the raw.data and meta.data slots. |
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
Convert S4 objects to lists and vice versa. Useful for declassing an S4
object while keeping track of it's class using attributes (see section
S4 Class Definition Attributes below for more details). Both
ListToS4
and S4ToList
are recursive functions, affecting all
lists/S4 objects contained as sub-lists/sub-objects.
S4ToList(object) IsS4List(x) ListToS4(x) ## Default S3 method: S4ToList(object) ## S3 method for class 'list' S4ToList(object)
S4ToList(object) IsS4List(x) ListToS4(x) ## Default S3 method: S4ToList(object) ## S3 method for class 'list' S4ToList(object)
object |
An S4 object |
x |
A list with an S4 class definition attribute |
S4ToList
: A list with an S4 class definition attribute
IsS4List
: TRUE
if x
is a list with an S4 class
definition attribute
ListToS4
: An S4 object as defined by the S4 class definition
attribute
S4 classes are scoped to the package and class name. In order to properly
track which class a list is generated from in order to build a new one,
these function use an attribute
to denote the
class name and package of origin. This attribute is stored as
“classDef” and takes the form of “package:class
”.
Segmentation
ClassThe Segmentation
Class
Segmentation
methods: Segmentation-methods
Segmentation layer classes:
Centroids-class
,
Molecules-class
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")
NA
Set a default value depending on if an object is NA
x %NA% y x %na% y x %!NA% y x %!na% y
x %NA% y x %na% y x %!NA% y x %!na% y
x |
An object to test |
y |
A default value |
For %NA%
: y
if x
is NA
;
otherwise x
For %!NA%
: y
if x
is not
NA
; otherwise x
1 %NA% 2 NA %NA% 2 1 %!NA% 2 NA %!NA% 2
1 %NA% 2 NA %NA% 2 1 %!NA% 2 NA %!NA% 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<-
Methods for Seurat
objects for generics defined in other
packages
## S3 method for class 'Seurat' .DollarNames(x, pattern = "") ## S3 method for class 'Seurat' x$i, ... ## S3 replacement method for class 'Seurat' x$i, ... <- value ## S3 method for class 'Seurat' x[i, j, ...] ## S3 method for class 'Seurat' x[[i, ..., drop = FALSE]] ## S3 method for class 'Seurat' dim(x) ## S3 method for class 'Seurat' dimnames(x) ## S3 method for class 'Seurat' head(x, n = 10L, ...) ## S3 method for class 'Seurat' merge( x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, merge.dr = NULL, project = "SeuratProject", ... ) ## S3 method for class 'Seurat' names(x) ## S3 method for class 'Seurat' subset( x, subset, cells = NULL, features = NULL, idents = NULL, return.null = FALSE, ... ) ## S3 method for class 'Seurat' tail(x, n = 10L, ...) ## S4 replacement method for signature 'Seurat,ANY,ANY,ANY' x[[i, j, ...]] <- value ## S4 method for signature 'Seurat' colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' show(object)
## S3 method for class 'Seurat' .DollarNames(x, pattern = "") ## S3 method for class 'Seurat' x$i, ... ## S3 replacement method for class 'Seurat' x$i, ... <- value ## S3 method for class 'Seurat' x[i, j, ...] ## S3 method for class 'Seurat' x[[i, ..., drop = FALSE]] ## S3 method for class 'Seurat' dim(x) ## S3 method for class 'Seurat' dimnames(x) ## S3 method for class 'Seurat' head(x, n = 10L, ...) ## S3 method for class 'Seurat' merge( x = NULL, y = NULL, add.cell.ids = NULL, merge.data = TRUE, merge.dr = NULL, project = "SeuratProject", ... ) ## S3 method for class 'Seurat' names(x) ## S3 method for class 'Seurat' subset( x, subset, cells = NULL, features = NULL, idents = NULL, return.null = FALSE, ... ) ## S3 method for class 'Seurat' tail(x, n = 10L, ...) ## S4 replacement method for signature 'Seurat,ANY,ANY,ANY' x[[i, j, ...]] <- value ## S4 method for signature 'Seurat' colMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' colSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' rowMeans(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' rowSums(x, na.rm = FALSE, dims = 1, ..., slot = "data") ## S4 method for signature 'Seurat' show(object)
x , object
|
A |
pattern |
A regular expression. Only matching names are returned. |
i , features
|
Depends on the method
|
... |
Arguments passed to other methods |
value |
Additional metadata or associated objects to add; note:
can pass |
j , cells
|
Cell names or indices |
drop |
See |
n |
The number of rows of metadata to return |
y |
A single |
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 |
merge.dr |
Merge specified DimReducs that are present in all objects;
will only merge the embeddings slots for the first |
project |
Project name for the |
subset |
Logical expression indicating features/variables to keep |
idents |
A vector of identity classes to keep |
return.null |
If no cells are request, return a |
na.rm |
logical. Should missing values (including |
dims |
completely ignored by the |
slot |
Name of assay expression matrix to calculate column/row means/sums on |
$
: metadata column i
for object x
;
note: unlike [[
, $
drops the shape of the metadata
to return a vector instead of a data frame
$<-
: object x
with metadata value
saved as
i
[
: object x
with features i
and cells j
[[
: If i
is missing, the metadata data frame; if
i
is a vector of metadata names, a data frame with the requested
metadata, otherwise, the requested associated object
dim
: The number of features (nrow
) and cells
(ncol
) for the default assay; note: while the number of
features changes depending on the active assay, the number of cells remains
the same across all assays
dimnames
: The feature (row) and cell (column) names;
note: while the features change depending on the active assay, the
cell names remain the same across all assays
head
: The first n
rows of cell-level metadata
merge
: Merged object
names
: The names of all Assay
,
DimReduc
, Graph
, and SpatialImage
objects in the Seurat
object
subset
: A subsetted Seurat
object
tail
: The last n
rows of cell-level metadata
[[<-
: x
with the metadata or associated objects added
as i
; if value
is NULL
, removes metadata or associated
object i
from object x
show
: Prints summary to stdout
and
invisibly returns NULL
.DollarNames(Seurat)
: Autocompletion for $
access on a
Seurat
object
$
: Metadata access for Seurat
objects
`$`(Seurat) <- value
: Metadata setter for Seurat
objects
[
: Simple subsetter for Seurat
objects
[[
: Metadata and associated object accessor
dim(Seurat)
: Number of cells and features for the active assay
dimnames(Seurat)
: The cell and feature names for the active assay
head(Seurat)
: Get the first rows of cell-level metadata
merge(Seurat)
: Merge two or more Seurat
objects together
names(Seurat)
: Common associated objects
subset(Seurat)
: Subset a Seurat
object
tail(Seurat)
: Get the last rows of cell-level metadata
`[[`(x = Seurat, i = ANY, j = ANY) <- value
: Add cell-level metadata or associated objects
colMeans(Seurat)
: Calculate colMeans
on a
Seurat
object
colSums(Seurat)
: Calculate colSums
on a
Seurat
object
rowMeans(Seurat)
: Calculate rowMeans
on a
rowMeans
object
rowSums(Seurat)
: Calculate rowSums
on a
Seurat
object
show(Seurat)
: Overview of a Seurat
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).
# 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"]]) # `[' examples pbmc_small[VariableFeatures(object = pbmc_small), ] pbmc_small[, 1:10] # 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 number of features in an object nrow(pbmc_small) # Get the number of cells in an object ncol(pbmc_small) # Get the feature names of an object rownames(pbmc_small) # Get the cell names of an object colnames(pbmc_small) # Get the first 10 rows of cell-level metadata head(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)) names(pbmc_small) # `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)) # Get the last 10 rows of cell-level metadata tail(pbmc_small) head(colMeans(pbmc_small)) head(colSums(pbmc_small)) head(rowMeans(pbmc_small)) head(rowSums(pbmc_small))
# 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"]]) # `[' examples pbmc_small[VariableFeatures(object = pbmc_small), ] pbmc_small[, 1:10] # 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 number of features in an object nrow(pbmc_small) # Get the number of cells in an object ncol(pbmc_small) # Get the feature names of an object rownames(pbmc_small) # Get the cell names of an object colnames(pbmc_small) # Get the first 10 rows of cell-level metadata head(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)) names(pbmc_small) # `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)) # Get the last 10 rows of cell-level metadata tail(pbmc_small) head(colMeans(pbmc_small)) head(colSums(pbmc_small)) head(rowMeans(pbmc_small)) head(rowSums(pbmc_small))
The 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
SeuratCommand
MethodsMethods for SeuratCommand
objects for generics defined in
other packages
## S3 method for class 'SeuratCommand' .DollarNames(x, pattern = "") ## S3 method for class 'SeuratCommand' x$i, ... ## S3 method for class 'SeuratCommand' x[i, ...] ## S3 method for class 'SeuratCommand' as.list(x, complete = FALSE, ...) ## S4 method for signature 'SeuratCommand' show(object)
## S3 method for class 'SeuratCommand' .DollarNames(x, pattern = "") ## S3 method for class 'SeuratCommand' x$i, ... ## S3 method for class 'SeuratCommand' x[i, ...] ## S3 method for class 'SeuratCommand' as.list(x, complete = FALSE, ...) ## S4 method for signature 'SeuratCommand' show(object)
x , object
|
A |
pattern |
A regular expression. Only matching names are returned. |
i |
For a |
... |
Arguments passed to other methods |
complete |
Include slots besides just parameters (eg. call string, name, timestamp) |
$
: The value for parameter i
[
: Slot i
from x
as.list
: A list with the parameters and, if
complete = TRUE
, the call string, name, and timestamp
show
: Prints summary to stdout
and
invisibly returns NULL
.DollarNames(SeuratCommand)
: Autocompletion for $
access on a
SeuratCommand
object
$
: Access a parameter from a
SeuratCommand
object
[
: Access data from a SeuratCommand
object
as.list(SeuratCommand)
: Coerce a SeuratCommand
to a list
show(SeuratCommand)
: Overview of a SeuratCommand
object
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 '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
Key for the image
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
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")
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.
Tool(object = pbmc_small) ## Not run: sample.tool.output <- matrix(data = rnorm(n = 16), nrow = 4) # must be run from within a function Tool(object = pbmc_small) <- sample.tool.output ## End(Not run)
Tool(object = pbmc_small) ## Not run: sample.tool.output <- matrix(data = rnorm(n = 16), nrow = 4) # must be run from within a function Tool(object = pbmc_small) <- sample.tool.output ## End(Not run)
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)