Closed lopollar closed 10 months ago
This is still supported on main. The filtered out shapes are added to the sdata object:
├── Shapes
│ ├── 'expanded_cells20': GeoDataFrame shape: (1463, 1) (2D shapes)
│ ├── 'filtered_expanded_cells20_low_counts': GeoDataFrame shape: (52, 1) (2D shapes)
│ ├── 'filtered_expanded_cells20_segmentation': GeoDataFrame shape: (7, 1) (2D shapes)
│ ├── 'filtered_expanded_cells20_size': GeoDataFrame shape: (33, 1) (2D shapes)
│ ├── 'filtered_segmentation_mask_boundaries_low_counts': GeoDataFrame shape: (52, 1) (2D shapes)
│ ├── 'filtered_segmentation_mask_boundaries_segmentation': GeoDataFrame shape: (7, 1) (2D shapes)
│ ├── 'filtered_segmentation_mask_boundaries_size': GeoDataFrame shape: (33, 1) (2D shapes)
│ └── 'segmentation_mask_boundaries': GeoDataFrame shape: (1463, 1) (2D shapes)
and the filtered out cells can be plotted via
nas.pl.plot_shapes( sdata, img_layer='clahe', shapes_layer='segmentation_mask_boundaries', plot_filtered=True )
resulting in:
While checking this feature I found a small bug. If more than one shapes layer is added (e.g. if you did cell expansion with voronoi), then setting plot_filtered=True would plot all filtered cells, also the voronoi shapes. Therefore I changed to code in _plot_shapes
from
if f"filtered" in i:
sdata[i].cx[crd[0] : crd[1], crd[2] : crd[3]].plot(
ax=ax,
edgecolor="red",
linewidth=1,
alpha=alpha,
legend=True,
aspect=1,
cmap="gray",
)
to
if f"filtered_{shapes_layer}" in i:
sdata[i].cx[crd[0] : crd[1], crd[2] : crd[3]].plot(
ax=ax,
edgecolor="red",
linewidth=1,
alpha=alpha,
legend=True,
aspect=1,
cmap="gray",
)
I will push this fix on main later today
this is supported on main since https://github.com/saeyslab/napari-sparrow/pull/142
in the branch add_filtered _cells, some code was added to plot the cells that were filtered out in red to the plots. This looks as follows:
As this is very useful for quality control, is should be added into the new functions.
@ArneDefauw, do you have time to look at this, or should I look into it?
It comes down to saving the cells that were filtered in different shapes layers and then plotting all the filtered layers.