Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rraadd88 committed Feb 25, 2024
1 parent f3d0a1d commit be91ac3
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions 01_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"outputs": [],
"source": [
"# | export\n",
"\n",
"## helper functions\n",
"import roux.lib.df as rd #noqa\n",
"\n",
"def get_net_data(\n",
" adata,\n",
" n: int = 5, # number of nodes per subset/group\n",
Expand Down
3 changes: 2 additions & 1 deletion 02_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@
"from IPython.display import display\n",
"import pandas as pd\n",
"\n",
"## helper functions\n",
"import roux.lib.df as rd #noqa\n",
"from roux.lib.str import linebreaker\n",
"\n",
"\n",
"def center_subset_label(\n",
" ds1: pd.Series,\n",
") -> pd.Series:\n",
Expand Down
2 changes: 2 additions & 0 deletions 03_hypergraph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"import pandas as pd\n",
"from roux.lib.io import read_dict\n",
"\n",
"import roux.lib.df as rd #noqa\n",
"\n",
"def get_degreeby_subset(\n",
" nodes: pd.DataFrame,\n",
" edges: pd.DataFrame,\n",
Expand Down
6 changes: 3 additions & 3 deletions index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
"warnings.filterwarnings(\"ignore\", category=UserWarning)\n",
"\n",
"from pathlib import Path\n",
"\n",
"import pandas as pd\n",
"import roux.lib.df as rd\n",
"\n",
"## helper functions\n",
"import roux.lib.df as rd #noqa\n",
"## functions from parag\n",
"from parag.utils import export_plot\n",
"\n",
"## parameters\n",
Expand Down
6 changes: 5 additions & 1 deletion parag/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
__all__ = ['get_net_data']

# %% ../01_data.ipynb 3
## helper functions
import roux.lib.df as rd #noqa

def get_net_data(
adata,
n: int = 5, # number of nodes per subset/group
Expand All @@ -19,6 +22,7 @@ def get_net_data(
"""
import logging
import pandas as pd
import roux.lib.df as rd

## nodes
logging.info("processing nodes:")
Expand All @@ -29,7 +33,7 @@ def get_net_data(
],
axis=1,
)
if n is not None:
if not n is None:
df1 = (
df01.log()
.groupby("bulk_labels", as_index=False, observed=False)
Expand Down
11 changes: 7 additions & 4 deletions parag/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@

logging.basicConfig(level=logging.INFO)
import pandas as pd
from roux.lib.io import read_dict, to_dict
from roux.lib.io import read_dict, to_dict, read_ps, read_table, to_table
import roux.lib.df as rd # noqa

from IPython.display import display
import pandas as pd

## helper functions
import roux.lib.df as rd #noqa
from roux.lib.str import linebreaker


def center_subset_label(
ds1: pd.Series,
) -> pd.Series:
Expand Down Expand Up @@ -102,7 +105,7 @@ def get_preprocessed(
}
)
)
if testn is not None:
if not testn is None:
df1 = df1.head(testn)
logging.warning(f"testing {testn} nodes")
if verbose:
Expand Down Expand Up @@ -327,7 +330,7 @@ def to_net(
# _col_node_name=_col_node_id
if col_subset_name is None:
col_subset_name = col_subset_id
if nodes_path is not None and edges_path is not None:
if not nodes_path is None and not edges_path is None:
df1 = pd.DataFrame(read_dict(nodes_path))
df2 = pd.DataFrame(read_dict(edges_path))
else:
Expand Down
5 changes: 4 additions & 1 deletion parag/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import pandas as pd
from roux.lib.io import read_dict

import roux.lib.df as rd #noqa

def get_degreeby_subset(
nodes: pd.DataFrame,
edges: pd.DataFrame,
Expand Down Expand Up @@ -102,7 +104,7 @@ def plot_degreeby_subset(
col_target=col_target,
col_subset_id=col_subset_id,
)
if order is not None:
if not order is None:
degreebysubset = degreebysubset.set_index("source").loc[order, :].reset_index()
# degreebysubset.head(1)

Expand All @@ -119,6 +121,7 @@ def plot_degreeby_subset(
# import seaborn as sns # for the matching color palette
# cmap_subsets=sns.color_palette("colorblind")

from roux.viz.colors import get_ncolors

if hue_order is None:
subsets = degreebysubset.set_index("source").columns.tolist()
Expand Down
2 changes: 1 addition & 1 deletion parag/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def display_plot(
method (str, optional): method. Defaults to 'vega'.
"""

if defaults is not None:
if not defaults is None:
spec = _set_defaults(
spec,
defaults,
Expand Down

0 comments on commit be91ac3

Please sign in to comment.