smorabit / hdWGCNA

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

Question about exporting the networks to Metascape #223

Open DelongZHOU opened 2 months ago

DelongZHOU commented 2 months ago

Hi Sam, I wonder if there is a way to export the networks to Metascape so I can annotate the network with other information like protein-protein interaction or gene ontology association. Thank you!

smorabit commented 2 months ago

Hi,

I do not have a way to export to Metascape built in to hdWGCNA. I am not very familiar with Metascape but I will look into it and get back to you soon. I agree it would be interesting to have an export to Metascape option for hdWGCNA!

DelongZHOU commented 1 month ago

Hi Sam,

I just realized that I didn't mean Metascape but Cytoscape!

I found this tutorial here which uses functions from WGCNA that I'll try to implement. https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10500560/

As for Metascape it accepts gene list(s) as input and I think it's best to use their webserver / installed version instead of trying to interact it through R.

I don't know if I should change my original title / content - I'll leave it for you to decide.

Best, Delong

smorabit commented 1 month ago

Hi,

I am unfortunately not familiar with Cytoscape (or Metascape). I found this function include in the WGCNA package, maybe you could make use of it.

https://rdrr.io/cran/WGCNA/man/exportNetworkToCytoscape.html

DelongZHOU commented 1 month ago

Hi Sam, That's exactly the function used in the tuto that I cited earlier. I managed to adapt the process to hdWGCNA with the code below.

# Load data
seurat_obj<-readRDS('')
TOM <- GetTOM(seurat_obj)

# Print out the module names
modules <- GetModules(seurat_obj)
print(levels(modules$module))

# Select module to export
module_to_extract <- ''

# Get hubgenes
genes_df <- GetHubGenes(seurat_obj, n_hubs = 30)
modGenes <- genes_df[genes_df$module==module_to_extract,]$gene_name

# Select the corresponding Topological Overlap
modTOM <- TOM[modGenes, modGenes]
# Export 
cyt <- exportNetworkToCytoscape(modTOM,
                                edgeFile = paste0('hdWGCNA_to_Cyto.',module_to_extract,'.hub=30.edge.txt'),
                                nodeFile = paste0('hdWGCNA_to_Cyto.',module_to_extract,'.hub=30.node.txt'),
                                threshold = 0
                                )

I consider my issue solved. I'll leave it to you to decide whether to close the ticket.

Best, Delong