satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.26k stars 906 forks source link

Looking for a cluster that contains a cell barcode by typing in the cell barcode #5297

Closed csung331 closed 2 years ago

csung331 commented 2 years ago

I have two snRNAseq integrated datasets that were analyzed slightly differently and would like to find the cluster of cells that I have been working with in one dataset (dataset-1) in the other dataset (dataset-2).

I am able to obtain the list of cell barcodes from my cluster of interest in dataset-1. Is there an R code that I can use that when I enter one barcode (or several) that I found from dataset-1, R/Seurat will search through dataset-2 and will let me know which cluster this barcode (from dataset-1) is found in?

Thank you!

samuel-marsh commented 2 years ago

Hi,

Not member of dev team but hopefully can be helpful. You can get this info either through Seurat or R.

cells <- c("barcode1", "barcode2", etc)

# Seurat
cluster_info <- FetchData(object = obj_name, vars = "ident", cells = cells)

# R/tidyverse
library(dplyr)
library(tibble)

cluster_info <- data.frame(Idents(obj_name)) %>% 
  rownames_to_column("barcodes") %>% 
  filter(barcodes %in% cells)

Best, Sam

mhkowalski commented 2 years ago

I agree with Sam's solution.

csung331 commented 2 years ago

I apologize for the delayed response. Thank you very much for the R code. It worked!!