This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Seurat Metadata to Dataframe Manipulation

This is perhaps a question that is too simple, but I have been stuck on this for the past two hours.

I currently have a Seurat object and converted this into a data frame for further processing with another file. I need a certain pattern removed from the row names such that I am only left with the Cell IDs. Right now I have:

flox_1_TCAGAT-1
ko_1_TAGCAA-1

flox_2_TCAGAT-1
ko_2_TAGCAA-1

flox_3_TCAGAT-1
ko_3_TAGCAA-1

flox_4_TCAGAT-1
ko_4_TAGCAA-1

My approach has been:

rownames(df)<- sub("flox_1", " ", as.character(rownames(df)))

However when I reapply this again for flox_2, ko_1, ko_2, ko_3, etc. I receive the error: Error in .rowNamesDF<-(x, value = value) : duplicate 'row.names' are not allowed

Any other suggestions on how to mitigate this issue?

rstudio seurat scrna-seq

1 answer

rownames must be "unique". Your barcodes are duplicated between different samples. There is no way to replace your rownames with these barcodes because of this issue.

I may have oversimplified it too much. The row names are cell ids for one sample, CKO_AO2_TTTCCTCTCCTTGACC-1

CKO_AO2_ACACCCTAGCAAATCA-1

FLOX_AO1_CCTCTGAGTACTCAAC-1

I need to intersect these cell ids with another sample. The pattern for the reference dataset is: TTTCCTCTCCTTGACC-1

ACACCCTAGCAAATCA-1

CCTCTGAGTACTCAAC-1

I don't get your point.

What do you really want to do and what data do you have right now?

Log in to answer this question.