CityUHK-CompBio / HTSanalyzeR2

HTSanalyzeR2: A R package for gene set enrichment and network analysis of various high-throughput data
https://cityuhk-compbio.github.io/HTSanalyzeR2/
13 stars 5 forks source link

Save viewEnrichMap as PNG #4

Open rgaiacs opened 2 years ago

rgaiacs commented 2 years ago

From vignette,

viewEnrichMap(
  gsca3,
  resultName = "GSEA.results",
  gscs=c("PW_KEGG", "GO_MF"),
  allSig = FALSE,
  gsNameType = "term",
  ntop = 8
)

will create a enrichment map. How can I programmable save the enrichment map as a PNG file?

Following https://mpn.metworx.com/packages/r2d3/0.2.3/articles/publishing.html#save_d3_png, I tried

install.packages('r2d3')
install.packages('webshot')
webshot::install_phantomjs()

library(r2d3)

m <- viewEnrichMap(
  gsca3,
  resultName = "GSEA.results",
  gscs=c("PW_KEGG", "GO_MF"),
  allSig = FALSE,
  gsNameType = "term",
  ntop = 8
)

save_d3_png(
  m,
  file = "viz.png"
)

but the result is a white PNG without the enrichment map.

jflucier commented 1 month ago

Hello,

I would have the same question. @rgaiacs @linazhu3 did you find a way to do this?

I would also like to output the enrichment tsv but have not found the way beside manually clicking in app. My script is all automated until that part.

Thanks for your help

jflucier commented 1 month ago

I found the way to export tsv file. Here is the code:

d <- gsca3@result[["GSEA.results"]][["PW_KEGG"]]
write.table(
  data.frame("Gene.Set"=rownames(d),d),
  file = paste0(out,"/top_genesets.tsv"),
  sep = "\t",
  row.names = FALSE
)