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

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.

class flyeye.analysis.spectrogram.Spectrogram(t, y, dy=None, periods=None)[source]

Object for spectral decomposition of a 1-D timeseries via Lomb-Scargle periodogram. Internal functions are based on AstroML library.

Attributes:

t (np.ndarray) - timepoints

y (np.ndarray) - values

dy (np.ndarray) - estimated measurement error

periods (np.ndarray) - oscillation periods tested (same units as t)

omegas (np.ndarray) - oscillation frequencies tested

PS (np.ndarray) - spectral power of each frequency

power (np.ndarray) - max. spectral power

dominant_period (float) - oscillation period of max. spectral power

dominant_frequency (float) - oscillation frequency of max. spectral power

add_power(ax, xaxis='period')[source]

Annotate peak spectral power.

Args:

ax (mpl.axes.AxesSublot)

xaxis (str) - quantity for x axis, either ‘period’ or ‘frequency’

compute_thresholds(confidence=None, nbootstraps=1000)[source]

Determine significance thresholds.

Args:

confidence (array like) - confidence levels to assess, length C

nbootstraps (int) - number of boostrap samples

Returns:

thresholds (np.ndarray) - spectral power thresholds, length C
evaluate_periodogram()[source]

Evaluate periodogram.

full_visualization(confidence=[99], nbootstraps=1000, xaxis='period')[source]

Plot spectrogram and corresponding signal on adjacent axes.

Args:

confidence (array like) - confidence levels to be added

nbootstraps (int) - number of bootstrap samples

xaxis (str) - quantity for x axis, either ‘period’ or ‘frequency’

plot_samples(ax)[source]

Plot timeseries samples.

Args:

ax (mpl.axes.AxesSublot)
plot_spectrogram(ax, confidence=[99], nbootstraps=None, xaxis='period', annotate=True, **kwargs)[source]

Plot spectrogram.

Args:

ax (mpl.axes.AxesSublot)

confidence (array like) - confidence levels to be added

nbootstraps (int) - number of bootstrap samples

xaxis (str) - quantity for x axis, either ‘period’ or ‘frequency’

annotate (bool) - if True, label peak spectral power

kwargs: plot formatting keyword arguments

Returns:

ax (mpl.axes.AxesSublot)
simple_visualization(ax=None, confidence=[99], nbootstraps=1000, xaxis='period', annotate=True, **kwargs)[source]

Plot spectrogram.

Args:

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

confidence (array like) - confidence levels to be added

nbootstraps (int) - number of bootstrap samples

xaxis (str) - quantity for x axis, either ‘period’ or ‘frequency’

annotate (bool) - if True, label peak spectral power

kwargs: plot formatting keyword arguments

Returns:

ax (mpl.axes.AxesSublot)