Skip to content

Commit

Permalink
Merge branch 'main' into pixie/filter_with_nuclear_mask
Browse files Browse the repository at this point in the history
  • Loading branch information
srivarra committed Jan 20, 2023
2 parents 01d36c8 + 6eaf5f8 commit ec39153
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion ark/analysis/visualize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ def test_visualize_topic_eda():
# Run topic EDA
tops = [3, 4, 5, 6, 7]
eda = pros.compute_topic_eda(cell_table_features["featurized_fovs"],
featurization=cell_table_features["featurization"], topics=tops)
featurization=cell_table_features["featurization"],
topics=tops,
num_boots=25)

with pytest.raises(FileNotFoundError):
# trying to save on a non-existant directory
Expand Down
4 changes: 1 addition & 3 deletions ark/utils/metacluster_remap_gui/metaclustergui.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def make_gui(self):
self.fig.canvas.mpl_connect('pick_event', self.onpick)

# heatmaps
self.normalizer = ZScoreNormalize(-1, 0, 1)
self.normalizer = ZScoreNormalize(-3, 0, 3)

def _heatmap(ax, column_count):
data = np.zeros((self.mcd.marker_count, column_count))
Expand Down Expand Up @@ -384,8 +384,6 @@ def update_gui(self):
def _preplot(df):
return df.apply(zscore).clip(upper=self.zscore_clamp_slider.value).T

self.normalizer.calibrate(_preplot(self.mcd.clusters).values)

# clusters heatmap
self.im_c.set_data(_preplot(self.mcd.clusters))
self.im_c.set_extent((0, self.mcd.cluster_count, 0, self.mcd.marker_count))
Expand Down
16 changes: 10 additions & 6 deletions ark/utils/metacluster_remap_gui/zscore_norm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ZScoreNormalize(Normalize):
[vcenter,vmax] -> [0.5,1.0]
"""
def __init__(self, vmin=-1, vcenter=0, vmax=1):
def __init__(self, vmin=-3, vcenter=0, vmax=3):
"""Initial ZScoreNormalize
vmin < vcenter < vmax
Expand All @@ -30,10 +30,13 @@ def __init__(self, vmin=-1, vcenter=0, vmax=1):
self.vcenter = vcenter
super().__init__(vmin, vmax)

def calibrate(self, values):
self.vmin = min([np.min(values), 0])
self.vcenter = 0.0
self.vmax = np.max(values)
def inverse(self, value):
result = np.interp(
value,
[0, 0.5, 1],
[self.vmin, self.vcenter, self.vmax],
)
return result

def __call__(self, value: np.ndarray, clip=None):
"""Map ndarray to the interval [0, 1]. The clip argument is unused."""
Expand All @@ -42,6 +45,7 @@ def __call__(self, value: np.ndarray, clip=None):
normalized_values = np.interp(
result,
[self.vmin, self.vcenter, self.vmax],
[0, 0.5, 1.])
[0, 0.5, 1.]
)

return np.ma.masked_array(normalized_values, mask=np.ma.getmask(result))
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ipython>=8.4.0,<9
jupyter_contrib_nbextensions>=0.5.1,<1
jupyterlab>=3.4.3,<4
jedi>=0.18.1,<0.19
matplotlib==3.4.3
matplotlib>=3.6.2,<4
multiprocess==0.70.13
natsort>=8.1.0,<9
numpy>=1.23.4,<2
Expand All @@ -31,7 +31,7 @@ spatial-lda>=0.1.3,<1
statsmodels>=0.13.2,<1
tables>=3.7.0,<4
tifffile>=2022.8.12,<2023
tmi @ git+https://github.com/angelolab/tmi.git@v0.1.0
tmi @ git+https://github.com/angelolab/tmi.git@v0.1.2
umap-learn>=0.5.3,<1
xarray>=2022.6.0,<2023
tqdm>=4.64.0,<5
Expand Down

0 comments on commit ec39153

Please sign in to comment.