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

rename error when use RenameGenesSeurat #69

Closed
songlyzz opened this issue Mar 22, 2024 · 6 comments
Closed

rename error when use RenameGenesSeurat #69

songlyzz opened this issue Mar 22, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@songlyzz
Copy link

Description
Hi, vertesy:
When I use the function of RenameGenesSeurat, I got some errors that :
RNA@data is of type dgeCMatrix!
Error in validObject(object = x) :
The object with the category "LogMap" is incorrect: Rownames cannot be empty strings

Can you help me?I post my code below.

THANKS,
SONG

for (sample in folders ){ 
  sc_object <- CreateSeuratObject(
    counts = Read10X(file.path(sample), gene.column = 1),
    project = sample,
    min.cells = 3, min.features = 200
  )
  
  # rename 
  ids=mapIds(EnsDb.Mmusculus.v79,
             keys = rownames(sc_object), # the keys to select records for from the database.
             keytype="GENEID",
             columns="SYMBOL",
             column="SYMBOL")
  ids=as.data.frame(ids)
  ids$ENSEMBL=row.names(ids)
  ids=ids[!duplicated(ids$ids),]
  ids=ids[!duplicated(ids$ENSEMBL),]
  pos=match(ids$ENSEMBL,rownames(sc_object) )
  sc_object=sc_object[pos,]
  
  obj =RenameGenesSeurat(obj = sc_object,
                         newnames = ids$ids)
  sc_object<-obj[,-grep("NA",rownames(obj))]
}
@songlyzz songlyzz added the bug Something isn't working label Mar 22, 2024
@vertesy
Copy link
Owner

vertesy commented Mar 22, 2024

Hi Song, sure, happy to,

could you please tell me your version of:

  1. Seurat
  2. Seurat.utils
  3. the seurat version of sc_object.

This bug seems to be zombie: i solved it mutiple times, but keeps coming back

@songlyzz
Copy link
Author

Hi ,
I changed my code like this:

ids=select(org.Mm.eg.db,keys = rownames(sc_object),
             columns = c('ENSEMBL','SYMBOL'),
             keytype = 'ENSEMBL')
  head(ids)
  dim(ids) # 
  ids=na.omit(ids)
  dim(ids) 
  length(unique(ids$SYMBOL)) # 
  ids=ids[!duplicated(ids$SYMBOL),]
  ids=ids[!duplicated(ids$ENSEMBL),]
  pos=match(ids$ENSEMBL,rownames(sc_object) )
  sc_object=sc_object[pos,]
  
  sc_object =RenameGenesSeurat(obj = sc_object,
                         newnames = ids$SYMBOL)

This time it do well !

THANKS,
SONG

@vertesy
Copy link
Owner

vertesy commented Mar 22, 2024

great!

@vertesy vertesy closed this as completed Mar 22, 2024
@songlyzz
Copy link
Author

Hi vertesy,
Now I have an another problem that in the org.Mm.eg.db, I did not have like "mt-" mitochondrial genes, how can I filter it when the name is not standard for PercentageFeatureSet(sc_object, pattern = "^mt-") function that in order to QC.

THANKS,
SONG

@vertesy
Copy link
Owner

vertesy commented Mar 22, 2024

I am sorry but this goes beyond what I can support.
PercentageFeatureSet is anyways Seurat, not this package

@songlyzz
Copy link
Author

Hi vertesy:
Thank you very much! I know why my first method is not work, because here is a empty symbol gene name to match the ensembl id, but the org.Mm.eg.db database matches it, so the second one work well.
I can fix them together to solve the problem.

THANKS,
SONG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants