nulogo

Processing Module

flyeye.processing provides tools for converting raw fluorescence measurements into developmental timepoints.

Triangulation

Tools for estimating the median distance between adjacent columns of R8 photoreceptors.

class flyeye.processing.triangulation.ExperimentTriangulation(experiment, **kwargs)[source]

Object for estimating the median distance between adjacent columns of R8 cells for each disc within an experiment. Distance estimate is obtained by constructing a Delaunay graph connecting all annotated R8 neurons, filtering the edges by length and angle relative to the horizontal axis, then evaluating the median x-component of remaining edges.

The median inter-column distance is multiplied by the estimated MF velocity (0.5 columns/hr) to generate a distance-to-time scaling factor.

Attributes:

experiment (data.experiments.Experiment)

tri (dict) - {disc ID: Triangulation} pairs

plot_expression(ax, channel, color='black', **kwargs)[source]

Plot expression for all triangulations.

show_alignment(channel, xoffsets=None, ax=None, scatter=False, legend=True, window_size=100, ma_type='sliding', color_wheel='cmyk', figsize=(4, 3))[source]

Plot alignment of all discs.

show_triangulations()[source]

Visualize all triangulations.

class flyeye.processing.triangulation.Triangulation(disc, furrow_velocity=2, threshold=None, min_angle=30, max_angle=60, include_x=True, include_y=False)[source]

Object for estimating the median distance between adjacent columns of R8 cells within an individual eye disc. Distance estimate is obtained by constructing a Delaunay graph connecting all annotated R8 neurons, filtering the edges by length and angle relative to the horizontal axis, then evaluating the median x-component of remaining edges.

The median inter-column distance is multiplied by the estimated MF velocity (0.5 columns/hr) to generate a distance-to-time scaling factor.

Attributes:

params (dict) - triangulation parameters, {name: value}

xycoords (np.ndarray) - R8 cell positions

delaunay (scipy.spatial.tri) - Delaunay triangulation

distances (np.ndarray) - distances between adjacent R8 cells

edges (np.ndarray) - edge vertices

hours_per_pixel (float) - distance to time scaling factor

disc (data.discs.Disc)

add_edges_to_plot(ax, cmap=<matplotlib.colors.LinearSegmentedColormap object>)[source]

Add delaunay edges to existing axes.

get_disc()[source]

Return disc.

overlay_epression(ax, channel, **kwargs)[source]

Plot expression trajectory on twin y-axis.

plot_expression(ax, channel, **kwargs)[source]

Plot expression trajectory.

plot_histogram(ax)[source]

Histogram inter-R8 distances.

show(gs_parent=None, include_expression=True, channel=None, is_subplot=False, **kwargs)[source]

Plot inter-R8 distance distribution, Delaunay triangulation, and expression.

triangulate(disc, furrow_velocity=2, threshold=None, min_angle=30, max_angle=60, include_x=True, include_y=False)[source]

Run triangulation.

Args:

disc (data.discs.Disc)

furrow_velocity (float) - furrow inverse-velocity (hr/column)

threshold (float) - max quantile of included distances, 0 to 100

min_angle, max_angle (float) - min/max angle of included edges

include_x (bool) - if True, include x-distance

include_y (bool) - if True, include y-distance

Alignment

Tools for aligning expression dynamics between populations of cells.

class flyeye.processing.alignment.Alignment(t, x, t_ref=None, x_ref=None, metric='crosscorrelation', window_size=10)[source]

Object for alignment of a 1-D timeseries with another.

Attributes:

t, x (np.ndarray) - timeseries to be aligned

t_ref, x_ref (np.ndarray) - reference to which timeseries is aligned

window_size (int) - window size used for local smoothing

lag (float) - computed time shift for optimal alignment

score (float) - computed metric for quality of alignment

align(metric='crosscorrelation', window_size=50, dt=0.1)[source]

Run alignment to determine optimal lag.

Args:

metric (str) - name of alignment criterion

window_size (int) - window size for local smoothing

dt (float) - resolution

Returns:

lag (float) - time shift that maximizes quality of alignment

score (float) - quality of alignment

get_smoothed_scores(metric='crosscorrelation', window_size=10, dt=0.1)[source]

Returns smoothed alignment scores.

plot_alignment(scatter=True, trend=True, ax=None, window_size=100)[source]

Plot aligned time series.

Args:

scatter (bool) - if True, show individual samples

trend (bool) - if True, show moving average

ax (matplotlib.axes.AxesSubplot)

window_size (int) - window size for local smoothing

plot_scores(metric='crosscorrelation', ax=None, window_size=None, dt=0.1)[source]

Plot quality of alignment versus lag time.

Args:

metric (str) - name of alignment criterion

ax (matplotlib.axes.AxesSubplot)

window_size (int) - window size for local smoothing

dt (float) - resolution

class flyeye.processing.alignment.CellsAlignment(data, reference_data=None, channel='ch1_normalized', basis='t', metric='crosscorrelation', window_size=None)[source]

Object for alignment of one group of cells with another.

Attributes:

data (pd.DataFrame) - aligned cells data

Inherited attributes:

t, x (np.ndarray) - timeseries to be aligned

t_ref, x_ref (np.ndarray) - reference to which timeseries is aligned

window_size (int) - window size used for local smoothing

lag (float) - computed time shift for optimal alignment

score (float) - computed metric for quality of alignment

class flyeye.processing.alignment.DiscAlignment(disc, reference_disc, channel='ch1_normalized', metric='crosscorrelation', window_size=None)[source]

Object for alignment of one Disc instance with another.

Attributes:

disc (data.discs.Disc) - copy of aligned disc instance

hours_per_pixel (float) - distance to time scaling factor

space_lag (float) - computed time shift for optimal alignment (x-units)

time_lag (float) - computed time shift for optimal alignment (t-units)

Inherited attributes:

t, x (np.ndarray) - timeseries to be aligned

t_ref, x_ref (np.ndarray) - reference to which timeseries is aligned

window_size (int) - window size used for local smoothing

lag (float) - computed time shift for optimal alignment

score (float) - computed metric for quality of alignment

data (pd.DataFrame) - aligned cells data

static apply_to_disc(disc, space_lag, time_lag)[source]

Apply lag to copy of disc.

Args:

disc (data.discs.Disc)

space_lag (float) - lag to be applied (x-units)

time_lag (float) - lag to be applied (t-units)

Returns:

disc (data.discs.Disc) - copy of disc with lag applied

get_aligned_disc()[source]

Return aligned copy of disc.

class flyeye.processing.alignment.ExperimentAlignment(experiment, **kwargs)[source]

Object for the time-alignment of all discs within an experiment.

Attributes:

experiment (data.experiments.Experiment) - copy of experiment

scores (dict) - keys are disc IDs, values are quality of alignment

align_discs(**kwargs)[source]

Align all discs with first disc.

kwargs: keyword arguments for DiscAlignment instantiation

get_aligned_experiment()[source]

Return aligned experiment.

class flyeye.processing.alignment.MultiExperimentAlignment(*experiments, **kwargs)[source]

Object for the time-alignment of multiple experiments. The first experiment serves as the reference.

Attributes:

experiments (list) - copies of Experiment instances

static aggregate_discs(experiment)[source]

Aggregate all discs within an Experiment into single Cells object.

Args:

experiment (data.experiments.Experiment)

Returns:

cells (data.cells.Cells)

align_experiments(**kwargs)[source]

Align all experiments with first experiment.

kwargs: keyword arguments for alignment

get_aligned_experiments()[source]

Return aligned experiments.

Returns:

experiments (list) - list of copied Experiment instances