General accessor and setter functions for Assay
objects.
GetAssayData
can be used to pull information from any of the
expression matrices (eg. “counts”, “data”, or
“scale.data”). SetAssayData
can be used to replace one of these
expression matrices
GetAssayData(object, ...)
SetAssayData(object, layer, new.data, slot = deprecated(), ...)
# S3 method for Seurat
GetAssayData(object, assay = NULL, layer = NULL, slot = deprecated(), ...)
# S3 method for Seurat
SetAssayData(
object,
layer = "data",
new.data,
slot = deprecated(),
assay = NULL,
...
)
# S3 method for Assay
GetAssayData(
object,
layer = c("data", "scale.data", "counts"),
slot = deprecated(),
...
)
# S3 method for Assay
SetAssayData(
object,
layer = c("data", "scale.data", "counts"),
new.data,
slot = deprecated(),
...
)
An object
Arguments passed to other methods
Name of layer to get or set
New assay data to add
Specific assay to get data from or set data for; defaults to the default assay
GetAssayData
: returns the specified assay data
SetAssayData
: object
with the assay data set
GetAssayData
and SetAssayData
have been superseded. To fetch
expression matrices, use LayerData
; to set expression data,
use LayerData<-
# Get assay data from the default assay in a Seurat object
GetAssayData(object = pbmc_small, layer = "data")[1:5,1:5]
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#> ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA
#> MS4A1 . . . .
#> CD79B 4.968821 . . .
#> CD79A . . . .
#> HLA-DRA . 4.776153 . .
#> TCL1A . . . .
#> AGTCAGACTGCACA
#> MS4A1 .
#> CD79B .
#> CD79A .
#> HLA-DRA 4.074201
#> TCL1A .
# Set an Assay layer through the Seurat object
count.data <- GetAssayData(object = pbmc_small[["RNA"]], layer = "counts")
count.data <- as.matrix(x = count.data + 1)
new.seurat.object <- SetAssayData(
object = pbmc_small,
layer = "counts",
new.data = count.data,
assay = "RNA"
)
# Get the data directly from an Assay object
GetAssayData(pbmc_small[["RNA"]], layer = "data")[1:5,1:5]
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#> ATGCCAGAACGACT CATGGCCTGTGCAT GAACCTGATGAACC TGACTGGATTCTCA
#> MS4A1 . . . .
#> CD79B 4.968821 . . .
#> CD79A . . . .
#> HLA-DRA . 4.776153 . .
#> TCL1A . . . .
#> AGTCAGACTGCACA
#> MS4A1 .
#> CD79B .
#> CD79A .
#> HLA-DRA 4.074201
#> TCL1A .
# Set an Assay layer directly
count.data <- GetAssayData(pbmc_small[["RNA"]], layer = "counts")
count.data <- as.matrix(x = count.data + 1)
new.assay <- SetAssayData(pbmc_small[["RNA"]], layer = "counts", new.data = count.data)