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

Bug in Seurat's wrapper function #292

Open
soheilj opened this issue Oct 31, 2023 · 1 comment
Open

Bug in Seurat's wrapper function #292

soheilj opened this issue Oct 31, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@soheilj
Copy link

soheilj commented Oct 31, 2023

Hi,

I think the following part in the RunOptimizeALS() SeuratWrapper function has potentially a bug.

   split.cells <- split(x = colnames(x = object), f = split.by)
   scale.data <- lapply(X = split.cells, FUN = function(x) {
      return(t(x = GetAssayData(object = object, slot = "scale.data",
                                assay = assay)[, x]))
   })
   out <- rliger::optimizeALS(object = scale.data, k = k, lambda = lambda,
                              thresh = thresh, max.iters = max.iters, nrep = nrep,
                              H.init = H.init, W.init = W.init, V.init = V.init, rand.seed = rand.seed,
                              print.obj = print.obj)
   colnames(x = out$W) <- VariableFeatures(object = object)

Fetching the scaled data matrix from the Seurat object without specifying the gene order would not necessarily have the same order of genes as appears in the VariableFeatures() function. So in the last line, gene names can be assigned to column names of the out$W matrix in an incorrect order.

I think adding the gene order after the GetAssayData() would be an easy fix.

   scale.data <- lapply(X = split.cells, FUN = function(x) {
      return(t(x = GetAssayData(object = object, slot = "scale.data",
                                assay = assay)[VariableFeatures(object = object), x]))
   })
@theAeon theAeon added the bug Something isn't working label Nov 2, 2023
@mvfki
Copy link
Collaborator

mvfki commented Mar 25, 2024

That's a great catch!

We just made a new release of rliger package 2.0. And we are abandoning the seurat wrappers since we allowed the native Seurat object support in the new version. I.e. you can directly call a rliger function using a Seurat object now. The rliger wrapper functions in SeuratWrappers package is not yet updated accordingly but we are planning on deprecating them.

For the specific point you're making, I'm very sure that now the feature names come directly from the scaled matrix objects. And it doesn't matter if you use a Seurat or liger object.

Yichen

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

3 participants