Add meta data from ample level data.frame/tibble to cell level seurat @meta.data slot

Add_Sample_Meta(
  seurat_object,
  meta_data,
  join_by_seurat,
  join_by_meta,
  na_ok = FALSE,
  overwrite = FALSE
)

Arguments

seurat_object

object name.

meta_data

data.frame/tibble containing meta data or path to file to read. Must be formatted as either data.frame or tibble.

join_by_seurat

name of the column in seurat_object@meta.data that contains matching variables to join_by_meta in meta_data.

join_by_meta

name of the column in meta_data that contains matching variables to join_by_seurat in seurat_object@meta.data.

na_ok

logical, is it ok to add NA values to seurat_object@meta.data. Default is FALSE. Be very careful if setting TRUE because if there is error in join operation it may result in all @meta.data values being replaced with NA.

overwrite

logical, if there are shared columns between seurat_object@meta.data and meta_data should the current seurat_object@meta.data columns be overwritten. Default is FALSE. This parameter excludes values provided to join_by_seurat and join_by_meta.

Value

Seurat object with new @meta.data columns

Examples

if (FALSE) {
# meta_data present in environment
sample_level_meta <- data.frame(...)
obj <- Add_Sample_Meta(seurat_object = obj, meta_data = sample_level_meta,
join_by_seurat = "orig.ident", join_by_meta = "sample_ID")

# from meta data file
obj <- Add_Sample_Meta(seurat_object = obj, meta_data = "meta_data/sample_level_meta.csv",
join_by_seurat = "orig.ident", join_by_meta = "sample_ID")
}