Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Find paths between node A and node B in the Translator KG <br>
Find a subnetwork given a list of nodes in the Translator KG <br>
Developer-friendly wrappers for resolving labels/CURIEs, caching Translator resources, and returning parsed finder results <br>
Connecting user's API with Translator API <br>
*Note: Visualization capabilities (pyvis, matplotlib, seaborn) can be installed separately via the `vision` extra.*


## How to use TCT
Expand All @@ -34,8 +35,13 @@ pip install TCT
# TCT is in development, to get the most recent update, user can install it through the github repo
```

**This the recommended approach for installation.**
**This is the recommended approach for a minimal installation.**

Visualization support is optional. Install it with the `vision` extra when you need the plotting and graph-rendering utilities:

```bash
pip install "TCT[vision]"
```

#### Development Installation

Expand All @@ -57,6 +63,12 @@ cd Translator_component_toolkit
uv sync
```

To include visualization support in the UV environment:

```bash
uv sync --extra vision
```

#### Building and Deployment
**Using pip:**
- Build: `python -m build`
Expand Down
27 changes: 20 additions & 7 deletions TCT/TCT.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
import requests
import json
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import networkx as nx
import numpy as np
#import openai
from . import name_resolver, node_normalizer, translator_query

# plt.switch_backend('module://ipykernel.pylab.backend_inline')

from IPython.display import display

__all__ = [
'TCT_help',
'list_functions',
Expand Down Expand Up @@ -851,6 +846,9 @@ def plot_heatmap(predicates_by_nodes_df,num_of_nodes = 20,
fontsize = 6,
title_fontsize = 10,
output_png="NE_heatmap.png"):
import matplotlib.pyplot as plt
import seaborn as sns

#matplotlib.use('Agg')

#title = "Ranking of one-hop nodes by primary infores"
Expand Down Expand Up @@ -891,7 +889,8 @@ def plot_heatmap_ui(predicates_by_nodes_df,num_of_nodes = 20,
fontsize = 6,
title_fontsize = 10,
output_png="NE_heatmap.png"):

import matplotlib.pyplot as plt
import seaborn as sns

title = "Ranking of one-hop nodes by primary infores"
ylab = "infores"
Expand Down Expand Up @@ -1658,7 +1657,8 @@ def merge_by_ranking_index(result_ranked_by_primary_infores,
title_fontsize = 12,
fontsize = 12,
):

import matplotlib.pyplot as plt
import seaborn as sns

dic_rank1 = {}
for i in range(0, result_ranked_by_primary_infores.shape[0]):
Expand Down Expand Up @@ -1774,6 +1774,9 @@ def plot_path_bar(x,
fontsize = 8,
title_fontsize = 10,
output_png="NE_heatmap.png"):
import matplotlib.pyplot as plt
import seaborn as sns

#matplotlib.use('Agg')

# title = "Bridging nodes" # Unused variable
Expand Down Expand Up @@ -1965,6 +1968,9 @@ def select_result_to_analysis(sele_genes,Temp_result_df1, Temp_result_df2 ):


def plot_graph_by_predicates(for_plot):
import networkx as nx
from IPython.display import display

graph = nx.from_pandas_edgelist(for_plot,
source='Subject',
target='Object',
Expand Down Expand Up @@ -2013,6 +2019,8 @@ def plot_graph_by_predicates(for_plot):


def plot_graph_by_infores(for_plot):
import networkx as nx
from IPython.display import display

graph = nx.from_pandas_edgelist(for_plot,
source='Subject',
Expand Down Expand Up @@ -2062,6 +2070,8 @@ def plot_graph_by_infores(for_plot):


def plot_graph_by_API(for_plot):
import networkx as nx
from IPython.display import display

graph = nx.from_pandas_edgelist(for_plot,
source='Subject',
Expand Down Expand Up @@ -2273,6 +2283,9 @@ def load_translator_resources():


def visulize_path(input_node1_id, intermediate_node, input_node3_id, result, result2):
import networkx as nx
from IPython.display import display

forplot_subject = []
forplot_object = []
forplot_predicate = []
Expand Down
6 changes: 3 additions & 3 deletions TCT/TCT_Visualization.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

from .node_normalizer import ID_convert_to_preferred_name_nodeNormalizer

import networkx as nx
from pyvis.network import Network

def visualize_neighborhood_graph(result, show_label=True, height="1000px", width="100%", output_filename_prefix=None):
'''Visualize the neighborhood graph using pyvis
Args:
Expand All @@ -18,6 +15,9 @@ def visualize_neighborhood_graph(result, show_label=True, height="1000px", width
dic_graph = visualize_neighborhood_graph(result, show_label=True, height="500", width="100%")
'''

import networkx as nx
from pyvis.network import Network

# Your JSON (as Python dict)
data = result
IDs = []
Expand Down
13 changes: 12 additions & 1 deletion docs/source/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Allowing testing whether a user defined API follows a [TRAPI](https://github.com
Faciliting to explore knowledge graphs from both Translator ecosystem and user defined APIs.<br>
Developer-friendly `pathfinder` and `neighborhood_finder` wrappers for resolving labels/CURIEs, caching Translator resources, and returning parsed finder results (`from TCT import pathfinder, neighborhood_finder`). <br>
Connecting large language models to convert user's questions into TRAPI queries. <br>
*Note: Visualization capabilities (pyvis, matplotlib, seaborn) can be installed via the `vision` extra using `pip install TCT[vision]`*

### Contributing
TCT is a tool that helps to explore knowledge graphs developed in the Biomedical Data Translator Consortium. Consortium members and external contributors are encouraged to submit issues and pull requests.
Expand All @@ -22,7 +23,17 @@ Guangrong Qin, guangrong.qin@isbscience.org
## How to use TCT
### Install Requirements

To install TCT as a python library, you can install the library using `pip install TCT` from the command line.
To install the minimal TCT package, run:

```bash
pip install TCT
```

Visualization support is optional. Install it with the `vision` extra when you need the plotting and graph-rendering utilities:

```bash
pip install "TCT[vision]"
```

The TCT is continuously updated, if you would like to use the latest functions, you can also clone this most recent github repository (https://github.com/NCATSTranslator/Translator_component_toolkit/tree/main),
`git clone https://github.com/NCATSTranslator/Translator_component_toolkit.git`
Expand Down
17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ dependencies = [
"requests",
"jsons",
"pandas",
"seaborn",
"matplotlib",
"ipycytoscape",
"networkx",
"numpy",
"openai",
"ipykernel",
'networkx',
'igraph',
'pyvis',
'zstandard',
"igraph",
"zstandard",
]

[project.optional-dependencies]
vision = [
"ipycytoscape",
"matplotlib",
"networkx",
"pyvis",
"seaborn",
]
mcp = [
"fastmcp>=2.12.2",
"click>=8.2.1",
Expand Down
26 changes: 14 additions & 12 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading