R: Add in metadata associated with either cells or features.

AddMetaData {SeuratObject} | R Documentation

## Add in metadata associated with either cells or features.

### Description

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"]]`)

### Usage

    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)

### Arguments

`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

### Value

`object` with metadata added

### Examples

    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[[]])

[Package SeuratObject version 4.0.3 Index]