Skip to main content

Utilities for EigenP

Project description

eigenp-utils

eigenp-utils is a comprehensive toolkit of helper utilities for scientific Python. It provides modules for image analysis, single-cell data processing, advanced plotting, and core Python utilities.

Features

Image Analysis

  • Extended Depth of Focus (EDOF): Reconstruct focused 2D images from 3D stacks with high accuracy using log-parabolic interpolation of focus scores and continuous surface sampling.
  • Surface Extraction: Robust extraction of 2D surfaces from 3D volumes. Includes topological filtering (Connected Components Analysis) to handle debris, nearest-neighbor inpainting for invalid regions, and precise upscaling via RegularGridInterpolator.
  • Registration & Drift Correction: Bidirectional 2D drift correction (apply_drift_correction_2D, compute_drift_trajectory), and iterative shift-compensated windowing (maxproj_registration) to eliminate systematic biases and achieve sub-pixel stability.
  • Intensity Rescaling: Tools for contrast enhancement, including CLAHE.

Plotting & Visualization

  • Interactive 3D Widgets: Jupyter and Marimo-compatible, anywidget-based orthogonal slicers (TNIASliceWidget, show_xyz for dynamic multichannel viewers), interactive point cloud visualization (IsoScatterWidget), and 3D point annotation (TNIAAnnotatorWidget).
  • Publication-Ready Plots: raincloud_plot supporting Seaborn-style arguments (grouped and colored with automatic position dodging). Custom Matplotlib colormap generation via colormap_maker, and SVGs embedded with metadata via savefig_svg.

Single-Cell Analysis

  • Robust Cluster Annotation: Score cell types via the Empirical Probability of Superiority ($P(S_1 > S_2)$) to ensure robustness against outliers and non-normal distributions (annotate_clusters_by_markers).
  • Dataset Integration (kkNN): Adaptive curvature-based k-nearest neighbors mapping (kknn_ingest) to dynamically project metadata and embeddings across references based on local manifold geometry.
  • Label Classification & Smoothing: Distance-weighted majority voting or averaging (kknn_classifier) to smooth categorical or continuous cell metadata using the kkNN backbone.
  • Gene Archetypes: Cluster genes by expression patterns to find dominant archetypes using hierarchical Ward clustering and SVD (find_expression_archetypes).
  • Multiscale Clustering: Run multi-resolution Leiden clustering and track lineage hierarchies across scales (multiscale_coarsening, plot_clustering_tree).
  • Feature Correlation: Find highly correlated features with respect to targets, optionally utilizing graph-based diffusion to smooth over the cell-cell graph (find_correlated_features).
  • Spatial Autocorrelation: Fast Moran's I implementation (morans_i_all_fast) that correctly handles general (non-row-standardized) spatial weights.
  • Dimensionality Reduction: tl_pacmap for PaCMAP embeddings supporting versatile initialization strategies (e.g., PAGA, PCA, random).

Statistical Utilities

  • General Statistics: stats.py provides comprehensive statistical functions including cohens_d, bootstrap_ci, summary_stats, remove_outliers, and add_stat_annotations for annotating plots with significance markers.

Core Utilities

  • Spline Utilities: Calculate tangent vectors and project points onto planes for arbitrary splines and discrete curves (spline_utils.py).
  • Data Handling: Standardize image dataset dimensions strictly to STCZYX via numpy_to_stczyx_xarray.
  • I/O Utilities: Functions to streamline file and data reading.

Installation

By default, the package installs a minimal set of dependencies (like numpy, scipy, pandas, matplotlib, etc). To install it, run:

pip install eigenp-utils

Alternatively, to install the latest development version directly from GitHub:

pip install "eigenp_utils @ git+https://github.com/eigenP/utils.git"

Using uv:

uv pip install "eigenp_utils @ git+https://github.com/eigenP/utils.git"

Optional Dependencies

You can choose to install optional dependencies if you need functionality such as single-cell analysis or image analysis:

  • [image-analysis] - installs scikit-image.
  • [single-cell] - installs packages like scanpy, pacmap, leidenalg, etc.
  • [plotting] - installs plotly.
  • [all] - installs all of the optional dependencies above.
  • [dev] - installs all dependencies and additional tools for testing (e.g. pytest).

e.g. (uv install)

uv pip install "eigenp-utils[all]"

(Note: quotes are required so the shell doesn't misinterpret the brackets.)

For the latest development versions with optional dependencies:

pip install "eigenp_utils[all] @ git+https://github.com/eigenP/utils.git"

or

uv pip install "eigenp_utils[all] @ git+https://github.com/eigenP/utils.git"

You can replace [all] with other groups like [single-cell] or [image-analysis,single-cell] depending on your specific needs.

License

License CC BY-NC https://creativecommons.org/licenses/by-nc/4.0/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eigenp_utils-0.0.2.tar.gz (375.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eigenp_utils-0.0.2-py3-none-any.whl (306.1 kB view details)

Uploaded Python 3

File details

Details for the file eigenp_utils-0.0.2.tar.gz.

File metadata

  • Download URL: eigenp_utils-0.0.2.tar.gz
  • Upload date:
  • Size: 375.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for eigenp_utils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 f0f6fcaaeb045e8c75efeb206b7b22e90db31a217febf454a388bfa185fbdb27
MD5 2be38e24c594aafd99a4e6f4a60f90b4
BLAKE2b-256 8cfaa649fa7ee11ed517e4025c818bf9f6ebb765d9daa4f96a5c53d88ad08181

See more details on using hashes here.

File details

Details for the file eigenp_utils-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: eigenp_utils-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 306.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.10

File hashes

Hashes for eigenp_utils-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c68c5caf81ea496788146ad43389866e47675d9a827bbb53d437a39f725b16e8
MD5 4a82928bc094c6edd56ee9ae9f0f5de5
BLAKE2b-256 ae3c6c3885acdcdff0f0a16a8057093bbf206d94f6ff36ce49b359b60800e547

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page