-
-
Save simone-codeluppi/cf7174e7fee6be56e547ed8550b7cbee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import zarr | |
import numpy as np | |
from pathlib import Path | |
import dask.array as da | |
%gui qt5 | |
# Note that this Magics command needs to be run in a cell | |
# before any of the Napari objects are instantiated to | |
# ensure it has time to finish executing before they are | |
# called | |
import napari | |
# counts example | |
# adjust the path depending on where the data are stored | |
tmp_counts = 'EXP-19-CX9100_Excitatory_Hybridization01_Cy5_pos_4.zarr' | |
st_tmp = zarr.DirectoryStore(tmp_counts) | |
root_tmp = zarr.group(store=st_tmp, overwrite=False) | |
# collect the thr | |
thrs = np.unique(root_tmp['graph_raw_counts']['counting_thr']) | |
# ------------------------------------------------ | |
# working approach using int as label in the slider | |
# ------------------------------------------------ | |
points_nd = [] | |
all_counting_thr = root_tmp['graph_raw_counts']['counting_thr'][...] | |
all_coords = root_tmp['graph_raw_counts']['coords_original'][...] | |
for idx, thr in enumerate(thrs): | |
selected_counts = all_coords[:,all_counting_thr==thr].T | |
points = np.concatenate((np.full((selected_counts.shape[0], 1), idx), selected_counts), axis=1) | |
points_nd.append(points) | |
points_nd = np.concatenate(points_nd,axis=0) | |
viewer = napari.Viewer() | |
pts_layer = viewer.add_points(points_nd,symbol='+',edge_color='red', face_color='red',size=2, name='counts at different thr') | |
# --------------------------------- | |
# not working solution using the thr value (float) as label for the slider | |
# conversion to int create only the 0 label | |
# --------------------------------- | |
points_nd = [] | |
all_counting_thr = root_tmp['graph_raw_counts']['counting_thr'][...] | |
all_coords = root_tmp['graph_raw_counts']['coords_original'][...] | |
for idx, thr in enumerate(thrs): | |
selected_counts = all_coords[:,all_counting_thr==thr] | |
thr_val = all_counting_thr[all_counting_thr==thr] | |
points = np.vstack((thr_val, selected_counts)) | |
points = points.T | |
points_nd.append(points) | |
points_nd = np.concatenate(points_nd,axis=0) | |
viewer = napari.Viewer() | |
pts_layer = viewer.add_points(points_nd,symbol='+',edge_color='red', face_color='red',size=2, name='counts at different thr') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment