Skip to main content

IFcoder: embeddings of immunofluorescence cell images

Project description

IFcoder

IFcoder is a Python package for embedding immunofluorescence cell images into the latent space using variational autoencoders (VAEs).

It is designed to operate seamlessly with CellProfiler and Scanpy, making it easy to move from image segmentation to downstream single-cell analysis.


Key features

  • Extracts image patches centered at cell objects based on CellProfiler segmentation.
  • Learns embeddings of the image patches using a convolutional VAE.
  • Stores the embeddings in a single AnnData file along with the image patches, CellProfiler measurements, and metadata.

Installation

pip install ifcoder

Input

  • CellProfiler output CSV. Four columns Location_Center_X, Location_Center_Y, ImageNumber, ObjectNumber are mandatory. Optionally, user can append additional columns of metadata (e.g., batch, treatment, diagnosis).
  • Input images of the CellProfiler pipeline. Image patches will be extracted from them.

Example

please see ifcoder_example.ipynb.

Usage

  1. Extract image patches based on CellProfiler output
ifcoder extract --cp-csv ${cellprofiler_csv} --out ${patches_h5ad}

This step:

  • reads a CellProfiler output (e.g. Cells.csv),
  • extracts image patches centered on cells,
  • saves the image patches, metadata, and measurements in an AnnData file
  1. Train VAE and compute embeddings
ifcoder train --data ${patches_h5ad} --out ${embeddings_h5ad}

This runs VAE and adds learned embeddings to the AnnData object adata.obsm["X_ifcoder"]

  1. Downstream analysis
import scanpy as sc

adata = sc.read_h5ad("embeddings.h5ad")
sc.pp.neighbors(adata, use_rep="X_ifcoder")
sc.tl.umap(adata)
sc.pl.umap(adata)

This example draws UMAP dimentionality reduction of cells.

Output

IFcoder uses AnnData as the central data structure:

  • adata.obsm["X_ifcoder"]

    Learned VAE embeddings of cell objects.

  • adata.obsm["patches"]

    Image patches of cell objects with dimensions (n_cells, n_channels, height, width).

  • adata.X

    CellProfiler quantitative measurements of cell objects. The columns starting with AreaShape_ and Intensity_ in CellProfiler output are stored here.

  • adata.obs

    Cell metadata (the columns without prefixes AreaShape_ and Intensity_).

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

ifcoder-0.1.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

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

ifcoder-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file ifcoder-0.1.0.tar.gz.

File metadata

  • Download URL: ifcoder-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ifcoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9f9a9c421bcaef67f4f130b951781e99f91f03231f60c590087961628eb146d8
MD5 9434812ea1e8d49f2cff1ef15d8d9932
BLAKE2b-256 449aa04dc6b8e3a6293e12aca7433004177055631481cb9cee04575457cf9e58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ifcoder-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for ifcoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ccd9e7eaff1f9257abc2c5568996bdec2492fde52fadaad6bc24a6231f3cfe9
MD5 51c99689200bf37e4a50b141fbf8e044
BLAKE2b-256 d8619b0688f6123ace61b932456f823ed23e6bf3afc5663005adb23c3b2afb8f

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