How to add labels to a Seurat object, matching the barcodes?
Hi, I'm trying to add a file that contains barcode-label pairs to a Seurat object I have. The file looks like this:
Cells 0
ATGATCGTCTACCACC Cluster 6
GAAGCCCAGTTACTCG Cluster 2
CAAGCTACACGGTGTC Cluster 7
CACAACACACAGTATC M8
CATCCACGTTCGGTTA Cluster 2
ATGCATGGTGTGGTCC Cluster 3
ACCCTTGTCTCGGGAC Cluster 6
The issue is that the barcodes in this new file do not match the barcodes or the matrix file I originally used to create the Seurat object. It contains fewer rows due to different filtering standards. Is there a way to merge these two files and removing rows that do not appear in the labels file?
Thank you!
• 6,977 views
•
link
1 answer
Filtering and joining your label file (e.g. naming metasample after reading to R) based on the barcodes that existed in the seurat object (e.g. seu_obj@meta.data).
# the only common colname in the 2 objects should be the barcode column (Cells).
meta_data <- dplyr::left_join(seu_obj@meta.data, metasample, by=Cells)
# check meta_data if correct.
seu_obj@meta.data <- meta_data
• 0 views
•
link
Log in to answer this question.
How did you add a cluster column with barcode?