Skip to main content

Implementation of the Spatial-LDA model

Project description

Spatial-LDA

spatial-lda

Spatial-LDA is a probabilistic topic model for identifying characteristic cellular microenvironments from in-situ multiplexed imaging data such as MIBI-ToF or CODEX.

This repository contains an implementation of the Spatial-LDA model as described in the paper Modeling Multiplexed Images with Spatial-LDA Reveals Novel Tissue Microenvironments.

Please cite our work if you find this tool useful.

Modeling Multiplexed Images with Spatial-LDA Reveals Novel Tissue Microenvironments

Zhenghao Chen, Ilya Soifer, Hugo Hilton, Leeat Keren, and Vladimir Jojic

Journal of Computational Biology 2020.04.03; doi: http://doi.org/10.1089/cmb.2019.0340

BibTeX

@article{chen2020modeling,
  title={Modeling Multiplexed Images with Spatial-LDA Reveals Novel Tissue Microenvironments},
  author={Chen, Zhenghao and Soifer, Ilya and Hilton, Hugo and Keren, Leeat and Jojic, Vladimir},
  journal={Journal of Computational Biology},
  year={2020},
  publisher={Mary Ann Liebert, Inc., publishers 140 Huguenot Street, 3rd Floor New~…}
}

The repository also contains notebooks that generate the results and figures presented in the paper as examples of how to use Spatial-LDA.

Installation

The easiest and preferred way to install the Spatial-LDA package is via pip:

pip install spatial_lda

Alternatively, you can clone this repository and run setup.py directly (assuming you have setuptools installed).

python setup.py install

Examples

Please refer to the included notebooks below for examples of how to train a Spatial-LDA model. We include two notebooks:

(1) Applying Spatial-LDA to a CODEX dataset of mouse spleen tissues

We apply Spatial-LDA to a dataset of mouse spleens from Deep Profiling of Mouse Splenic Architecture with CODEX Multiplexed Imaging to validate that it recovers known spatial relationships between immune cells in the mouse spleen.

Mouse Spleen Analysis

(2) Applying Spatial-LDA to a MIBI-ToF dataset of Triple Negative Breast Cancer (TNBC) tumors

We apply Spatial-LDA to a dataset of TNBC tumors from A Structured Tumor-Immune Microenvironment in Triple Negative Breast Cancer Revealed by Multiplexed Ion Beam Imaging to identify prototypical tumor-immune microenvironments in TNBC.

TNBC Analysis

For convenience, we have included pre-processed versions of the data from the two datasets above under 'data/'.

Usage

Featurization

The Spatial-LDA model requires a dataset of index cells and neighborhood features along with an undirected graph where nodes are index cells and edges between nodes encode index cells that should be regularized to have similar topic priors.

We provide utilities in the featurization module to generate required neighborhood features (featurization.featurize_samples) and adjacency matrices (featurization.make_merged_difference_matrices) from dataframes containing the location and features of index and background cells.

Training and inference

To fit a Spatial-LDA model, call spatial_lda.model.train on the feature matrix and difference matrix generated in the featurization step. E.g.,

spatial_lda_model = spatial_lda.model.train(train_tumor_marker_features, 
                                            train_difference_matrices, 
                                            n_topics=N_TOPICS, 
                                            difference_penalty=DIFFERENCE_PENALTY, 
                                            verbosity=1,
                                            n_parallel_processes=3,
                                            n_iters=3,
                                            admm_rho=0.1,
                                            primal_dual_mu=2)

To run inference - computing regularized topic weights on a pre-trained set of topics:

complete_lda = spatial_lda.model.infer(
      spatial_lda_model.components_, tumor_marker_features, 
      complete_difference_matrices, difference_penalty=DIFFERENCE_PENALTY,
      n_parallel_processes=N_PARALLEL_PROCESSES)

For reference, we also include an earlier primal-dual based implementation of the model that was described in an earlier version of our paper. However, the ADMM based solution should be preferred as it should be significantly faster.

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

spatial-lda-0.1.0.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

spatial_lda-0.1.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

Details for the file spatial-lda-0.1.0.tar.gz.

File metadata

  • Download URL: spatial-lda-0.1.0.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for spatial-lda-0.1.0.tar.gz
Algorithm Hash digest
SHA256 888046e4be2b15333f14754cc08937698a00ca6557ddb9397a2d13c5dcd8cab2
MD5 c169a18ab0e825060d3a6d2e41ae01d1
BLAKE2b-256 a600ba9410735efcab7605167513e875ca8a643a581095c40c9d65c5bc597702

See more details on using hashes here.

File details

Details for the file spatial_lda-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spatial_lda-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.9

File hashes

Hashes for spatial_lda-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69b99116cf6b2d67e1604d5dd3c7b527f2d72c37ee779be68c7e5df6287356dd
MD5 28bd409148333df675573170fd099c99
BLAKE2b-256 8e8ad195269166fe4234be0167df168b4daf894203cdf30a016452170e840fb0

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