Skip to content

funalab/pyCellLineage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intercellular Interaction Mechanisms Promote Diversity in Intracellular ATP Concentration in Escherichia coli Populations: (pyCellLineage)

Last Modified: Fri, 14 Oct 2022 02:31:28 +0900

Copyright (c) 2018-2022 Funahashi Lab., Keio University.

Introduction

Welcome to pyCellLineage! This software allows users to analyze ATP heterogeneity among single cell populations grown in a 2-dimensional surface using time-lapse fluorescent images. This software allows users to do the following analyses on these images.

  • Analysis of stochastic state switching using hidden markov models(HMM).
  • Analysis of periodic oscillation using Gaussian Process Regression(GPR) and Fourier Transform.
  • Analysis of cellular age using cellular lineages and spatial information.

Regarding previously reported programs such as Schnitzcells(Young et al. 2012), and cellular transmission analysis (van Vliet et al. 2018) they are not included in pyCellLineage for license purposes. The user must download the above codes on their own. All data used and generated by the analyses, including Schnitzcells and cellular transmission analysis, are included in the Data directory of this software.

Installation

To install clone this git repository to your computer. The software is implemented as a combination of Python and R scripts. It also uses the specified modules that are listed below in Requirements. To use this software you must have Python 3.7.10 and R 3.4.3. The software has been tested on Mac OS X High Sierra.

Quick start usage

The software can be executed to generate figures and csv files used in the paper as follows.

# In terminal
% python ./Analysis_Gui/SampleAnalysesGui.py  

# -or on ipython-  

In []: from pyCellLineage.Analysis_Gui import SampleAnalysesGui
In []: SampleAnalysesGui.run()

Once the software has started to run you can select the following modes via GUI to generate Figures used in paper.

Main Figures

  • Figure 1
    Histograms for glucose control and poor conditions. Run python program ./Data/Histograms/plotHistograms.py.
% python plotHistograms.py
  • Figure 2
    2-dimensional cellular lineages of all samples. Run GUI, and choose save when asked modes for lineage.

  • Figure 3
    3-dimensional cellular lineages color coded by ATP class. Run GUI, and choose 3d when asked modes for hmmPrepClass.

  • Figure 4
    Histograms for ATP/Glycerol added Glucose Control conditions and Supernatant of Glucose fixed Glucose poor conditions. Same as Figure 1.

Supplementary Figures

  • Supplementary Figure 1
    Caliburation curve used in this analysis. Run jupyter notebook ./Data/CalibCurve/drawStdCurve.ipynb.
% jupyter-notebook-3.7 drawStdCurve.ipynb
  • Supplementary Figure 3
    2-dimensional cellular lineages color coded by ATP class. Run GUI, and choose 2d when asked modes for hmmPrepClass.

  • Supplementary Figure 4
    Hidden Markov Models constructed for glucose control conditions with randomization test results. To constrcut Hidden Markov Models run R script ./LIAnalysis/HMM_model_beta2.R. To plot results run MATLAB program ./Data/SuplFigCode/HMM_RandomizationTestPlot.m

% Rscript HMM_model_beta2.R
# In MATLAB
> cd ./Data/SuplFigCode/
> SampleDir = '../glc_poor' % use SampleDir = '../glc_rich' for control conditions
> RandomizationTestPlot(SampleDir)
  • Supplementary Figure 5
    Hidden Markov Models constructed for glucose poor conditions with randomization test results. Same as Suplementary Figure 4

  • Supplementary Figure 6
    Individual cellular lineages of all samples. Run GUI, and choose fft when asked modes for oscillation.

  • Supplementary Figure 7
    Box plot comparison of results generated by fourier free transform for all samples. Run python program ./Data/SuplFigCode/Osscilatory_PlotSample.py.

% python Osscilatory_PlotSample.py
  • Supplementary Figure 8
    Box plot comparison of results of cellular age for all samples. Run python program ./Data/SuplFigCode/Age_PlotSample.py.
% python Age_PlotSample.py
  • Supplementary Figure 9
    Randomization test results for spacial correlation. Generated by van Vliet et. al's code for Randomization Testing.

  • Supplementary Figure 10
    Plotted GC/MS result. Run python program./Data/GC:MS/plotGCMS.py.

% python plotGCMS.py

Specific contents and usage

GUI explanation

Each screen allows the user to choose which analyses to conduct. Below is an ordered explanation for each screen.

  1. Sample Selection:
    For exact replicaton of data included in paper, select all samples.

  2. Lineage Plots:
    Allow plotting of 3d lineages and 2d lineages. If there are no preferences in saving select show. Select 3d for 3-dimensional lineage, defaults to 2-dimensional.

  3. Data Frames:
    Allow saving of constructed cell data frame. Contains cell uIDs and relationship with other cells. Also contains information on size, position, intensity of each individual. Look bellow for specific explanation of Cell DataFrame.

  4. Oscillatory Analysis:
    Allows analysis for Fourier Free Transform (fft). If data directory is prepared for use, select fft.

  5. Histograms:
    Plots histograms of each time point in lineage. None are used to plot histograms used in the paper.

  6. Hidden Markov Model Analysis (6,7,8th screens):
    Select hmmPrep totalATP gmmPoor for results used in paper. Select hmmPrep class 2D for plot of classified lineage.

Cell DataFrame Explanation

Below is a table listing names of variables included in Cell DataFrame

