Skip to main content

CellNiche represents cellular microenvironments in atlas-scale spatial omics data with contrastive learning

Project description

CellNiche

Overview

CellNiche is a scalable, cell-centric framework for identifying and characterizing cellular micro-environments from atlas-scale, heterogeneous spatial omics data.
Instead of processing entire tissue slices, CellNiche samples local subgraphs around each cell and learns context-aware embeddings via contrastive learning, while explicitly decoupling molecular identity (gene expression or cell-type labels) from spatial proximity modeling.

Key Features

Installation

From Source

git clone https://github.com/Super-LzzZ/CellNiche.git
cd cellniche

From PyPI

pip install CellNiche

Requirements

  • Python ≥ 3.7
  • PyTorch ≥ 1.12
  • PyTorch Geometric (torch-geometric, torch-scatter, torch-sparse, torch-cluster, torch-spline-conv)
  • Scanpy ≥ 1.9
  • Anndata ≥ 0.9
  • scikit-learn ≥ 1.3
  • numpy ≥ 1.22
  • scipy ≥ 1.10
  • pandas ≥ 2.0
  • networkx ≥ 3.1
  • tqdm ≥ 4.67.1

You can install most dependencies with:

pip install torch torchvision torchaudio
pip install torch-geometric torch-scatter torch-sparse torch-cluster torch-spline-conv
pip install scanpy anndata scikit-learn numpy scipy pandas networkx tqdm

Tutorial

Coming soon

Getting Started

bash

python ./cellniche/main.py --config ./configs/xxx.yaml

python

import CellNiche

# Parse arguments from a YAML config
opts = cellniche.parse_args([
    "--config", "configs/xxx.yaml"
])
# Run training/inference
cellniche.main(opts)

Example YAML snippet (configs/example.yaml):

# Data & preprocessing
data_path: "path/data/"
dataset: "osmFISH_SScortex"
phenoLabels: "ClusterName"
nicheLabels: "Region"
embedding_type: "pheno_expr"
hvg: False

# Graph construction
k_neighborhood: null
radius: 1000.0

# Sampling & training
batch_size: 2048
epochs: null
max_steps: 20
lr: 0.001
weight_decay: 0.0
dropout: 0.0

# Model architecture
hidden_channels: [512, 256]
size: [10, 10]
projection: "" # [128, 64]
decoder: "" # [64]

# Contrastive strategy
tau: 0.9
negative_slope: 0.5
strategy: "freq"

use_weight: False
pos_weight_strategy: "inverse_sim"
neg_weight_strategy: "inverse_sim"

# Random‐walk
wt: 30
wl: 5
p: 0.25
q: 4.0

# Misc
seed: 42
save: False
metrics: true
refine: False
save_path: "path/results"
verbose: true

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

cellniche-0.1.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

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

cellniche-0.1.1-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file cellniche-0.1.1.tar.gz.

File metadata

  • Download URL: cellniche-0.1.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.20

File hashes

Hashes for cellniche-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c6486906fc584727d9fa72ebf914fa37d732e9495a843279a88ea9ec36475cb0
MD5 9918b8b917dfe98f38b2029bb23ac585
BLAKE2b-256 e3a3fd436ef473da7a9c991c070bef1af9caa69e1993f070e2bd1de2bbe11b09

See more details on using hashes here.

File details

Details for the file cellniche-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cellniche-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.20

File hashes

Hashes for cellniche-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3f2ae1411238f03b1a2ca245e6b496160cc30d132b4020b9b57bf831d2c73f7
MD5 0a396ac74b6357e721e6dcbad97e4227
BLAKE2b-256 f61cce92faa795ab13012bd68e2aa4850e678c938401fb68f2baa2b83e1f95ea

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