Hi, I have exactly the same problem mentioned in this post: fail to annotate chromosome data to single cell object When annotating my single cell data obtained from cellranger (with their latest human (GRCh38) reference) using AnnotationHub, some of my genes (about 200) cannot be annotated. I tried to use different versions of EnsDb but this does not help. My codes are here:
ah <- AnnotationHub()
ens.hs.107<- query(ah, c("Homo sapiens", "EnsDb", 107))[[1]]
genes <- rowData(sce)$ID #sce is my single cell object
gene_annot <- AnnotationDbi::select(ens.hs.107,
keys = genes,
keytype = "GENEID",
columns = c("GENEID", "SEQNAME")) %>% set_names(c("ID", "Chromosome"))
rowData(sce) <- merge(rowData(sce), gene_annot, by = "ID", sort=FALSE)
----
Error in .local(x, ..., value = value) :
34085 rows in value to replace 34202rows
Does this include anything you could not get from the GTF that ships with CellRanger? GeneID and chromosome is part of the GTF, so simply load it via
rtracklayer::import
and filter for what you need.