I am new to single-cell RNA sequencing and am trying to add additional metadata to my Seurat object. The problem is that the methods I’m using (merge, left_join, full_join, AddMetaData, etc) change the dimensions of my metadata or simply do not work. The errors I am receiving using either method is:
1.) Warning: Cannot add more or less meta data without cell names
2.) Detected an unexpected many-to-many relationship between
xand
y. ℹ Row 1 of
xmatches multiple rows in
y. ℹ Row 4518236 of
ymatches multiple rows in x. ℹ If a many-to-many relationship is expected, set relationship = "many-to-many"\ to silence this warning
So far I have tried:
1.) MANIPULATING METADATA AFTER SEURAT OBJECT CREATION:
CONTEXT: the following code below is me reading in my files, creating a seurat object (sobj), and trying to manipulate the metadata to incorporate 1 other metadata file called “mapping”. The Goal is to get the individual’s sex, genotype, and diagnosis incorporated into the metadata before differential testing.
`barcodes <- synGet("syn23554294", downloadLocation="~/Downloads")
genes <- synGet("syn23554293", downloadLocation="~/Downloads")
mtx <- synGet("syn23554292", downloadLocation="~/Downloads")
metadata <- synGet("syn23554294", downloadLocation="~/Downloads")
counts <- ReadMtx(mtx = mtx$path,
cells = barcodes$path,
features = genes$path,
feature.column = 1,
skip.cell = 1,
skip.feature = 1)
sobj <- CreateSeuratObject(counts, meta.data = metadata) # works fine`
head(metadat_aug16)
dim(metadata_aug16) # 74153 16
dim(sobj) # 28781 172659
These dimensions obviously do not match up!
head(sobj)
SOBJ: Seurat Object
2.) MANIPULATING DATA BEFORE CREATING SEURAT OBJECT
CONTEXT: I also tried extracting the metadata from Seurat as a dataframe, editing it with the info I needed, then resubmitting ‘m’ back as the metadata for the Seurat object. This works for the following code, but then I don’t know how to go back and add even more information about the clinical info (sex, genotype, etc) especially when each individual and their cells are represented more than once in the metadata object / dataframe.
m <- as.data.frame([email protected]) # make into df and test seurat after
head(m) m$cell <- rownames(m) # save rownames (cells) as cell column
m$barcode <- substr(m$cell, 21, 36) # make barcode column
head(m)
dim(m) # 172659 5
dataframe called ‘m’
**Can anyone help me find a way to do this? Thank you so much for any help or guidance. **
I tried lots of manipulations using dplyr and Seurat “AddMetaData” and get errors each time.
Melise Edwards is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.