BaderLab / EnrichmentMapApp

The EnrichmentMap Cytoscape App allows you to visualize the results of gene-set enrichment as a network.
http://apps.cytoscape.org/apps/enrichmentmap
GNU Lesser General Public License v2.1
31 stars 12 forks source link

Enrichmentmap combine datasets from R #486

Closed alievakrash closed 1 year ago

alievakrash commented 2 years ago

I am trying to visualize enrichmentmaps that I process with R and then send to Cytoscape. It works great, but it only creates one enrichmentmap per dataset at a time. Is there a possibility to combine enrichmentmaps once they are created? Or when sending them to cytoscape specify the dataset?

Here is the code that I am using where the input is the result of clusterProfiler EnrichGo function. `egobp.results.df <- egobp_results[[1]]@result

create a new column for term size from BgRatio

egobp.results.df$term.size <- gsub("/(\d+)", "", egobp.results.df$BgRatio)

filter for term size to keep only term.size => 3, gene count >= 5 and subset

egobp.results.df <- egobp.results.df[which(egobp.results.df[,'term.size'] >= 3 & egobp.results.df[,'Count'] >= 5),] egobp.results.df <- egobp.results.df[c("ID", "Description", "pvalue", "qvalue", "geneID")]

format gene list column

egobp.results.df$geneID <- gsub("/", ",", egobp.results.df$geneID)

add column for phenotype

egobp.results.df <- cbind(egobp.results.df, phenotype=1) egobp.results.df <- egobp.results.df[, c(1, 2, 3, 4, 6, 5)]

change column headers

colnames(egobp.results.df) <- c("Name","Description", "pvalue","qvalue","phenotype", "genes") egobp.results.filename <-file.path(getwd(),paste("clusterprofiler_cluster_enrresults.txt",sep=""))

change column headers

colnames(egobp.results.df2) <- c("Name","Description", "pvalue","qvalue","phenotype", "genes") egobp.results.filename <-file.path(getwd(),paste("clusterprofiler_cluster_enrresults.txt",sep="")) write.table(egobp.results.df,egobp.results.filename,col.name=TRUE,sep="\t",row.names=FALSE,quote=FALSE) cytoscapePing()

Visualize in Cytoscope

em_command = paste('enrichmentmap build analysisType="generic" ', 'pvalue=',"0.5", 'qvalue=',"0.5", 'similaritycutoff=',"0.25", 'coeffecients=',"JACCARD", 'enrichmentsDataset1=',egobp.results.filename , sep=" ")

enrichment map command will return the suid of newly created network.

em_network_suid <- commandsRun(em_command) renameNetwork("Test_enrichmentmap_cl2_13T", network=as.numeric(em_network_suid)) `

Thanks!

risserlin commented 2 years ago

You can merge networks in Cytoscape using the merge tools but for use case much better to create a mastermap with all the EM features. An Enrichment map from multiple datasets. In order to automate it you have set up a directory structure where each dataset is in its own directory. EM will take the names of the directory as the name of the dataset.
For example mastermap_dir Dataset1 generic_EM_results_Dataset1.txt Dataset2 generic_EM_results_Dataset2.txt Dataset3 generic_EM_results_Dataset1.txt

Then when you are creating the enrichment map mastermap instead of specifying the individual files you specify the root directory and EM will be able to find all the datasets.

em_command = paste('enrichmentmap mastermap ', 'pvalue=',"0.5", 'qvalue=',"0.5", 'similaritycutoff=',"0.25", 'coeffecients=',"JACCARD", 'rootFolder=',egobp.results.dirname , sep=" ")

https://enrichmentmap.readthedocs.io/en/latest/Automating.html#enrichmentmap-mastermap

alievakrash commented 2 years ago

Thanks for the quick reply. I am getting this error when I am running it: Error: Error: no such command: 'mastermap '

Do I need to call the directory in a specific way? I am running Cytoscape on Version: 3.9.1 and RCy3_2.10.2 .

risserlin commented 2 years ago

What version of enrichment map do you have? (I think it would have be a really old version of enrichment map to not have mastermap.)

In cytoscape, in the command line window when you run "help enrichmentmap" is there a "enrichmentmap mastermap" listed?

Screen Shot 2022-05-09 at 10 51 23 AM

alievakrash commented 2 years ago

I fixed it with removing space after mastermap, also had to remove the coefficient term, as it was giving error. But this worked:

em_command = paste('enrichmentmap mastermap', 'pvalue=',"0.5", 'qvalue=',"0.5", 'similaritycutoff=',"0.25", 'rootFolder=',egobp.results.dirname , sep=" ")

risserlin commented 2 years ago

mastermap's parameters only allow the correctly spelled coefficients but the build command because of a spelling mistake a long time ago accepts coeffecients and coefficients. If you change the parameter in your mastermap command to coefficients it should work. I am not sure why the space gave you issues though.

alievakrash commented 2 years ago

Yes, that works. Thanks. Btw, is there a way to show only the p value pie charts but not the names of the pathways? I have so many and I see them on top. I was trying to change the font, but didn't see how to do that.

risserlin commented 2 years ago

Sorry. I forgot to respond to this when I first saw it.
Yes. You can suppress the labels. In EM there is a toggle button in the EM interface that hides the labels when you click "Publication ready" but unfortunately that is not available through the em commands. It might be an easy feature to add to the commands. I think that all the feature is doing is setting the node labels to zero so you can also do that using RCy3 using the following command (but I am not sure that is still the way it is done) @mikekucera how does the publication ready work?: https://rdrr.io/bioc/RCy3/man/setNodeFontSizeDefault.html

mikekucera commented 2 years ago

Publication ready removes the style mapping for node labels, and sets the style default to the empty string. I think you can do the same thing using RCy3.

On Thu, May 12, 2022 at 6:13 PM Ruth Isserlin @.***> wrote:

Sorry. I forgot to respond to this when I first saw it. Yes. You can suppress the labels. In EM there is a toggle button in the EM interface that hides the labels when you click "Publication ready" but unfortunately that is not available through the em commands. It might be an easy feature to add to the commands. I think that all the feature is doing is setting the node labels to zero so you can also do that using RCy3 using the following command (but I am not sure that is still the way it is done) @mikekucera https://github.com/mikekucera how does the publication ready work?: https://rdrr.io/bioc/RCy3/man/setNodeFontSizeDefault.html

— Reply to this email directly, view it on GitHub https://github.com/BaderLab/EnrichmentMapApp/issues/486#issuecomment-1125467352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABI2JAAMERX22R3OXCOCQWLVJV67XANCNFSM5VN32ELQ . You are receiving this because you were mentioned.Message ID: @.***>