Variable Name Contents
ID unique ID within single image for individuals
uID unique ID within whole lineage
motherID uID of mother Cell
daughter1ID uID of one daughter cell
daughter2ID uID of other daughter cell
cenX centroid x position
cenY centroid y position
Z time frame
cellNo ID used in Schnitzcells
intensity Intensity of Individual in image
area Area of individual
ATP intracellular ATP concentration when input image is raw ratio image
ATP_Class ATP Class used for HMM Analyses
Age Cellular Age of Individual
linIdx ID of lineage; depends on how many cell there are in first image
... Other variables can be appended using pandas

All code and how to use

This software can be used to create lineages of schnitzcells Data.
The software consists of three main directories of programs,

  • LIAnalysis
    Mainly used for analysing the lineage for cellular age, HMM analysis and periodic oscillation analysis. It also prepares data for HMM Analysis and GPR. By using the R-scripts included in the directory, it is possible to run HMM analysis and gaussian process regression.

  • PDAnalysis
    Mainly used for analysis on doubling time and cell size.

  • lineageIO
    Mainly used to create a custom Dataframe reading the schnitzcell lin.mat data. It can also load Ratio Imgs to calculate ATP concentration. (Look at below warnings)
    Once the Dataframe has been created it can either plot 2D, 3D lineage renderations or create histograms of each time point. Visualize Lineages also makes it possible for segmented images to show tracked information.

An optional GUI is also provided,

  • Analysis_Gui
    This is a very Simple GUI to select which Samples you would like to Analyze and allows you to select Analysis Modes.
    To start GUI enter;
    # In terminal
    % cd /Path/To/pyCellLineage
    % python Analysis_Gui/SampleAnalysesGui.py  
    
    # -or on ipython-  
    
    In []: from pyCellLineage.Analysis_Gui import SampleAnalysesGui
    In []: SampleAnalysesGui.run()
    
    The results that are created by these analyses are saved in the directory of the sample.

Warnings:
For Experiments, Analysis_Gui uses paths that are hardcoded in pyCellLineage/Analysis_Gui/pathParms.py All functions depend on a certain directory structure. (See Sample Data Structure for details)

Another point to keep in mind is that when calculating atp concentration pyCellLineage looks for a file named "atp_calib.csv" in the lineageIO directory. It is a simple CSV file with the below contents. Please updated the file on your own whenever you redraw the caliburation curve.

parameter,value
Emax,4.9474
EC50,5.8325
d,0.6521

The first three directories are part of the pyCellLineage Module,
but the util directory also contains python or zsh programs that are useful in extracting schnitzcell prepared images from raw images,
creating an automatic initSchnitz command unique to the experiment for MATLAB and also creating Ratio images from the raw images.

About utils

The util directory contains programs that are convenient in constructing specified directories or images. There are explanations below.

  • arrangeFiles.sh
    Arranges files to schnitz readable directory format.

ex)

% arrangeFiles.sh ./Pos0
  • imagesToSchnitz.py Makes image file names to schnitz readable format.

ex)

% imagesToSchnitz.py ./405
  • initschnitzmaker.py Makes initial initschnitz command for Schnitzcells based on current Directory. (Directory must be schnitz readable format)
% python initschnitzmaker.py #at directory that has been prepared for schnitz
  • CreateRatioFS.py
    Make ATP images from raw images.

Data directory

The Data directory contains all raw CSVs and figures generated by pyCellLineage for the paper. The Data directory has subdirectories seperated accordingly.

  • ATPAssay
    Microsoft Excel File of Data used in ATP reporte assay.

  • CalibCurve
    Data and jupyter notebook program used to generate standard curve.

  • GC/MS
    Result data of GC/MS.

  • Histograms
    Images used to generate intracellular ATP concentration histogram results and the merged results of each sample.

  • SuplFigCode
    Code used to generate figures used in Supplementary Figure #,# and #.

  • Total
    Generated Figures by SuplFigCode.

  • glc_poor
    Images used for each specific sample analysis and generated CSVs/Figures by pyCellLineage. Contains samples under glucose poor conditions and the MATLAB results of spacial correlation and factors generated by code used in van Vliet et. al.

  • glc_rich
    Images used for each specific sample analysis and generated CSVs/Figures by pyCellLineage. Contains samples under glucose control conditions and the MATLAB results of spacial correlation and factors generated by code used in van Vliet et. al.

Lineage Analysis Sample Directory Strcuture

The cell lineage analyses gui works only on the below directory structure.

  • glc_poor/glc_rich
    • sample X
      • Pos0
        • 405 Contains fluorescent microscope images named img_XXXXXXXXX_405_000.tif
          Cropped microscope image

        • 405FS
          Contains fluorescent microscope images renamed 405-g-XXX.tif
          Used for Cellular Segementation Purposes by Schnitzcells

        • 488
          Contains fluorescent microscope images named img_XXXXXXXXX_488_000.tif
          Cropped microscope image

        • Phase Contains bright field microscope images named img_XXXXXXXXX_Phase_000.tif Cropped microscope image

        • RatioFS
          Contains ATP concentration translated images named 405-g-XXX.tif Used for construction of cellular lineages and analyses

        • saveimg Data storage directory for data generated by MATLAB using Schnitzcells and van Vliet et. al's code for cellular transmission.

Update Information and News

pyLineage27 has been removed from the main branch.

Requirements

Python Modules

  • numpy : 1.15.2
  • pandas : 0.23.4
  • matplotlib : 2.2.3
  • scipy : 1.1.0
  • scikit-image : 0.14.2_1
  • networkx : 2.2
  • opencv : 3.4.10

Additional GUI

  • kivy 2.0.0

R Libraries

  • aphid
  • doParallel
  • foreach
  • here
  • GPfit
  • lhs

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published