Skip to content

Commit

Permalink
Update preprocessing.py
Browse files Browse the repository at this point in the history
Pandas groupby call now defaults to `numeric_only=False`. See pandas-dev/pandas#46072. This change breaks `get_filter_stats` call when `data.obs` contains `str` and `category` dtype. It fixes by explicitly calling `median` function with `numeric_only=True`.
  • Loading branch information
hoondy authored Feb 1, 2025
1 parent 40d2646 commit 0e44d14
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pegasus/tools/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_filter_stats(data: MultimodalData, min_genes_before_filt: int = 100) ->

df = data.obs[data.obs["n_genes"] >= min_genes_before_filt] if data.obs["n_genes"].min() == 0 else data.obs
gb1 = df.groupby("Channel")
df_before = gb1.median()
df_before = gb1.median(numeric_only=True)
df_before = df_before.assign(total=gb1.size())
df_before.rename(
columns={
Expand All @@ -116,7 +116,7 @@ def get_filter_stats(data: MultimodalData, min_genes_before_filt: int = 100) ->

# focusing only on filtered cells
gb2 = data.obs[data.obs["passed_qc"]].groupby("Channel")
df_after = gb2.median()
df_after = gb2.median(numeric_only=True)
df_after = df_after.assign(kept=gb2.size())
df_after.rename(
columns={
Expand Down

0 comments on commit 0e44d14

Please sign in to comment.