Skip to content

Commit

Permalink
Read condition from anndata obs
Browse files Browse the repository at this point in the history
The obs dataframe preserves the data type as it allows different datatypes for each column while the X matrix is numpy array. Keep backward compatibility and type conversion from X matrix upon table loading.
  • Loading branch information
fdsteffen committed Sep 23, 2024
1 parent 649cb54 commit e068d1d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/napari_ome_zarr_navigator/img_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def initialize_filters(self):
if self.zarr_root:
adt = self.load_table()
if adt:
self.df = adt.to_df()
self.df = adt.to_df() # keep for backwards compatibility
if self.df.empty:
self.df = adt.obs
self.df_without_pk = self.df.drop(
columns=["row", "col"]
).apply(pd.to_numeric, errors="ignore")
Expand Down Expand Up @@ -120,7 +122,7 @@ def initialize_filters(self):
msg = "No condition table is present in the OME-ZARR."
logger.info(msg)
napari.utils.notifications.show_info(msg)
wells = _validate_wells(self.zarr_dir.value, None)
wells = _validate_wells(self.zarr_root, self.zarr_dict["well"])
wells_str = sorted([f"{w[0]}{w[1]}" for w in wells])
self.well.choices = wells_str
self.well._default_choices = wells_str
Expand All @@ -131,6 +133,7 @@ def initialize_filters(self):
}
)
self.filter_names = None
self.well.value = wells_str[0]

self.select_well.enabled = True
self.btn_load_roi.enabled = True
Expand Down

0 comments on commit e068d1d

Please sign in to comment.