Skip to main content

A simple and efficient clustering tool for spatial 2D points with categorical labels.

Project description

Points2Regions

Points2Regions is a Python tool designed for clustering and defining regions based on categorical marker data, commonly encountered in spatial biology. It provides methods for feature extraction, clustering, and generating various outputs like label masks, GeoJSON representations, and more.

Installation

You can install Points2Regions using the following command:

pip install points2regions

Usage

from points2regions import Points2Regions
import pandas as pd

# Example usage with a CSV file
data = pd.read_csv('https://tissuumaps.dckube.scilifelab.se/private/Points2Regions/toy_data.csv')

# Create the clustering model
p2r = Points2Regions(
    data[['X', 'Y']], 
    data['Genes'], 
    pixel_width=1, 
    pixel_smoothing=5
)

# Cluster with a specified number of clusters
p2r.fit(num_clusters=15)

# Get cluster label for each marker
cluster_per_marker = p2r.predict(output='marker')

# Get a label mask
label_mask, tform = p2r.predict(output='pixel')

# Get connected components
connected_components, num_components, label_mask, tform  = p2r.predict(output='connected')

Example

See the Jupyter Notebook example.ipynb for examples.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

points2regions-0.0.6.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

points2regions-0.0.6-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file points2regions-0.0.6.tar.gz.

File metadata

  • Download URL: points2regions-0.0.6.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for points2regions-0.0.6.tar.gz
Algorithm Hash digest
SHA256 dbc465e3eabc6be81786089a5d71f66bab6bd64390f410de2aee318daa1fb0af
MD5 b95f707c6c72b2d6fff18558ecc13115
BLAKE2b-256 f9123fa4faa1696eec8391c30ba6b892ec964a9488e1177bc261562de5534f80

See more details on using hashes here.

File details

Details for the file points2regions-0.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for points2regions-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d48d9e5b0956682ab8c047b256c85a7dd04199982ab7a1e49b2fa7ac7a0c6da4
MD5 ebfa168ddeed42e7b9114a3f34a207ba
BLAKE2b-256 0537fa77c2c77c0e8c01675ca9b2f3de13cca16308c2cd183b57957188437d94

See more details on using hashes here.

Supported by

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