For purposes of anonymization I need to rename the cell-names which include the study number in our dataset.
I have a Seurat-object with test@assays$RNA$counts@Dimnames[2]) and test@assays$SCT$counts@Dimnames[2]) having for instance: "aab1.P2.299" "aab1.P2.311" "aab1.P2.315" "aab1.P2.318" "aab1.P2.319" "aab1.P2.321" "aab1.P2.322" "aab1.P2.338" "aab1.P2.349".
Here's what I did.
First, I got the list of original cell names in a new column:
[email protected]$orig.cellname <- unlist(c(test@assays$RNA$counts@Dimnames[2]))
Next, I split this column:
[email protected] <- [email protected] %>% separate(orig.cellname, c('Cell_SNR', 'Cell_Plate', 'Cell_nr'))
Then I created a new cellname:
[email protected]$new.cellname <- paste(test$SampleID, test$Cell_Plate, test$Cell_nr, sep = ".")
Where SampleID is a new anonymized sample ID.
Finally, I apply RenameCell.
test <- RenameCells(test, new.names = [email protected]$new.cellname)
Here I assume the dimnames will be replaced throughout the SeuratObject, so at test@assays$RNA$counts, test@assays$RNA$data, test@assays$SCT$counts, and test@assays$SCT$data, but also at test@graphs$SCT_nn, and test@graphs$SCT_snn.
I get this error:
Error in new.cell.names.global[match(x = working.cells, table = old.names)] <- new.cell.names :
NAs are not allowed in subscripted assignments
I don't get this as far as I can see there aren't any 'NAs' in my new column.
I did search Google and found a few hints, which didn't help me further.
Solution 1:
https://github.com/broadinstitute/infercnv/issues/396
options(scipen = 10000)
test <- RenameCells(test, new.names = [email protected]$new.cellname)
Still produces the same error.
I am not sure how to move forward from here. Any advice or suggestions would be great.
P.S. for obvious reasons I can't provide example data here.