0
$\begingroup$

I have a Seurat object of 8 patients. I want to add metadata to that so that I have origin of each cell. At the moment UMAP just shows a bunch of cells while I want to color clusters by sample

This is my metadata

> str(head(metadata))
'data.frame':   6 obs. of  3 variables:
 $ barcodes: chr  "AAACAGCCAAACTGCC-5" "AAACAGCCAACAGGAT-1" "AAACAGCCAAGATTCT-1" "AAACAGCCAAGGTATA-1" ...
 $ libcodes: Factor w/ 8 levels "1","2","3","4",..: 5 1 1 1 5 7
 $ samples : chr  "PN0252_0005" "PN0252_0001" "PN0252_0001" "PN0252_0001" ...
> 

> pbmc
An object of class Seurat 
36601 features across 26473 samples within 1 assay 
Active assay: RNA (36601 features, 0 variable features)
> 

> dim(metadata)
[1] 26473     3
> 
$\endgroup$
0
0
$\begingroup$

Answer from @user438383, converted from comment:

Did you try this function? This post may also be useful.

$\endgroup$
0
$\begingroup$

If you have single-dimension per-cell metadata, and it's arranged identically to the cell order in the Seurat object, I find it easier to use the double bracket notation to add metadata to a Seurat object. For example:

metadata$barcodes -> pbmc[["barcodes"]]
metadata$libcodes -> pbmc[["libcodes"]]
metadata$samples -> pbmc[["samples"]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.