Closed ayoraind closed 2 weeks ago
Hi,
in our next version of pling we will add an option to save the network as cytoscape compatible json files, which can be loaded directly into cytoscape with a pling style file, and cytoscape then allows saving static images. Would this suit your needs?
In the current version though, you can screenshot any network visualisations you want to have as a static image (this is what I personally do)
Hi @babayagaofficial,
The ability to save the network as cytoscape compatible json files would suit my needs a bit. I look forward to the next version of Pling. The other reason I would wish for the generation of an SVG file is to be able to remove the containment distance/DCJ distance (e.g., 0.3/3) from the community network plots (using e.g., Inkscape) because it becomes a bit messy with these numbers for plasmid networks containing more than 7 nodes.
Yesterday, I did a workaround by importing the dcj all_plasmids_distances.tsv and information on the plasmid subcommunities (dcj_thresh_4_graph/objects/typing.tsv) into R, modified the dfs a bit to be compatible with Cytoscape input files, and generated networks (similar to the pling output) using RCy3.
The following code in R might be useful for those needing it (or for future me). Ideas were derived from https://bioconductor.org/packages/release/bioc/vignettes/RCy3/inst/doc/Overview-of-RCy3.html
library(RCy3)
cytoscapePing() # to see if RCy3 can communicate with Cytoscape (Cytoscape must have been launched prior)
cytoscapeVersionInfo()
# read in distances
all_plasmid_dcj_distances <- readr::read_tsv("all_plasmids_distances.tsv")
containment_subcommunities <- readr::read_tsv("dcj_thresh_4_graph/objects/typing.tsv")
try_plasmid_subcommunity_nodes <- containment_subcommunities %>%
rename("id" = "plasmid",
"group" = "type") %>%
mutate(score = 1:nrow(.))
try_plasmid_edgesv2 <- all_plasmid_dcj_distances %>%
rename("source" = "plasmid_1",
"target" = "plasmid_2") %>%
mutate(weight = 2,
interaction = "interacts")
createNetworkFromDataFrames(try_plasmid_subcommunity_nodes,try_plasmid_edgesv2, title="plasmid_subcommunitiesv2", collection="DataFrame Example") # this generates the standard networks with rectangular nodes.
# Modify initial bland plot and add colours per sub-community
try_plasmid_subcommunity_node_groups <- try_plasmid_subcommunity_nodes %>%
distinct(group) %>%
pull() # this captures unique plasmid subcommunity node names/ids
safe_colorblind_palette <- c("#88CCEE", "#CC6677", "#DDCC77", "#117733", "#332288", "#AA4499",
"#44AA99", "#999933", "#882255", "#661100", "#6699CC", "#888888")
## create own style. Convert rectangular node shape to circular, colour based on the safe_colorblind_palette
style.name = "myStyle3"
defaults <- list(NODE_SHAPE="circle",
NODE_SIZE=30,
EDGE_TRANSPARENCY=120,
NODE_LABEL_POSITION="W,E,c,0.00,0.00")
nodeLabels <- mapVisualProperty('node label','id','p')
nodeFills <- mapVisualProperty('node fill color','group','d',c(try_plasmid_subcommunity_node_groups), c(safe_colorblind_palette))
arrowShapes <- mapVisualProperty('Edge Target Arrow Shape','interaction','d',c("interacts"),c("None"))
edgeWidth <- mapVisualProperty('edge width','weight','p')
createVisualStyle(style.name, defaults, list(nodeLabels,nodeFills,arrowShapes,edgeWidth))
setVisualStyle(style.name)
saveSession('vignette_session')
# save Image
full.path=paste(getwd(),'vignette_image',sep='/')
exportImage(full.path, 'PNG', zoom=200) #.png scaled by 200%
This process helped me to get rid of the numbers (containment distance and dcj distance values on networks) and generate a publication-ready figure.
Dear Pling developers,
I write to ask if it is possible to save the plasmid network generated as an SVG image or if there is a way or a tool to enable saving the networks as a static image.