Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cytoscape export #75

Merged
merged 26 commits into from
Nov 8, 2024
Merged

Conversation

rbasu101
Copy link
Contributor

Two buttons were added to graph_app that allows a user to download the generated graph either as a .png, or as a .json (based on the selected button).
Resolves #72

rbasu101 and others added 25 commits June 28, 2024 11:45
dgidb.py:
Added get_drug_list(), which pulls all drug names present in DGIdb

graph_app.py:
Reformatted and renamed many variables/functions for consistency
Added search mode selection menu, allowing users to choose between gene and drug mode.
Selecting a mode will update the terms dropdown menu with genes or drugs respectively, and allow genes or drugs to be graphed.
Node selection, the neighbors dropdown menu, and edge selection, all function as expected in drug mode.

network_graph.py:
Updated code to support drug-search interaction data
    Now changes node_color and sizes based on search_mode
    Whereas before there only existed single/multi degree drugs, genes now are displayed to be single/multi degree
    In summary:
        Genes and Drugs are larger when in their respective search mode
        Blue and Red nodes represent single-degree genes and drugs respectively
        Cyan and Orange nodes represent multi-degree genes and drugs respectively
Removed trailing whitespace on 2 lines.
- Previously implementation of using plotly to visualize the the networkx graph has now been replaced with cytoscape
    - All previously used plotly functions have been removed
    - Functionality of __add_node_attributes has been moved to the stylesheet of cytoscape_figure in __set_app_layout() in graph_app.py
    - generate_cytoscape() handles creation of a cytoscape graph from a networkx graph
- Basic implementation of cytoscape
    - Nodes are categorized by whether or not they are genes and their degree
        - Further stylistic distinction TBD
    - Many elements on right sidebar may not currently work as intended TBD
All info-boxes and user-interaction features (found on the right side of graph app) are now functional
with the cytoscape:
    Selecting nodes AND edges works as intended
    Neighbor Dropdown properly updates with selected nodes
    Edge info properly updates when an edge is selected OR when a node is selected and a neighbor from the dropdown menu is selected

Various variables and functions have been renamed for better consistency
This reverts commit 585c1fb, reversing
changes made to 7ca0695.
Part 1: Merge branch 'master' into "cash-cytoscape-integration"
Due to interaction data no longer being a pandas, code alterations were to made to fix iteration. Naming differences were also ammended for sources and pmid.
Merging main main to this branch resulted in the updated test being overriden by the old one. The updated test has now been restored.
README and a query did not get correctly merged. This commit ammends that
Imported JSON to allow a cytoscape-figure to exported as a JSON. Added card header to 'Selection Info' for consistency. Added New Card with two buttons allowing the user to download the current cytoscape figure as a .png or a .json. Removed '_get_node_data_from_id' as it is unused. Added '_generate_png' and 'generate_json' to handle png and json generation.
Added the 'class_name="m-1"' attribute to the 'export graph' buttons to visually space them apart.
@rbasu101 rbasu101 added enhancement New feature or request priority:low Low priority labels Oct 21, 2024
@rbasu101 rbasu101 self-assigned this Oct 21, 2024
@rbasu101 rbasu101 linked an issue Oct 21, 2024 that may be closed by this pull request
@rbasu101
Copy link
Contributor Author

In Cytoscape's documentation, there is also options to download the graph as a .svg or a .jpg. However, In my testing:

  • Downloading the graph as a .svg simply doesn't work. Maybe someone could follow up on this?
  • Downloading the graph as a .jpg does work, but it seems rather redundant to add it since a .png would do everything a .jpg would do but better (transparent background, higher quality, etc). Any possible use case for this?

@jsstevenson
Copy link
Member

@rbasu101 SVG would be nice, but if it doesn't work, it doesn't work. Agree that there's no need for multiple basic image formats.

Added functionality to export .svg images from the cytoscape graph. A new button exists to export the graph as an .svg.
@rbasu101
Copy link
Contributor Author

rbasu101 commented Oct 25, 2024

I found out that .svg exporting does work, but it requires this line of code to be at the top.
cyto.load_extra_layouts()
Previous commit adds .svg exporting functionality alongside .png exporting.

@rbasu101 rbasu101 merged commit 6b5d8ce into main Nov 8, 2024
12 checks passed
@rbasu101 rbasu101 deleted the 72-image-exporting-from-cytoscape-graph branch November 8, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:low Low priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Image Exporting from Cytoscape Graph
3 participants