smorabit / hdWGCNA

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

MetaspotsByGroups ERROR: invalid class “Assay5” object: Layers must be two-dimensional objects #317

Open dylanwudy opened 1 month ago

dylanwudy commented 1 month ago

Hi,

I'm trying to use the MetaspotsByGroups function with multiple variables from meta.data, including "case," "batch," "region," and "distance." However, when I include the "distance" variable, I encounter an error stating: "invalid class 'Assay5' object: Layers must be two-dimensional objects" in CreateAssay5Object when there are NA in the distance; and it shows "'data' must be of a vector type, was 'NULL'." when I changed all the values to numeric, the issue persisted. When removing the distance variable, the code can run normally. Could this be because the group.by parameter does not support continuous variables? If so, how can I incorporate the "distance" variable to meet the requirements for using it in the hdWGCNA analysis? seurat_wgcna_1 <- MetaspotsByGroups( seurat_obj = seurat_wgcna, assay='py', group.by = c("case","batch","region","distance"), ident.group = "batch" )

smorabit commented 1 month ago

The variables that you include in group.by should be categorical variables, not continuous. I am guessing that distance is a continuous variable, so in this case you should not use it.