smorabit / hdWGCNA

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

Error with MetaspotsByGroups #179

Closed Prakrithi-P closed 5 months ago

Prakrithi-P commented 5 months ago

Hi Sam, I have been using hdWGCNA for a while but never faced this issue earlier. Could you please help me with it? The code and error are below

construct metacells in each group

seu_wgcna <- MetaspotsByGroups( S4_wgcna, group.by = c("cell_type"), ident.group = "cell_type", assay = 'Spatial', slot = 'counts' )

Error in (function (cur_seurat, mode = "sum", assay = "Spatial", slot = "counts") : More than one sample present in grouping. Please specify a metadata column with group.by indicating different ST samples.

Thanks, Prakrithi

smorabit commented 5 months ago

Hi Prakrithi,

Thanks for your interest in hdWGCNA and for taking the time to write an issue. Just checking that you are indeed using Visium spatial transcriptomics data? Can you tell me more about this data, do you have more than 1 image in the Seurat object or is it just 1 image? How big is the dataset? Any other info that you think may be relevant.

Prakrithi-P commented 5 months ago

Thanks for the prompt response Sam, I am using Visium data. It has just one image

An object of class Seurat 33539 features across 1298 samples within 1 assay Active assay: Spatial (33539 features, 2000 variable features) 2 dimensional reductions calculated: pca_genes, umap_genes 1 image present: S4

The h5 file is just 7MB.

smorabit commented 5 months ago

Hi, could you tell me what the output is when you run this command on your Seurat object:

Images(S4_wgcna)
Prakrithi-P commented 5 months ago

Images(S4_wgcna) [1] "S4"

This is what I get

smorabit commented 5 months ago

This error can be triggered when your Seurat object is missing key information about the spatial transcriptomic coordinates.

The image in your Seurat object (named S4) should have a table containing the coordinates. Can you check that this exists in your Seurat object:

head(S4_wgcna@images$S4@coordinates)
Prakrithi-P commented 5 months ago

Ah so the Brcode IDs in S4_wgcna@images$S4@coordinates did not match with the colnames(S4_WGCNA) and the metadata rownames ( like ATGCTAGCTTTT-1 and ATGCTAGCTTTT.1) . I corrected that and it worked fine. Thank you so much. I would not have thought of it that way. :)

smorabit commented 5 months ago

Glad that it worked for you!