Learn R Programming

Seurat (version 3.1.1)

Idents: Get, set, and manipulate an object's identity classes

Description

Get, set, and manipulate an object's identity classes

Usage

Idents(object, ...)

Idents(object, ...) <- value

RenameIdents(object, ...)

ReorderIdent(object, var, ...)

SetIdent(object, ...)

StashIdent(object, save.name, ...)

# S3 method for Seurat Idents(object, ...)

# S3 method for Seurat Idents(object, cells = NULL, drop = FALSE, ...) <- value

# S3 method for Seurat ReorderIdent(object, var, reverse = FALSE, afxn = mean, reorder.numeric = FALSE, ...)

# S3 method for Seurat RenameIdents(object, ...)

# S3 method for Seurat SetIdent(object, cells = NULL, value, ...)

# S3 method for Seurat StashIdent(object, save.name = "orig.ident", ...)

# S3 method for Seurat levels(x)

# S3 method for Seurat levels(x) <- value

Arguments

...

Arguments passed to other methods; for RenameIdents: named arguments as old.ident = new.ident; for ReorderIdent: arguments passed on to FetchData

value

The name of the identites 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 mean

reorder.numeric

Rename all identity classes to be increasing numbers starting from 1 (default is FALSE)

x, object

An object

Value

Idents: The cell identies

Idents<-: An object with the cell identites changed

RenameIdents: An object with selected identity classes renamed

ReorderIdent: An object with

SetIdent: An object with new identity classes set

StashIdent: An object with the identities stashed

Examples

Run this code
# NOT RUN {
# Get cell identity classes
Idents(object = pbmc_small)

# Set cell identity classes
# Can be used to set identities for specific cells to a new level
Idents(object = pbmc_small, cells = 1:4) <- 'a'
head(x = Idents(object = pbmc_small))

# Can also set idents from a value in object metadata
colnames(x = pbmc_small[[]])
Idents(object = pbmc_small) <- 'RNA_snn_res.1'
levels(x = pbmc_small)

# Rename cell identity classes
# Can provide an arbitrary amount of idents to rename
levels(x = pbmc_small)
pbmc_small <- RenameIdents(object = pbmc_small, '0' = 'A', '2' = 'C')
levels(x = pbmc_small)

# }
# NOT RUN {
head(x = Idents(object = pbmc_small))
pbmc_small <- ReorderIdent(object = pbmc_small, var = 'PC_1')
head(x = Idents(object = pbmc_small))
# }
# NOT RUN {
# Set cell identity classes using SetIdent
cells.use <- WhichCells(object = pbmc_small, idents = '1')
pbmc_small <- SetIdent(object = pbmc_small, cells = cells.use, value = 'B')

head(x = pbmc_small[[]])
pbmc_small <- StashIdent(object = pbmc_small, save.name = 'idents')
head(x = 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)

# }

Run the code above in your browser using DataLab