cran / Seurat

:exclamation: This is a read-only mirror of the CRAN R package repository. Seurat — Tools for Single Cell Genomics. Homepage: https://satijalab.org/seurat, https://github.com/satijalab/seurat Report bugs for this package: https://github.com/satijalab/seurat/issues
Other
4 stars 0 forks source link

Using Idents to add column for samples per barcode #1

Open mbartl13 opened 1 year ago

mbartl13 commented 1 year ago

Hi- I am attempting to repeat what worked previously on a smaller data set where I added in a column to re-assign cell IDs to a specific sample. I have several longitudinal samples which I ran using cellranger multi v07 and when loading into Seurat all samples are denoted as "-1". However, this dataset is considerably larger than the previous one. Any tips/suggestions for how to perform something similar to what I performed previously at scale? Thanks!

Create table for how samples should be partitioned

example_meta_by_sample` <- tibble::tribble(
  ~orig.ident,  ~sample_
name,
1,  "   1001",
2,  "   1002 ",
3,  "   1003",
4,  "   1560")

Change orig.ident column to factor so that it can be joined later

example_meta_by_sample$orig.ident <- as.factor(example_meta_by_sample$orig.ident)
metadata <- read_csv("metasmall.csv")

metasmall_v02.xlsx

Pull existing meta data where samples are specified by orig.ident and remove everything but orig.ident

OBJ_meta <- SeuratObject@meta.data %>% 
  select(orig.ident) %>% 
  rownames_to_column("barcodes")

Use full join with object meta data in x position so that by sample meta dataframe is propagated across the by cell meta dataframe from the object and then remove orig.ident because it's already present in object meta data.

full_new_meta <- full_join(x = OBJ_meta, y = example_meta_by_sample) %>% 
  column_to_rownames("barcodes") %>% 
  select(-orig.ident)

Add to object to graph by treatment groups

SeuratObject <- AddMetaData(object = SeuratObject, metadata = full_new_meta)

gaborcsardi commented 1 year ago

Hi, this is a read only mirror of CRAN, please see the package authors in the DESCRIPTION file. Look for Maintainer, BugReports and URL. Thanks!

mbartl13 commented 1 year ago

Got it thanks!


From: Gábor Csárdi @.> Sent: Monday, August 28, 2023 7:32 AM To: cran/Seurat @.> Cc: Maggie Linn Bartlett @.>; Author @.> Subject: Re: [cran/Seurat] Using Idents to add column for samples per barcode (Issue #1)

  External Email - Use Caution

Hi, this is a read only mirror of CRAN, please see the package authors in the DESCRIPTION file. Look for Maintainer, BugReports and URL. Thanks!

— Reply to this email directly, view it on GitHubhttps://github.com/cran/Seurat/issues/1#issuecomment-1695534324, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARPWQ5DUKXUP2ERQ3E7ZM6TXXR6WXANCNFSM6AAAAAA4BIHOQA. You are receiving this because you authored the thread.Message ID: @.***>