## demo data
from parag.core import get_net_data
import scanpy as sc
=get_net_data(sc.datasets.pbmc68k_reduced()) nodes,edges
(Pairwise) Graph
to_net
to_net (col_node_id:str, col_source:str, col_target:str, col_subset_id:str, nodes:pandas.core.frame.DataFrame=None, edges:pandas.core.frame.DataFrame=None, nodes_path:str=None, edges_path:str=None, col_node_name:str=None, col_subset_name:str=None, cmap_subsets=None, remove_orphans:bool=True, show_node_names:bool=True, off_subset_name:int=15, config_base_path:str=None, defaults:dict=None, use_urls:bool=False, out:str=None, plot:bool=True, testn:int=None, verbose:bool=False)
*Plots the interactive pairwise graph.
Args: nodes (pd.DataFrame): node data edges (pd.DataFrame): edge data col_node_id (str): node id col_node_name (str): node name col_source (str): source column col_target (str): target column col_subset_id (str): subset id col_subset_name (str): subset name nodes_path (str, optional): path to nodes file. Defaults to None. edges_path (str, optional): path to edges file. Defaults to None. cmap_subsets (type, optional): colormap. Defaults to None. show_node_names (bool, optional): show node names. Defaults to True. off_subset_name (int, optional): offset of the subset names from the node names. Defaults to 15. config_base_path (str, optional): vega config path. Defaults to None. defaults (dict, optional): default vega settings. Defaults to None. use_urls (bool, optional): use urls in the vega config. Defaults to False. out (str, optional): output format. Defaults to None. plot (bool, optional): plot or not. Defaults to True. testn (int, optional): test n nodes. Defaults to None. verbose (bool, optional): verbose. Defaults to False.
Returns: tuple: vega config, nodes*
Type | Default | Details | |
---|---|---|---|
col_node_id | str | ||
col_source | str | ||
col_target | str | ||
col_subset_id | str | ||
nodes | DataFrame | None | data |
edges | DataFrame | None | |
nodes_path | str | None | |
edges_path | str | None | |
col_node_name | str | None | labels |
col_subset_name | str | None | ‘gene set name’, |
cmap_subsets | NoneType | None | ‘nipy_spectral’ |
remove_orphans | bool | True | # switches |
show_node_names | bool | True | |
off_subset_name | int | 15 | # knobs |
config_base_path | str | None | ‘inputs/edge_bundle.json’, |
defaults | dict | None | |
use_urls | bool | False | |
out | str | None | |
plot | bool | True | |
testn | int | None | # etc |
verbose | bool | False | |
Returns | tuple |
get_preprocessed
get_preprocessed (nodes:pandas.core.frame.DataFrame, edges:pandas.core.frame.DataFrame, col_node_id:str, col_node_name:str, col_subset_id:str, col_subset_name:str, _col_node_id:str, _col_node_name:str, _col_node_parent:str, _col_source:str, _col_target:str, _col_subset_name:str, col_source:str, col_target:str, remove_orphans:bool, testn:int=None, verbose:bool=False)
*Get preprocessed nodes and edges
Args: nodes (pd.DataFrame): node data edges (pd.DataFrame): edge data col_node_id (str): node id col_node_name (str): node name col_source (str): source column col_target (str): target column col_subset_id (str): subset id col_subset_name (str): subset name _col_node_id (str): vega node id _col_node_name (str): vega node name _col_node_parent (str): vega parent key _col_source (str): vega source key _col_target (str): vega source key _col_subset_name (str): vega subset name key remove_orphans (bool): remove orphan/unconnected nodes testn (int, optional): test n nodes. Defaults to None. verbose (bool, optional): verbose. Defaults to False.
Returns: tuple: nodes, edges*
center_subset_label
center_subset_label (ds1:pandas.core.series.Series)
Removes the subset label except at the middle.
Demo data
1) nodes.head(
1) edges.head(
=to_net(
cfg_base,nodes_=nodes,
nodes=edges,
edges='cell id',
col_node_id='cell id1',
col_source='cell id2',
col_target='bulk_labels',
col_subset_id=dict(
defaults=165,
radius=8,
textSize=7,
textOffset
),# show_node_names=False,
)
nodes_.head()