Skip to content

aicjanelia/phasor_mixing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOI:https:10.5281/zenodo.17793283

Phasor Mixing Coefficient

Implementation of a phasor-based method for analyzing signal mixing in multispectral images.

This code accompanies a manuscript currently under review. The manuscript_figures folder contains all relevant analysis code to produce the figures for the manuscript. The Python file pmc/pmc.py contains helper functions and the main classes--Phasor, PC, and PairMixture--which handle the phasor analysis of signal mixing.

The examples provided in the manuscript_figures folder provide illustrative instruction for using this method. However, a more general and detailed explanation will be provided here in the future.

Notes

This code was built and run on a PC running Windows 11 and WSL (Ubuntu).
The machine in question was equipped with the following relevant hardware:

  • Intel(R) Xeon(R) w7-3465X 2.50 GHz
  • 512 GB RAM

No GPU is required and the code was not optimized for utilizing a GPU.

Installation

Clone this repository into a local directory:

git clone https://github.com/aicjanelia/phasor_mixing

Create a new Python environment with your preferred environment manager (such as miniforge)

conda create -n phasor_mixing python=3.10.12
conda activate phasor_mixing

Install the required dependencies using pip

python -m pip install -r phasor_requirements.txt

Example

import phasorpy.phasor as ph
import phasorpy.plot as plot

import matplotlib.pyplot as plt
import os
import sys
import numpy as np

import warnings
warnings.filterwarnings("ignore", "is_categorical_dtype")
warnings.filterwarnings("ignore", "use_inf_as_na")

plt.style.use('default')
colors = ['#EC8609','#0365B5','#5EB5FD','#671343','#DF53A2']

# Edit this path to point to the downloaded data directory
droot = f'/path/to/downloaded/data'
os.chdir(droot)

# This path should not need to change unless this notebook is moved out of the local directory into which this repo was cloned
sys.path.append("../pmc/pmc.py")
from pmc import *

Running PMC analysis consists of calling only a handful of functions. Default parameters were used for all parameters throughout the associated manuscript.

The first step of PMC analysis is to determine the pure components (PC's). To do so, we first load the multispectral images and compute the phasor transform.

pc1_test = PC(file='/path/to/single_color_control_1.czi',name='Control_1',thresh=None,filt=True)
pc2_test = PC(file='/path/to/single_color_control_2.czi',name='Control_2',thresh=None,filt=True)

Then a two-step clustering workflow determines the centroids of the phasor clusters for each PC.

pc1_test.determine_peak()
pc2_test.determine_peak()

After PC phasor coordinates are determined, we load the two-color experiment image and compute its phasor transform. The single-color control objects--with their computed PC coordinates--are passed to the the mixture object as variables.

crop_dims = [y1,y2,x1,x2]

mix_mitomito = PairMixture(file='path/to/two_color_cell_1.czi',name='mito',
                  pcs=[pc1_test,pc2_test],thresh=None,filt=True,crop_dims=crop_dims)

Once the two-color multispectral image is converted to phasor space, the PC coordinates are used to define the mixing band. PMC is then calculated by taking the mean and normalized variance of the distribution of points within this band.

mix_mitomito.analyze_overlap()

For comparison throughout the associated manuscript, Pearson's and Manders' Correlation Coefficients (PCC and M1, M2) are also calculated.

mix_mitomito.calc_pearson_mander(pcs=mix_mitomito.purecomps)

Access to data for examples

The data relevant for the manuscript can be accessed at FigShare (doi in process).
The example Jupyter notebook will require the user to edit the path to point to the directory containing the downloaded data, as indicated.

About

Implementation of a phasor-based method for analyzing signal mixing in multispectral images.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors