Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

AssayData

Get and Set Assay Data


Description

General accessor and setter functions for Assay objects. GetAssayData can be used to pull information from any of the expression matrices (eg. “counts”, “data”, or “scale.data”). SetAssayData can be used to replace one of these expression matrices

Usage

GetAssayData(object, 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, ...)

Arguments

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

Value

GetAssayData: returns the specified assay data

SetAssayData: object with the assay data set

Examples

# 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)

SeuratObject

Data Structures for Single Cell Data

v4.0.1
GPL-3
Authors
Rahul Satija [aut] (<https://orcid.org/0000-0001-9448-8833>), Andrew Butler [aut] (<https://orcid.org/0000-0003-3608-0463>), Paul Hoffman [aut, cre] (<https://orcid.org/0000-0002-7693-8957>), Tim Stuart [aut] (<https://orcid.org/0000-0002-3044-0897>), Jeff Farrell [ctb], Shiwei Zheng [ctb] (<https://orcid.org/0000-0001-6682-6743>), Christoph Hafemeister [ctb] (<https://orcid.org/0000-0001-6365-8254>), Patrick Roelli [ctb], Yuhan Hao [ctb] (<https://orcid.org/0000-0002-1810-0822>)
Initial release
2021-05-07

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.