ark.utils.metacluster_remap_gui¶
ark.utils.metacluster_remap_gui.colormap_helper¶
- ark.utils.metacluster_remap_gui.colormap_helper.distinct_cmap(n=33)[source]¶
Return a List of n visually distinct colors as a matplotlib ListedColorMap
The sequence of color is deterministic for any n, and increasing n does not change the lower index colors.
- Parameters:
n (int) – The number of RGB tuples to return.
- Returns:
N distinct colors as a matplotlib ListedColorMap
- Return type:
- ark.utils.metacluster_remap_gui.colormap_helper.distinct_rgbs(n=33)[source]¶
Return a List of n visually distinct colors as RGB tuples.
The sequence of color is deterministic for any n, and increasing n does not change the lower index colors.
- ark.utils.metacluster_remap_gui.colormap_helper.generate_meta_cluster_colormap_dict(meta_cluster_remap_path, cmap, cluster_type='pixel')[source]¶
Returns a compact version of the colormap used in the interactive reclustering processes.
Generate a separate one for the raw meta cluster labels and the renamed meta cluster labels.
Used in the pixel and cell meta cluster overlays, as well as the average weighted channel expression heatmaps for cell clustering
- Parameters:
meta_cluster_remap_path (str) – Path to the file storing the mapping from SOM to meta clusters (raw and renamed)
cmap (matplotlib.colors.ListedColormap) – The colormap generated by the interactive reclustering process
cluster_type (str) – The type of clustering being done
- Returns:
- Return type:
ark.utils.metacluster_remap_gui.file_reader¶
ark.utils.metacluster_remap_gui.metaclusterdata¶
- class ark.utils.metacluster_remap_gui.metaclusterdata.MetaClusterData(cluster_type, raw_clusters_df, raw_pixelcounts_df)[source]¶
Bases:
objectStore the state of the clusters and metaclusters
- Parameters:
cluster_type (str) – the type of clustering being done
raw_clusters_df (pd.Dataframe) – validated and initialized clusters dataframe.
raw_pixelcounts_df (pd.Dataframe) – validated and initialized pixelcounts dataframe.
- property cluster_count¶
- property clusters¶
- property clusters_with_metaclusters¶
- property fixed_width_marker_names¶
- property linkage_matrix¶
- property marker_count¶
- property marker_names¶
- property metacluster_count¶
- property metacluster_displaynames¶
- property metaclusters¶
- property output_mapping_filename¶
ark.utils.metacluster_remap_gui.metaclustergui¶
- class ark.utils.metacluster_remap_gui.metaclustergui.MetaClusterGui(metaclusterdata, heatmapcolors=seaborn.diverging_palette, width=17.0, debug=False, enable_throttle=True)[source]¶
Bases:
objectCoordinate and present the metacluster Graphical User Interface
- mcd¶
State of the actual clusters at any point in time
- Type:
- Parameters:
data (MetaClusterData)) – An initialized MetaClusterData instance
heatmapcolors (matplotlib.colors.ColorMap)) – If you wish to change the default heatmap colors
width (float) – Adjust the actual width to accomodate monitor size, resolution, zoom, etc
debug (bool) – Enable debug mode for the GUI. This enables a special logging window where output from callbacks can be printed.
enable_throttle (bool) – Control whether or not to throttle GUI callbacks. Disabling might be helpful for debugging certain race conditions.
- clear_selection(e)¶
- enable_debug_mode()[source]¶
Display the debug output widget as part of the GUI
This is used to route logging, output, and tracebacks that happen in any of the event handler callbacks.
- make_gui()[source]¶
Create and configure all of the plots which make up the GUI
Below is a map of the physical subplot layout of the Axes within the Figure.
- The abbreviation is used both for the axes
e.g. self.ax_c
- as well as the plotted items.
e.g. self.im_c, self.rects_cp
Map of matplotlib Figure:
| | Cluster | Meta | ---------------------------- | | cp | cb | counts of pixels, color bar | cd| c | m | heatmap itself | | cs | ms | selection markers | | cl | ml | metacluster color labels
- move_dendro_labels(ax, dendrosplit_ratio=1.8)[source]¶
Overlay axis labels directly onto a scipy dendrogram
Final image will use the ratio 1:dendrosplit_ratio for tree_region:labels_region
- Parameters:
ax (matplotlib.axes.Axes) – The axis containing the existing scipy dendrogram
dendrosplit_ratio (float) – How big to make the the labels compared to the tree
- new_metacluster(e)¶
- onpick(e)¶
- remap_current_selection(metacluster)[source]¶
Instruct the MetaClusterData to remap the selected clusters
All selected clusters will be remapped to the metacluster id which is passed
- Parameters:
metacluster (int) – metacluster id to map the current selection to
- property selection_mask¶
2D boolean mask of shape (1,cluster_count) of currently selected clusters
- update_current_metacluster(metacluster)¶
- update_current_metacluster_displayname(t)¶
- update_zscore(e)¶
ark.utils.metacluster_remap_gui.throttle¶
- ark.utils.metacluster_remap_gui.throttle.throttle(wait)[source]¶
Second order decorator for rate-limiting a function within an asyncio concurrent app
The first call will always happen without delay.
Subsequent calls, within wait seconds, are dropped, even if argurments differ.
The final call will always execute, sometimes with a delay. This guarentees that that final value passed to will be applied.
Example usage:
@throttle(.5) def update_a_gui_element(e): do_stuff(e.name) but_not_too_often()
- Parameters:
wait (float) – minimum time between subsequent calls, in seconds
- Returns:
Decorator for throttling by wait seconds
- Return type:
function
ark.utils.metacluster_remap_gui.zscore_norm¶
- class ark.utils.metacluster_remap_gui.zscore_norm.ZScoreNormalize(*args: Any, **kwargs: Any)[source]¶
Bases:
NormalizeNormalizer tailored for zscore heatmaps
Map each value of an incoming vector each between 0 and 1, which is the interval for cmaps.
The mapping consists of two separate linearly interpolated intervals:
[vmin,vcenter] -> [0.0,0.5] [vcenter,vmax] -> [0.5,1.0]