harmony icon indicating copy to clipboard operation
harmony copied to clipboard

Error in data.use %*% cell.embeddings : non-conformable arguments

Open Sophiesze opened this issue 4 years ago • 7 comments

Hello,

I have met the same issue as previously described by yejg2017. When I was trying to RunHarmony with my 10X-ATAC data (reduction = 'lsi'), harmony did not work well.

Harmony converged after 8 iterations
Error in data.use %*% cell.embeddings : non-conformable arguments
Calls: RunHarmony -> RunHarmony.Seurat -> <Anonymous>
In addition: Warning message:
Quick-TRANSfer stage steps exceeded maximum (= 2252350)
Execution halted

Is it possible that you can help me with this problem? Thanks so much.

Sophiesze avatar Apr 25 '20 12:04 Sophiesze

Hi, Same error here using a custom reduction object based on scBFA reduction metho (but this reduction object works with any other method or package i've tried till now)...

aoumess avatar May 13 '20 10:05 aoumess

Hi @Sophiesze, thanks for reporting the issue.

You might consider sharing more information:

  • What is reduction = 'lsi'?
  • Could you share a complete code snippet that we can run on our machines to reproduce your error?
  • Could you please share the complete output of sessionInfo(), so we know which version of harmony you are using?
  • Is it possible to share the dimensions of your dataset?
  • Is it possible to share a dataset that causes this error so we can run it on our machines and see if we can fix it?

slowkow avatar Jul 06 '20 14:07 slowkow

I'm encountering the same error with 10X scATAC-seq data. it appears during a call to ProjectDim, where the assay is not properly set (see #1849)

proposed fix to Runharmony.R#L159

    object <- Seurat::ProjectDim(
      object,
      reduction = reduction.save,
      assay = assay.use,
      overwrite = TRUE,
      verbose = FALSE
    )

(but make sure that assay.use also has been scaled, because ProjectDim accesses this slot)

bobermayer avatar Feb 08 '21 11:02 bobermayer

Hi all,

I also ran into the same issue. If I understand correctly, the ProjectDim part in the harmony source code is trying to project the batch corrected embedding back to the original feature loading (is that right?). Therefore I guess if you only need the corrected embedding but not the corrected original data we can do something like RunHarmony(data, "batch", project.dim = F). Setting project.dim avoids invoking the ProjectDim function and solved my problem.

In addition, the project.dim argument was not found in the documentation at https://www.rdocumentation.org/packages/harmony/versions/1.0/topics/RunHarmony so it took me sometime to dig this out. It might be nice to include it in the documentation.

Thanks

HYsxe avatar Feb 22 '21 20:02 HYsxe

Using project.dim = F is OK, but in fact, this error is because assay.use was not correctly set, the default is assay.use = "RNA", when you use other assays, such as SCT or integrated, it should be explicitly set to solved the problem:

object <- RunHarmony(object = object,group.by.vars = "var",assay.use = "SCT")
object <- RunHarmony(object = object,group.by.vars = "var",assay.use = "integrated")

lizhiweiyy avatar Sep 01 '21 10:09 lizhiweiyy

I'm also running into the same issue, but the assay I'm using is "RNA"

I use the following command: seurObj <- RunHarmony(object = data, group.by.vars = "batch", assay.use='RNA')

And then I run into the issue: Harmony converged after 3 iterations Error in data.use %*% cell.embeddings : non-conformable arguments

I tried it without projecting back to the original dimensions. I see that dim(cell.embeddings) is (34068, 50) while the original expression matrix's dimension is (36601, 34068). In the original expression matrix, 36601 is the number of features and 34068 is the number of samples. I'm curious why I'd continue running into this problem. Please let me know if you have any insights

shivamjgandhi avatar Sep 30 '21 20:09 shivamjgandhi

@shivamjgandhi You might consider making a reprex, so we can reproduce the same error that you are reporting.

slowkow avatar Oct 01 '21 19:10 slowkow