Hypergraphs

For hypergrapph related functions

from parag.hypergraph import get_degreeby_subset, plot_degreeby_subset, to_net

Demo data

from parag.core import get_net_data
import scanpy as sc
nodes,edges=get_net_data(sc.datasets.pbmc68k_reduced())
nodes.head(1)
cell id bulk_labels n_genes percent_mito n_counts S_score G2M_score phase louvain x y
0 CAGACAACAAAACG-7 CD4+/CD25 T Reg 1109 0.012702 3779.0 -0.054589 -1.267457 G1 0 -7.174749 -6.994063
edges.head(1)
cell id1 cell id2 distance
0 CAGACAACAAAACG-7 GTGATGACTGGGAG-4 1.298669

Degrees by subsets

cfg_bars=plot_degreeby_subset(
    nodes.sort_values('bulk_labels',ascending=True),
    edges,
    col_node_id='cell id',
    col_source='cell id1',
    col_target='cell id2',
    col_subset_id='bulk_labels',    
    config_base_path=None,
    cmap_subsets=None,  
    # defaults=dict(
    #     innerRadius=170,
    #     outerRadius=200,
    #     innerPadding=0.15,
    # ),
    )

Integrate with graph

cfg,df_=to_net(
    nodes,
    edges,
    col_node_id='cell id',
    col_source='cell id1',
    col_target='cell id2',
    col_subset_id='bulk_labels',
    show_node_names=False,
    defaults=dict(
            textSize=8,
            textOffset=3,
    ),
)