Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RenameCell error when replacing cell-names #184

Open
swvanderlaan opened this issue Feb 23, 2024 · 0 comments
Open

RenameCell error when replacing cell-names #184

swvanderlaan opened this issue Feb 23, 2024 · 0 comments

Comments

@swvanderlaan
Copy link

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:

test@meta.data$orig.cellname <- unlist(c(test@assays$RNA$counts@Dimnames[2]))

Next, I split this column:

test@meta.data <- test@meta.data %>% separate(orig.cellname, c('Cell_SNR', 'Cell_Plate', 'Cell_nr'))

Then I created a new cellname:

test@meta.data$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 = test@meta.data$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 am not sure how to move forward from here. Any advice or suggestions would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant