1.1. pycellid package

1.1.1. Submodules

1.1.2. pycellid.core module

Merge and analyze tables of characteristics of cells and find images.

class pycellid.core.CellData(path, df)[source]

Bases: object

Collapse your data into a single data frame.

Recursively inspect the path, create a unique identifier per cell, and inspect related images.

Parameters
  • _path (str) – global path to output CellID tables.

  • _df (pandas.DataFrame) – Dataframe (output of CellID) containing all the measured parameters of each cell.

Returns

  • An instance of CellData containing all the information of

  • microscopy experiment.

Examples

>>> from pycellid.core import CellData
>>> df = CellData(
    path = '../my_experiment',
    df = my_dataframe
)
classmethod from_csv(path, **kwargs)[source]

Build a data frame from csv files contained in path.

A CellData class will be instantiated.

get_dataframe()[source]

Return a copy of the internal _df.

property plot

Represent set of cells_image or numerical data.

For cimage method you must specify an identifier id={}.

class pycellid.core.CellsPloter(cells)[source]

Bases: object

Accessor to plotter class.

Create a representation of each cell within a grid, inspect an entire image or create a snippet of a single cell. Provide a wrapper of pandas methods for plotting. Return axes to plot.

cells

An instance of CellData containing all the information of microscopy experiment.

Type

CellData

cells_image(array_img_kws=None, imshow_kws=None, ax=None)[source]

Display a random selection of cells on a square grid.

By default it represents a \(4\times 4\) matrix chosen at random.

Returns

Return type

ax to plot or figure.

Other Parameters
  • array_img_kws (dict) – Set the pycellid.images.img_array parameters.

    n : number of cells.

    channels : “TFP” or another that you have encoded.

  • imshow_kws (dict) – If you use matplotlib set equal to plt.imshow.

  • ax – Use your axes to plot.

cimage(identifier, box_img_kws=None, imshow_kws=None, ax=None)[source]

Show a sigle cell or complete image.

identifier’ param is required. Reference to a valid image or position. By default, an image with a size of (1392 X 1040)px will be rendered.

Parameters

identifier (path or dict) – path to an image file dict = { "channel":str, "UCID":int, t_frame":int }.

Returns

Return type

ax to plot or figure.

Other Parameters
  • box_img_kws (dict) – Set the pycellid.images.box_img parameters.

    imnumpy.array

    A full fluorescence microscopy image.

    x_posint

    \(x\)-coordinate of the center of the cell of interest.

    y_posint

    \(y\)-coordinate of the center of the cell of interest.

    radiusint

    lenght (in px) between the center of the image and each edge. Default = 90.

    mark_centerbool

    mark a black point. Default = False.

  • imshow_kws (dict) – If you use matplotlib set equal to plt.imshow.

  • ax – Use your axes to plot.

1.1.3. pycellid.images module

Images for PyCellID.

Attention! This module will not provide images. This module provides matrix representations for your analysis or to work with your favorite framework.

pycellid.images.array_img(data, path, channel='BF', n=16, criteria=None)[source]

Create a grid of images containing cells which satisfy given criteria.

Resulting image has ‘n’ instances ordered in a grid of shape ‘shape’. Each instance corresponds to a image centered in a cell satisfying provided criteria.

Parameters
  • data (pandas.DataFrame) – Dataframe (output of CellID) containing all the measured parameters of each cell.

  • path (str) – Path to the directory containing the images asociated to data.

  • channel (str) – Fluorescence channel of the image. The allowed values are 'BF', 'CFP', 'RFP' or 'YFP'.

  • n (int) – Number of instances composing the grid.

  • criteria (dict) – Dictionay containing the criteria of selection of cells.

Returns

iarray – A grid of n images of cells satisfying given criteria.

Return type

numpy.array

Raises

ValueError – If the number of cells satisfying the selection criteria is less than the number of cells to be shown.

pycellid.images.box_img(im, x_pos, y_pos, radius=90, mark_center=False)[source]

Create a single image contatinig an individualised cell.

The resulting image posses a mark in the center of the individualised cell and a pair of delimiters in the right and bottom edges.

Parameters
  • im (numpy.array) – A full fluorescence microscopy image.

  • x_pos (int) – \(x\)-coordinate of the center of the cell of interest.

  • y_pos (int) – \(y\)-coordinate of the center of the cell of interest.

  • radius (int) – lenght (in pixels) between the center of the image and each edge.

  • mark_center (bool) – mark a black point, defoult = False.

Returns

iarray – An array (image) containing an individualised, center-pinned, cell.

Return type

numpy.array

pycellid.images.img_name(path, ucid, channel, t_frame=None, fmt='.tif.out.tif')[source]

Construct the name of an image according to output format of CellID.

The returned string contains the path and name of the image.

Parameters
  • path (str) – Path to the directory containing images asociated to ‘data’.

  • ucid (int) – Unique traking number.

  • channel (str) – Fluorescence channel of the image. The allowed values are 'BF', 'CFP', 'RFP' or 'YFP'.

  • t_frame (int) – Time tag of the image.

  • fmt (str) – Format of the image to be read.

Returns

name – Name and path of an image according to the output format of CellID.

Return type

str

1.1.4. pycellid.io module

in-out implementations for pyCellID.

pycellid.io.make_df(path_file)[source]

Make a dataframe with number tracking ‘ucid’ and ‘position’.

Parameters

path_file (str) – Path to CellID’s outall data files.

Returns

df – Dataframe with df['ucid'] unique cell identifier.

Return type

pandas.DataFrame

pycellid.io.merge_tables(path, n_data='out_all', n_mdata='*mapping')[source]

Concatenate tables in the path with pandas method.

Transforms the identifying index of each cell from each data table into a temporal index UCID (Unique Cell Identifier) Disaggregate the columns of morphological measurements into columns by fluorescence channel. It uses the mapping present in the metadata file (mapping).

Parameters
  • path (str) – Global path to output ‘cellID’ tables.

  • n_data (str) – File name to find each data table.

  • n_mdata (str) – File name to find metadata tables or mapping_tags.

Returns

df – Dataframe containing ‘cellID’ data.

Return type

pandas.DataFrame

Examples

>>> import pycellid.io as ld
>>> df=ld.cellid_table(
    path = '../my_experiment',
    n_data ='out_all',
    n_mdata ='mapping'
)
pycellid.io.read_df(path_file)[source]

Read files with data of fluorescence microscopy experiments.

Create a dataframe with the data and rewrite headers format.

Parameters

path_file (str) – Path to files to be read.

Returns

df – Dataframe with data of fluorescence microscopy experiments.

Return type

pandas.DataFrame

1.1.5. Module contents

pyCellID.

An extension that analyze Cell-ID single-cell.