angelolab / ark-analysis

Integrated pipeline for multiplexed image analysis
https://ark-analysis.readthedocs.io/en/latest/
MIT License
69 stars 25 forks source link

generic cell cluster notebook for nimbus #1068

Open HPiyadasa opened 9 months ago

HPiyadasa commented 9 months ago

Currently in the generic cell clustering notebook, the heatmap widget shows valued that is scaled/Z scored. This is not informative when working with nimbus output that generates a probability score from 0-1 for each marker.

Describe the solution you'd like Remove any data transformation from the heatmap widget used for nimbus.

@alex-l-kong

ngreenwald commented 9 months ago

I thought there was already the option to do this? Maybe it's not turned on by default in the notebook? Pretty sure @JLrumberger added this in.

HPiyadasa commented 9 months ago

I am not sure. The only way I got this to work was by altering the ZscoreNormalize and update_gui functions to do nothing

` class ZScoreNormalize(Normalize): def init(self, vmin=None, vcenter=None, vmax=None): super().init(vmin, vmax) # Retain superclass initialization

def inverse(self, value):
    return value  # Return the value as-is

def calibrate(self, values):
    pass  # Do nothing

def __call__(self, value: np.ndarray, clip=None):
    return value  # Return the value as-is

`

and

`
def update_gui(self): """Update and redraw any updated GUI elements""" self.im_cs.set_data(self.selection_mask) self.im_cs.set_extent((0, self.mcd.cluster_count, 0, 1))

    if not self._heatmaps_stale:
        print("skipping other repaints")
        self.fig.canvas.draw()
        return

    # def _preplot(df):
    #     return df.apply(zscore).clip(upper=self.zscore_clamp_slider.value).T

    def _preplot(df):
        return df.T  # Avoiding z-score normalization and clipping

`

JLrumberger commented 8 months ago

We only added the option to make normalization optional for cell_som_clustering in issue #1000. But we didn't touch the GUI widget yet.