immunogenomics / harmony

Fast, sensitive and accurate integration of single-cell data with Harmony
https://portals.broadinstitute.org/harmony/
Other
526 stars 99 forks source link

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

Open Sophiesze opened 4 years ago

Sophiesze commented 4 years ago

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.

aoumess commented 4 years ago

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)...

slowkow commented 4 years ago

Hi @Sophiesze, thanks for reporting the issue.

You might consider sharing more information:

bobermayer commented 3 years ago

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)

HYsxe commented 3 years ago

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

lizhiweiyy commented 3 years ago

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")
shivamjgandhi commented 3 years ago

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

slowkow commented 3 years ago

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