carmonalab / ProjecTILs

Interpretation of cell states using reference single-cell maps
GNU General Public License v3.0
234 stars 27 forks source link

'RNA' not in 'altExpNames(<SingleCellExperiment>) when filter.cells= TRUE #11

Closed mihem closed 3 years ago

mihem commented 3 years ago

If I follow the tutorial:

library(ProjecTILs)
ref <- load.reference.map()
querydata <- ProjecTILs::query_example_seurat
query.projected <- make.projection(querydata, ref = ref, filter.cells = TRUE)

It interrupts with the following error:

Error in value[[3L]](cond) : 
  invalid subscript 'e' in 'altExp(<SingleCellExperiment>, type="character", ...)':
  'RNA' not in 'altExpNames(<SingleCellExperiment>)'

traceback:

17: stop("invalid subscript '", substr, "' in '", funstr, "(<", class(x), 
        ">, type=\"character\", ...)':\n  ", "'", index, "' not in '", 
        namestr, "(<", class(x), ">)'")
16: value[[3L]](cond)
15: tryCatchOne(expr, names, parentenv, handlers[[1L]])
14: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch({
        internals[, index]
    }, error = function(err) {
        stop("invalid subscript '", substr, "' in '", funstr, "(<", 
            class(x), ">, type=\"character\", ...)':\n  ", "'", index, 
            "' not in '", namestr, "(<", class(x), ">)'")
    })
12: .get_internal_character(x, e, getfun = int_colData, key = .alt_key, 
        funstr = "altExp", substr = "e", namestr = "altExpNames")
11: .local(x, e, ...)
10: altExp(x, name, withColData = withColData)
9: altExp(x, name, withColData = withColData)
8: SingleCellExperiment::swapAltExp(x = sce, name = assayn, saved = orig.exp.name)
7: as.SingleCellExperiment.Seurat(query.object)
6: as.SingleCellExperiment(query.object)
5: filterCells(query, human = human.ortho)
4: projection.helper(query = query.list[[i]], ref = ref, filter.cells = filter.cells, 
       query.assay = query.assay, direct.projection = direct.projection, 
       seurat.k.filter = seurat.k.filter, skip.normalize = skip.normalize, 
       id = names(query.list)[i])
3: FUN(X[[i]], ...)
2: lapply(X = 1:length(query.list), FUN = function(i) {
       res <- projection.helper(query = query.list[[i]], ref = ref, 
           filter.cells = filter.cells, query.assay = query.assay, 
           direct.projection = direct.projection, seurat.k.filter = seurat.k.filter, 
           skip.normalize = skip.normalize, id = names(query.list)[i])
       return(res)
   })
1: make.projection(querydata, ref = ref, filter.cells = TRUE)

If I turn of filter cells by setting filter.cells = FALSE, everything works fine.

ProjecTILs_1.0.0 Matrix_1.3-3 TILPRED_1.0.2 umap_0.2.7.0 SeuratObject_4.0.1 Seurat_4.0.2

mass-a commented 3 years ago

Hello, can I ask you what version of Bioconductor you have installed? and what version of SingleCellExperiment?

mihem commented 3 years ago

Of course, sorry I forgot about that. SingleCellExperiment_1.14.1 Bioconductor 3.13

mass-a commented 3 years ago

I have now been able to reproduce your bug. It is actually a problem with the latest update of Seurat (4.0.2), where conversion to SingleCellExperiment objects fails, as reported here: https://github.com/satijalab/seurat/issues/4531

While the problem is being solved you may downgrade to Seurat 4.0.1 which should work fine.

Thanks, -m

mihem commented 3 years ago

Ah i am sorry, i thought this was related to ProjecTIL. Thanks for linking that.