nulogo

Analysis Module

flyeye.analysis provides tools for detecting periodic spatial patterns of expression in the developing Drosophila eye field.

Spatial Correlations

Tools for quantifying expression similarity as a function of distance between cells.

class flyeye.analysis.correlation.CorrelationData(d_ij=None, C_ij=None)[source]

Container for correlations between 1-D timeseries.

Attributes:

d_ij (np array) - pairwise separation distances between measurements

C_ij (np array) - normalized pairwise fluctuations between measurements

classmethod bootstrap(x, y, confidence=95, N=1000, bins=None)[source]

Evaluate confidence interval for aggregation statistic.

Args:

x (np array) - values upon which samples are grouped

y (np array) - values upon which aggregate statistics are evaluated

N (int) - number of repeated samples

confidence (int) - confidence interval, between 0 and 100

bins (np array) - bins within which the statistic is applied

Returns:

centers (np array) - centers of distance bins

uppers, lowers (np array) - statistic confidence interval bounds

static get_binned_stats(x, y, bins, statistic='mean')[source]

Group samples into x-bins and evaluate aggregate statistic of y-values.

Args:

x (np array) - values upon which samples are grouped

y (np array) - values upon which aggregate statistics are evaluated

bins (np array) - bin edges

statistic (str) - aggregation statistic applied to each bin

Returns:

centers (np array) - bin centers

stats (np array) - aggregate statistic for each bin

visualize(ax=None, null_model=False, scatter=True, confidence=True, zero=True, ma_kw=None, nbootstraps=100, color='k', max_distance=500)[source]

Plot pairwise normalized fluctuations versus pairwise distances.

Args:

ax (mpl.axes.AxesSubplot) - if None, create figure

null_model (bool) - if True, shuffle d_ij vector

scatter (bool) - if True, show individual markers

confidence (bool) - if True, include confidence interval

zero (bool) - if True, include zero correlation line for reference

interval_kw (dict) - keyword arguments for interval formatting

ma_kw (dict) - keyword arguments for moving average smoothing

nbootstraps (int) - number of bootstrap samples for confidence interval

color (str) - color used for confidence interval

max_distance (float) - largest pairwise distance included

Returns:

ax (mpl.axes.AxesSubplot)

class flyeye.analysis.correlation.SpatialCorrelation(channel, data=None, y_only=True)[source]

Object for evaluating spatial correlation of expression between cells.

Attributes:

channel (str) - expression channel for which correlations are desired

y_only (bool) - if True, only use y-component of pairwise distances

Inherited attributes:

d_ij (np array) - pairwise separation distances between measurements

C_ij (np array) - normalized pairwise fluctuations between measurements

static from_experiment(experiment, channel, cell_type='pre', y_only=False, discs_included='all', **selection_kw)[source]

Instantiate a SpatialCorrelation instance for all specified cells in a flyeye.Experiment instance.

Args:

experiment (flyeye.Experiment)

channel (str or int) - channel for which correlations are desired

cell_type (str) - type of cells to select

y_only (bool) - if True, only use y-component of data

discs_included (list or str) - included discs, defaults to all

selection_kw: keyword arguments for cell position selection

Returns:

corr (analysis.correlation.SpatialCorrelation)

classmethod get_covariance_vector(vector)[source]

Get upper triangular portion of pairwise expression covariance matrix.

Args:

vector (1D np.ndarray) - expression levels for each cell

Returns:

covariance (1D np.ndarray) - pairwise fluctuations, ordered row then column

classmethod get_distances_vector(data, y_only=False)[source]

Get upper triangular portion of pairwise distance matrix.

Args:

data (pd.Dataframe) - cell measurements including position data

y_only (bool) - if True, only use y-component of cell positions

Returns:

distances (1D np.ndarray) - pairwise distances, ordered row then column

static get_matrix_upper(matrix)[source]

Return upper triangular portion of a 2-D matrix.

Parameters:

matrix (2D np.ndarray)

Returns:

upper (1D np.ndarray) - upper triangle, ordered row then column

Spectrogram

Tools for statistical detection of periodic spatial patterns, primarily via the AstroML library.