from parag.hypergraph import to_net
=to_net(
cfg,df_=nodes.sort_values('Essentiality (determined from multiple datasets)'),
nodes=edges,
edges='Gene ID',
col_node_id='# protein1',
col_source='protein2',
col_target='Essentiality (determined from multiple datasets)',
col_subset_id=True,
show_node_names=dict(
defaults=250,
radius=280,
innerRadius=295,
outerRadius=7,
textSize=3,
textOffset
), )
parag
Para (beyond pairwise) Graph: interactive visualization of higher-order graphs in Python
Install
pip install parag
Interpretation as a hypergraph, using proportion of degrees by communities
Proportion of degrees by communities in a pairwise graph helps reveal how nodes are grouped together and connected within different communities. This analysis highlights clusters of nodes with strong internal connections, potentially representing higher-order relationships. By comparing the degree proportions within and between communities, we can distinguish internal cohesion from inter-community interactions. These insights aid in interpreting the graph as a hypergraph, where communities with high intra-community connections may signify higher-order relationships, offering a richer understanding of complex interactions beyond simple pairwise connections.
Inspired by
Vehlow, Corinna, Thomas Reinhardt, and Daniel Weiskopf. “Visualizing fuzzy overlapping communities in networks.” IEEE Transactions on Visualization and Computer Graphics 19.12 (2013): 2486-2495.
Figure 9B
Examples:
Gene interaction networks
Neighbourhood analysis in latent space e.g. single cell data
="bulk_labels",title='Latent space') sc.pl.umap(adata, color
from parag.core import get_net_data
=get_net_data(adata) ## generated network data by measuring distances in the latent space and thresholding nodes,edges
from parag.hypergraph import to_net
=to_net(
cfg,df_
nodes,
edges,='cell id',
col_node_id='cell id1',
col_source='cell id2',
col_target='bulk_labels',
col_subset_id=False,
show_node_names=dict(
defaults=8,
textSize=3,
textOffset
), )
Heterogeneous graph e.g. drug side-effects network
## filter
=(df02
nodes"Individual Side Effect","Side Effect Name"]]
.loc[:,[
.log.drop_duplicates()
.assign(#Side Effect type
=lambda df: df['Side Effect Name'].str.split(' ',expand=True)[0],
subset
)'Side Effect Name'],axis=1)
.drop(['subset').filter(lambda df: len(df)>3 and len(df)<10)
.groupby(5)
.head('subset')
.sort_values('Individual Side Effect') # id
.log('Individual Side Effect') # name
.log(
)1) nodes.head(
Individual Side Effect | subset | |
---|---|---|
1 | C0162830 | Photosensitivity |
=(
edges
df02=f"`Individual Side Effect` == {nodes['Individual Side Effect'].unique().tolist()}")
.log.query(expr
)1) edges.head(
# STITCH | Individual Side Effect | Side Effect Name | |
---|---|---|---|
1 | CID003062316 | C0162830 | Photosensitivity reaction |
## append drugs to nodes
=pd.concat(
nodes
['# STITCH']].drop_duplicates().rename(columns={'# STITCH':'node id'},errors='raise').assign(subset='drug'),
edges.loc[:,[={'Individual Side Effect':'node id'},errors='raise'),
nodes.rename(columns
],=0,
axis
)1) nodes.head(
node id | subset | |
---|---|---|
1 | CID003062316 | drug |
from parag.hypergraph import to_net
=to_net(
cfg,df_
nodes,
edges,='node id',
col_node_id='# STITCH',
col_source='Individual Side Effect',
col_target='subset',
col_subset_id=False,
show_node_names=dict(
defaults=200,
radius=205,
innerRadius=235,
outerRadius=9,
textSize=3,
textOffset=3.5,
cornerRadius
), )
Network communities
# Plot graph with colouring based on communities
= plt.subplots(1,1, figsize=(5, 3))
fig, ax 3], 2) visualize_communities(G, communities[
=pd.Series({i:list(t) for i,t in enumerate(communities[3])}).explode().to_frame('node id').reset_index().rename(columns={'index':'community id'}).sort_values('community id')
nodes1) nodes.head(
community id | node id | |
---|---|---|
0 | 0 | 0 |
=pd.DataFrame(G.edges,columns=['source','target'])
edges1) edges.head(
source | target | |
---|---|---|
0 | 0 | 1 |
from parag.hypergraph import to_net
=to_net(
cfg,df_str),
nodes.applymap(str),
edges.applymap(='node id',
col_node_id='source',
col_source='target',
col_target='community id',
col_subset_id=True,
show_node_names=dict(
defaults=180,
radius=205,
innerRadius=235,
outerRadius=17,
textSize=4,
textOffset=3.5,
cornerRadius
), )
How to cite?
- Using BibTeX:
@software{Dandage_parag,
title = {parag: interactive visualization of higher-order graphs in Python},
author = {Dandage, Rohan},
year = {2024},
url = {https://doi.org/10.5281/zenodo.10703097},
version = {v0.0.1},
note = {The URL is a DOI link to the permanent archive of the software.},
}
Using citation information from CITATION.CFF file.