Skip to main content

Spaco: a comprehensive tool for coloring spatial data at single-cell resolution

Project description

Spaco: a comprehensive tool for coloring spatial data at single-cell resolution

python~=3.8 License: GPL3.0 DOI

Quick Example - Citation

Visualizing spatially resolved biological data with appropriate color mapping can significantly facilitate the exploration of underlying patterns and heterogeneity. Spaco (spatial colorization) provides a spatially constrained approach that generates discriminate color assignments for visualizing single-cell spatial data in various scenarios.

image

Features

Color assignment

By quantifying the complex topology between cell type clusters, We optimized color assignment of to achieve better visual recognizability.

Palette extraction

We provide a method for extracting color plates from images. While maintaining the theme color, the color differentiation is maximized.

Installation

pip install git+https://github.com/BrainStOrmics/Spaco.git

Enviroments

  • python>=3.8.0
  • numpy>=1.18.0
  • pandas>=0.25.1
  • scipy>=1.10.0
  • anndata>=0.8.0
  • scikit-learn>=0.19.0
  • scikit-image>=0.19.0
  • colormath>=3.0.0
  • pyciede2000==0.0.21
  • umap-learn>=0.5.0
  • logging-release>=0.0.4
  • typing_extensions>=4.0.0

NOTE THAT: Currently we found numpy version (1.22.x or 1.23.x) could influence the result of graph-guided mode of Spaco; However, colorization should be acceptable with either version; To exactly reproduce the results in Spaco vignette or paper, please check the numpy version at the end of each jupyter notebook.

Usage

Quick start

import spaco
import scanpy as sc # For visualization
import squidpy as sq # For loading example dataset

# loading data
adata_cell = sq.datasets.seqfish()
palette_default = adata_cell.uns['celltype_mapped_refined_colors'].copy()

# color assignment with default palette
color_mapping = spaco.colorize(
    cell_coordinates=adata_cell.obsm['spatial'],
    cell_labels=adata_cell.obs['celltype_mapped_refined'],
    palette=palette_default,
    radius=0.05,
    n_neighbors=30,
)

# Order colors by categories in adata
color_mapping = {k: color_mapping[k] for k in adata_cell.obs['celltype_mapped_refined'].cat.categories}
palette_spaco = list(color_mapping.values())

# Spaco colorization
sc.pl.spatial(adata_cell, color="celltype_mapped_refined", spot_size=0.035, palette=palette_spaco)

Tutorials and demo-cases

  • A brief demo is included in Spaco package.

Reproducibility

Scripts to reproduce benchmarking and analytic results in Spaco paper are in repository Spaco_scripts

Discussion

Users can use issue tracker to report software/code related issues. For discussion of novel usage cases and user tips, contribution on Spaco performance optimization, please contact the authors via email.

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

spaco-release-0.2.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

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

spaco_release-0.2.0-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file spaco-release-0.2.0.tar.gz.

File metadata

  • Download URL: spaco-release-0.2.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for spaco-release-0.2.0.tar.gz
Algorithm Hash digest
SHA256 77338d08594de45a1ed76c891ec2a9f879c4e2e6823f269517a953930f7f61f0
MD5 8aa390a941e10470398696d5738f95c8
BLAKE2b-256 326190b8beef1a3571f2ce26a527d2da382769d10958bbf452d164f8487b464a

See more details on using hashes here.

File details

Details for the file spaco_release-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: spaco_release-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for spaco_release-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f067534e76a4ccea94e8f6866ab8824a6843316e05e2eb25611753db083ae697
MD5 d7d40caf7546c42935c2ae9aba562c98
BLAKE2b-256 bfc478153897a6f57569a4e5467d93314eee09297b3be96d1e760cc097164770

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