Skip to content

ZAEDPolSl/miso-plot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

miso-plot

miso-plot logo

A lightweight visualization tool for clustered high-density data

PyPI License: MIT Python 3.8+ Build


Overview

miso-plot is a simple yet efficient Python library for visualizing large clustered datasets. It was designed for fast exploration of high-density 2D embeddings such as UMAP, t-SNE, or PCA outputs, using adaptive density smoothing and perceptually uniform color palettes.

Typical use cases include:

  • visual inspection of clustering quality in large datasets,
  • density-based highlighting of local data structures,
  • generation of publication-quality scatter plots.

Installation


 pip install miso-plot
 

Or install the latest development version directly from GitHub:


 pip install git+https://github.com/Aleksandra795/miso-plot.git
 

Quick Example


import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
from miso_plot import miso_plot

# Generate synthetic clustered data
X, labels = make_blobs(n_samples=50000, centers=6, n_features=2, random_state=42)
Y = X[:, 1]
X = X[:, 0]

# Plot simple scatterplot of the data
plt.figure()
plt.scatter(X, Y, s=10, c=labels, alpha=0.5, cmap='tab10')
plt.xlabel("x")
plt.ylabel("y")
plt.title("simple scatter plot")
plt.grid(True)
plt.show()
  

Example scatter plot

Because often the clusters overlap substantially, identifying their true centers is challenging. miso-plot facilitates this process by visualizing each cluster’s density distribution, highlighting regions representing the top m fraction of its overall density.


# Show cluster density centers with miso-plot
fig, ax = plt.subplots()
plt.scatter(X, Y, s=10, c='#D6D6D6', alpha=0.5)
miso_plot(X, Y, labels, cmap="tab10", m=0.5, ax=ax)  
plt.xlabel("x")
plt.ylabel("y")
plt.title("mISO plot, m=0.5")
plt.grid(True)
plt.show()
 

Example miso plot

The usefulness of miso-plot is best illustrated using real experimental data. Below is an example based on single-cell mass cytometry data from Samusik et al. (2016) — “Automated mapping of phenotype space with single-cell data” (Nature Methods, 13, 493–496; DOI: 10.1038/nmeth.3863) — containing 24 manually annotated bone marrow cell subtypes. miso-plot clearly reveals the dominant spatial organization of these subtypes on the UMAP projection while suppressing outliers and low-density noise, making the overall cluster structure easier to interpret.

Example miso plot


API Overview

miso_plot(X, Y, labels, cmap='miso24', m=0.5, lam=20, ax=None, alpha=0.3, marker='s', size=10)

Generates a smoothed scatter plot with adaptive density highlighting.

ParameterTypeDescription
X, Ynp.ndarrayCoordinates of points
labelsnp.ndarrayCluster labels for each point
cmapstr or listColormap ('miso24', matplotlib/seaborn name, or list of hex)
mfloatDensity threshold
lamintSmoothing parameter
axmatplotlib.axes.Axes or NoneOptional existing Axes; creates a new one if None
alphafloatTransparency of points
markerstrMarker style
sizeintSize of each point

The m parameter has the strongest impact on the visual output of miso-plot. Its default value is 0.5, corresponding to the median density isoline, but it can be adjusted to control how much of the cluster density is visualized. Common choices include 0.25 (top 75% of the densest regions) and 0.75 (top 25%), depending on the desired level of detail.

m parameter


Color Palettes

Built-in palette: miso24
Designed for cluster visualization (24 clusters) with high perceptual separation.

miso24 palette

You may also pass:

  • any matplotlib/seaborn palette name (e.g. 'viridis', 'tab10'),
  • a custom list of hex colors (e.g. ['ff0000', '00ff00', '0000ff']).

Citation

If you use miso-plot or the underlying method in your research or publications, please cite:

Suwalska, A.; Polanska, J.
GMM-Based Expanded Feature Space as a Way to Extract Useful Information for Rare Cell Subtypes Identification in Single-Cell Mass Cytometry.
Int. J. Mol. Sci. 2023, 24(18), 14033.
https://doi.org/10.3390/ijms241814033
(Open Access)

License

This project is distributed under the MIT License.


Created with ❤️ and scientific curiosity.

About

Simple visualization tool for clustered high-density data.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages