smorabit / hdWGCNA

High dimensional weighted gene co-expression network analysis
https://smorabit.github.io/hdWGCNA/
Other
316 stars 31 forks source link

MetacellsByGroups function, I get an error #100

Closed cccccdoinb closed 1 year ago

cccccdoinb commented 1 year ago

When I run the MetacellsByGroups function, I get an error and can't find a solution, how do I fix it?

seurat_obj <- MetacellsByGroups(

  • seurat_obj = seurat_obj,
  • group.by = c("celltype", "stage"), # specify the columns in seurat_obj@meta.data to group by
  • k = 40, # nearest-neighbors parameter
  • reduction = "pca",
  • slot='counts',
  • min_cells = 5,
  • max_shared = 10, # maximum number of shared cells between two metacells
  • ident.group = 'celltype',
  • mode = "average",# set the Idents of the metacell seurat object
  • ) Error in apply(cell_sample, 1, function(x) { : dim(X)的值必需是正数
smorabit commented 1 year ago

Hard for me to tell what is going on without more information, but I am guessing that your min_cells is too low. Try making min_cells > k.

Also, I am wondering if you can reproduce this error using the tutorial dataset?

Montsecb commented 1 year ago

Hi, I get the same error, even if I set min_cells > k. If the number of min_cells is greater than 100, it works. Here is my code:

seurat_obj <- MetacellsByGroups(seurat_obj,
                                group.by = c("Subtypes"), # specify the columns in seurat_obj@meta.data to group by
                                reduction = 'pca', # select the dimensionality reduction to perform KNN on
                                k = 25, # nearest-neighbors parameter
                                min_cells = 70,
                                max_shared = 5, # maximum number of shared cells between two metacells
                                ident.group = 'Subtypes', # set the Idents of the metacell seurat object
                                assay="RNA", 
                                slot="counts")
smorabit commented 1 year ago

Are you able to reproduce the error on the tutorial dataset or some other publicly available data?

Montsecb commented 1 year ago

Hi, I have followed the tutorial with the example dataset you provide and no errors appear with k=25 and min_cells=70. Could it be due to the number of cells in my data? I was trying to create metacells with around 6k cells.

smorabit commented 1 year ago

Hmm I am not sure what could be causing your issue at this time since I am not able to reproduce it. I will need to be able to reproduce the error in order to help resolve it.

smorabit commented 1 year ago

Closing for now but happy to look into this if a reproducible example is provided.

mmzielonka commented 1 month ago

Hi @Montsecb and @cccccdoinb , did you ever resolve this issue? I am encountering the same error in my dataset. thank you!