satijalab / seurat-wrappers

Community-provided extensions to Seurat
GNU General Public License v3.0
305 stars 131 forks source link

IntegrateLayers using FastMNN gives error: 'batch' must be specified if '...' has only one object #191

Open yesitsjess opened 6 months ago

yesitsjess commented 6 months ago

I'm trying to run FastMNN on a Seurat object from an existing analysis where I previously used Harmony integration but now I want the expression values to be batch corrected so I'm trying to use fastMNN instead.

This is my call: int_obj1 <- IntegrateLayers(soup_obj, method=FastMNNIntegration, orig.reduction="pca", new.reduction="integrated.mnn", assay="SCT")

And I get the following error:

Converting layers to SingleCellExperiment
Running fastMNN
Error in .check_valid_batch(batches[[1]], batch = batch) : 
  'batch' must be specified if '...' has only one object

Each layer contains 1 batch - any advise on how to correct format it for use with FastMNNIntegration please?

erzakiev commented 5 months ago

I am not the dev, but I obtain the same issue when I accidentally integrate layers before running the IntegrateLayers with the FastMNNIntegration. If I don't integrate layers, everything works ok. I think what happens in your case is that SCT-integrated assay gets treated as a single object rather than multiple separate layers, hence the error.

Alternatively, if you cannot un-integrate the object, I suggest you provide the batch argument to IntegrateLayers with the vector of group affiliations for each cell (e.g. batch = soup_obj$orig.ident), and it might work.

callmekelvinn commented 4 months ago

i have the same issue too