Functions
- bacteria.functions.bin_column(df_3d, column='F/V', bins=10, sort_by='Cell Cycle', print_bins=True, conf=0.95, method=<function mean>)
Perform the binning of one column.
Parameters
- df_3dDataFrame
DataFrame with the 3D data
- columnstr
DataFrame column to bin
- binsint or list (optional)
Amount of bins to use, default = 10. This parameter can also receive a list/nd.array with the desired bins intervals. e.g., [0,500,1000,1500,2000,2500,3000, 3500,4000,4500].
- sort_bystr (optional)
The parameter to bin the data (x axis), the default is ‘Cell Cycle’, but is also possible to bin by ‘Volume’ or ‘Time (fps)’ columns.
- print_binsbool
If true will plot a report of bins
- conffloat (optional)
confidence interval desired for bootstrap, default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
Returns
- bins_meannd.array
array(2,bins) with bin value in the first column and the mean value in the second
- cidict
array(2,bins) with inferior Confidence Interval in the first column and the upper one in the second
- bacteria.functions.cells_length(df, limit_inf, limit_sup, ax=None)
Plot the cell’s lenght over time, filtering by size. The data will be filted based on the size of the cells (< mean + 1 std)
Parameters
- dfDataFrame
DataFrame of 3D data
- limit_infint
Start moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
- limit_supint
End moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.cells_pos_shift(df_3d, pos)
Function to extract the Cell ID of all cells that were born after an moment in time.
Parameters
- df_3dDataFrame
3D data
- posint
Moment in time to be the start
Returns
- cells_posnd.array
array with the Cell ID for cells that were born after the treshold
- bacteria.functions.cells_pre_shift(df_3d, pre)
Function to extract the Cell ID of all cells that divided before an moment in time.
Parameters
- df_3dDataFrame
3D data
- preint
Moment in time to be the limit
Returns
- cells_prend.array
array with the Cell ID for cells that divided before the treshold
- bacteria.functions.ci_bootstrap(arr, conf=0.95, method=<function mean>, plot=False)
Calculate the confidence interval (CI) based on different methods.By default the bootstrap is done for 10000 times.
Parameters
- arr: nd.array
data to calculate the CI
- conffloat (optional)
confidence interval desired, default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
- plotbool (optional)
If true plot the distribution based of the boostrap and the CI.
Returns
- ci_lowfloat
Value for the lower CI (default 2.5%)
- ci_highfloat
Value for the higher CI (default 97.5%)
- bacteria.functions.column2d_mean(df, column='Vd-Vb', window=30, conf=0.95, method=<function mean>)
Estimate the column mean for all cells using the ‘pd.melt()’ method, sorting by time at division.
Parameters
- dfDataFrame
DataFrame with the deravtive data alongside with the time and volume or the 2D df
- columnstr
column to calculate the mean
- windowint
value to use in ‘rolling.mean()’
- conffloat (optional)
confidence interval desired for bootstrap, default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
Returns
- timesnd.array
1D time vector with the uniques time points (fps)
- meannd.array
1D time vector with the mean for each time point
- cind.array
array(2,bins) with inferior Confidence Interval in the first column and the
- bacteria.functions.column_mean(df, column, conf=0.95, method=<function mean>, smooth=False, factor=10, plot_hist=False)
Estimate the column mean for all cells using the ‘pd.melt()’ method, sorting by time.
Parameters
- dfDataFrame
DataFrame with the deravtive data alongside with the time and volume or the 3D df
- columnstr
column to calculate the mean
- conffloat (optional)
confidence interval desired for bootstrap, default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
- smoothbool
If true will smooth the column value and the CI
- factorint
Factor to smooth the data, default = 10
- plot_hist: bool (optional)
Plot a histogram with the data distribution
Returns
- timend.array
1D time vector with the uniques time points (fps)
- meannd.array
1D time vector with the mean for each time points
- cind.array
array(2,bins) with inferior Confidence Interval in the first column and the
- bacteria.functions.combined_filters(df_2d, df_3d, std=1, daughter=True, lentgh=True, plot=False)
Plot the mean fluo for the lineage for the entire experiment. Check also fluor_lineage(). The default filter is ‘stat0==2’ removing the data with grow rate = 0, values with NaN values and data with low points.
Parameters
- df_2dDataFrame
DataFrame of 2D data
- df_3dDataFrame
DataFrame of 3D data
- stdint (optional)
Number of standard deviations desired to use as reference for the cell size filter
- daughterbool (optional)
If True the daughter filter will be used. If True alongised with ‘lentgh’ the two filters will be used
- lentghbool (optional)
If True the lentgh filter will be used. If True alongised with ‘daughter’ the two filters will be used
- plotbool (optional)
Plot the histogram pre and pos filter the data
Returns
- df_2dDataFramef
Filtered DataFrame of 2D data
- df_3dDataFrame
Filtered DataFrame of 3D data
- gc_filternd.array
Array with good cells ID after filter
- bacteria.functions.concatenate_clist(path, fps=3, filters=True, save_mat=False, path2save=None, const=0.1067, direct=False)
Concatenate all c_list.mat from one experiment in DataFrames.
Parameters
- pathstr
Experiment path
- fpsint (optional)
Frames per second used in the experiment, usual 3
- filtersbool (optional)
Filter data based on data2d[‘stat0’] = 2 and is.nan()
- save_matbool (optional)
save the dataframes in .mat format.
- path2savestr (optional)
If false, the data will be saved into the current directory else, should pass a path to save.
- constfloat (optional)
parameter extracted from the microscope to transform pixel to micrometers
- directbool
If you have all the clists in one folder.
Returns
- data2Dpandas DataFrame
with 2D data
- data3Dpandas DataFrame
with 3D data
- gcnd.array
array with good cells ID
- bacteria.functions.derivative(df_3d, column='Fluor1 sum', minus=1, plus=2, bar=True)
Calculate the derivatine of the fluor sum using a 3 slide window. Return a dataframe with the derivative, derivative normalized by volume, logrith
Parameters
- df_3dDataFrame
DataFrame of 3D data
- columnstr
column to calculate the derivative
- minusint (optional)
value to change the window to the convolution to adapt the range for the loop (e.g, default = i in range(1,len(x)-2))
- plusint (optional)
value to change the window to the convolution to adapt the range for the loop (e.g, default = i in range(1,len(x)-2))
Returns
- df_derivativeDataFrame
DataFrame with the deravtives data alongside with the time and volume
- dict_derivativedict
A dict with other dicts that contains the [volume,fluor,time,F/V and all derivatives] of each cell at the slide window (cell number = key).
- bacteria.functions.derivative_binning(df_deriv, derivative_column='Derivative', bins=10, sort_by='Cell Cycle', print_bins=True, conf=0.95, method=<function mean>)
Perform the binning of the derivative of one column. Please check ‘derivative()’.
Parameters
- df_derivDataFrame
DataFrame with the derivative data, output from ‘derivative()’
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume.
- binsint or list (optional)
Amount of bins to use, default = 10. This parameter can also receive a list/nd.array with the desired bins intervals. e.g., [0,500,1000,1500,2000,2500,3000, 3500,4000,4500].
- sort_bystr (optional)
The parameter to bin the data (x axis), the default is ‘Cell Cycle’, but is also possible to bin by ‘Volume’ or ‘Time (fps)’ columns.
- print_binsbool
If true will plot a report of bins
- conffloat (optional)
- confidence interval desired for bootstrap,
default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
Returns
- bins_meannd.array
- array(2,bins) with bin value in the first
column and the mean value in the second
- cidict
- array(2,bins) with inferior Confidence
Interval in the first column and the upper one in the second
- bacteria.functions.df_data2d(data, fps=3, const=0.1067, comp=False)
Create a pandas DataFrame of the 2D data using the headers pre-determined.
Parameters
- data: clist.mat
Supersegger clist already loaded
- fps: int (optional)
Frames per second used in the experiment, usual 3
- constfloat (optional)
parameter extracted from the microscope to transform pixel to micrometers
- compbool
Input data are the compiled clists (clist for all xy/fovs)
Returns
df: pandas DataFrame
- bacteria.functions.df_data3d(data, fps=3, filters=True, const=0.1067, comp=False)
Create a pandas DataFrame of the 2D data using the headers pre-determined.
Parameters
- dataclist.mat
Supersegger clist already loaded
- fpsint (optional)
Frames per second used in the experiment, usual 3
- filtersbool (optional)
Filter data based on data2d[‘stat0’] = 2 and non NaN’s
- constfloat (optional)
parameter extracted from the microscope to transform pixel to micrometers
- compbool
Input data are the compiled clists (clist for all xy/fovs)
Returns
- dfpandas DataFrame
3D data in df
- gcnd.array
array with good cells ID
- bacteria.functions.diff_minima(df_3d, df_2d, derivative_column='Derivative/V', order=3, pre=None, pos=None, adjust=False)
Function to plot the distance between the minimas of the daughter and mother by the mothe volume. The ‘pre’ and ‘pos’ to be used, both must be different than ‘None’. It is possible to use a higher order together with adjust order for each cell, the higher the order, the higher the noise acceptance. Higher orders take longer and can reach 20 minutes to run. The value of the minimum used comes from the column ‘Smoothed Volume’, output of ‘lineage_derivative()’. Also, plot the histogram of the diff.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- df_2dDataFrame
DataFrame of 2D data
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume. Default is ‘Derivative/V’.
- orderint (optional)
The order of the polynomial used to fit the savgol_filter from scipy in ‘lineage_derivative()’ higher order is better to find more minimas, accept more noise. Default is 3.
- preint (optional)
Save the data pre this moment in minutes
- posint (optional)
Save the data pos this moment in minutes
- adjustbool (optional)
If true it’s possible to pass a bigger order value and the algorithm will adjust for each cell if needed and the order used for each cell is stored in the dictionary vol_dict[‘order’][‘cell id’]. Default false
- plotbool (optional)
If true will plot the result of the analysis, if ‘pre’ or ‘pos’ is None will plot just all the data.
Returns
- vol_dictdict
Dictionary with the following keys ‘all’, ‘pre’, ‘pos’ with subkeys ‘diff’ and ‘minima’, ‘diff’ is the difference between daughter and mother volume at minima and ‘minima’ the minima volume of the mother. The key ‘order’ store the order used for each cell and the value of ‘pre’ and ‘pos’ for plot purpose.
- bacteria.functions.fluor_lineage(df_2d, df_3d, limit_inf, limit_sup)
Calculate the fluor mean for every mother cell and daugther. The bins here were not made using pandas.
Parameters
- df_2dDataFrame
DataFrame of 2D data
- df_3dDataFrame
DataFrame of 3D data
- limit_infint
Start moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
- limit_sup: int
End moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
Returns
- mean_mnd.array
vector with the mean value for every mother cell
- bins_mnd.array
vector with bins used for mother cell’s (cell cycle)
- mean_dnd.array
vector with the mean value for every daugther cell
- bins_dnd.array
vector with bins used for daugthers cell’s (cell cycle)
- cells_removedlist
list with cell id for each cell without daugther
- bacteria.functions.lineage_corr_filter(df_3d, reverse_lineages, shift=None, threshold=0.96, column='Fluor1 mean', method=<function var>)
Filter the lineages based on the correlation between the longest lineage of a mother cell. Return the lineages that match the parameters.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- shiftint (optional)
Value to use to extract the lineages that pass through this time point, usually used to get the shift moment. If shift is passed automatically the output will be filtered for these cells. Default is None.
- thresholdfloat (optional)
Value to be used as threshold to determine if the lineage must be maintained. If the correlation between the daughter lineages is less than the threshold value, the lineage is maintained. Default ‘.96’.
- columnstr (optional)
The column to extract the feature of the dataset. Default ‘Fluor1 mean’.
- methodfunction (optional)
Method to use to extract feature of each cell, default its np.mean. Other options are np.std and stats.sem.
Returns
- filtered_lineagelist
List with the Cell ID for each lineage that match the paramters (threshold and shift). Longest lineages for each mother cell and different from each other in case of more than one.
- bacteria.functions.lineage_derivative(df_3d, reverse_lineage, column='Fluor1 sum', derivative_column='Derivative', std=2, window=None, order=5, perc=0.7, mode='nearest')
Plot a single lineages derivative. It’s possible to chose different columns to inspect. The function is already removing the last value of the reverse_lineage, because the last cell has no daughter and is removed by our filters. In this code the volume on the X axis are filtred using a standard window (lenght*perc) and summed with the last value of the previous cell and with the mean diff inside the cell. To create this volume array the data is filtered using the parameters ‘perc’ and ‘order’, in case of the order is biggter than the window the order will be reduced automatically. This manipulation isn’t used to normalize the derivative data. Also, the derivative data is filtered to remove the outliers based on the ‘std’ parameter.
Parameters
- df_3dDataFrame
3D data
- reverse_lineagelist
List with the lineage Cell ID’s, output from ‘lineages()’
- columnstr (optional)
The df column to compute the derivative, default is ‘Fluor1 sum’.
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume. Default is ‘Derivative’.
- stdint (optional)
Number of standard deviations to filter the data
- windowint (optional)
The window value to smooth the graph using savgol_filter from scipy. Default 19 based on previous tests.
- orderint (optional)
The order of the polynomial used to fit the savgol_filter from scipy. Default 5 based on previous tests. If the order is too large for one cell the order will be automatically decreased using ‘_adjust_order()’.
- percfloat (optional)
Percentage of the length of each cell to estimate the window to smooth the data for the volume adjust. Default is .7, should be between .1 to 1.
- modestr (optional)
This determines the type of extension to use for the padded signal to which the filter is applied check ‘scipy.signal.savgol_filter()’
Returns
- df_lineageDataFrame
Data frame with the columns ‘Cell ID’, ‘Time (fps)’, ‘Volume’, ‘Derivative’, ‘Smoothed Volume’, ‘Smoothed Derivative’. The columns ‘Cell ID’, ‘Time (fps)’, ‘Volume’ are related and should be used to access the data relative for each cell. The columns ‘Smoothed Volume’ and ‘Smoothed Volume’ are the data filtered and concatenated of the entire lineage (these columns are not related with the ‘Cell ID). The column ‘Time (fps)’ is used to plot the time for each cell and for entire lineage.
- peaksdict
Dictionary data with the indexes of local minima and local maxima related to ‘Smoothed Volume’,’Smoothed Derivative’ and ‘Time (fps)’.
- order_dictdict
Dictionary with the order used in each cell
- bacteria.functions.lineages(df_2d, nodes_min=5)
Extract the lineage for the entire dataset using AnyTree lib, data is organized using the node structure. The output is in dicts and anytree.node types. The last value of reverse lineage is the ID of a cell that we don’t have data, cells without daughters are removed by Stat0 == 2 filter.
Parameters
- df_2dpd.DataFrame
2D data
- nodes_minint
The minimum value of nodes in the lineage
Returns
- reverse_lineagesdict
Key values are the cell id of cells with more than X nodes (nodes_min), and the data values is a list with the nodes to reach the key cell.
- large_lineagesdict
Key values are the cell id of the root of the lineage, the data values are the all cells ids that are part of this lineage (mother and daughters).
- large_nodesdict
Key values are the cell id of the root of the lineage, and the values are the Node with all the information about this lineage, structure in anytree.Node dataype
- all_nodesdict
Key values are all the cell id’s in the dataset, and the values are the Node with all the information about this lineage, structure in anytree.Node dataype
- bacteria.functions.lineages_pos_shift(df_3d, reverse_lineages, shift)
Filter the lineages based on time, used to extract lineages pre shift. Save the Cell ID of every lineage that the first cell was born after the shift.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- shiftint
The time value of the shift
Returns
- lineage_filterlist
List with the Cell ID used as a key in ‘reverse_lineages’ dict.
- bacteria.functions.lineages_pre_shift(df_3d, reverse_lineages, shift)
Filter the lineages based on time, used to extract lineages pre shift. Save the Cell ID of every lineage that the first cell was born before the shift.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- shiftint
The time value of the shift
Returns
- lineage_filterlist
List with the Cell ID used as a key in ‘reverse_lineages’ dict.
- bacteria.functions.lineages_shift(df_3d, reverse_lineages, shift)
Filter the lineages based on time, used to extract lineages that pass through a time point (up shift or down shift). Save the Cell ID of every lineage that the first cell was born before the shift and the last was born after the shift.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- shiftint
The time value of the shift
Returns
- lineage_filterlist
List with the Cell ID used as a key in ‘reverse_lineages’ dict.
- bacteria.functions.longer_lineages(df_3d, reverse_lineages, column='Fluor1 mean', method=<function var>)
Filter the lineages based on length and return the variance (default or other method - np.mean, np.std, stats.sem and others) for one feature (as default ‘Fluor1 mean’, but can be used any column of df_3d). Return a dictionary with the root cell as a key, each root cell have dictionaries with the longest lineages and use the last cell ID as key. The values in the dict is the method applied into the column choosed. This function is used as support for other functions.
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- columnstr (optional)
The column to estimate the
- methodfunction (optional)
Method to use to extract feature of each cell, default its np.mean. Other options are np.std and stats.sem.
Returns
- root_dictdict
Dict with the mother Cell ID used as a key and inside each mother cell another dict with the longest daughters, the key of this dict is the last cell of the lineage.
- lineage_arraynd.array
Array with all lineages in arrays. Used in plot functions.
- len_dictdict
Dict with the mother Cell ID used as a key and inside the lenght of the longest lineage.
- bacteria.functions.plot_2d_data(df_2d)
Plot The Growth Rate, Cell Age and Long axis (L) death by ‘Birth Time + Age’.
Parameters
- df_2dDataFrame
DataFrame of 2D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- shiftint
The time value of the shift
Returns
None
- bacteria.functions.plot_bins(arr, ci, column='Fluor1 sum', derivative_column='Derivative', sort_by='Cell Cycle', cmap='rainbow', line='k', ax=None)
Plot the bins that are organized into arrays.
Parameters
- arrnd.array
2D array containing bins and the data to plot
- cind.array
2D array containing the inferior and superior confidence interval values
- columnstr (optional)
The feature used to calculate the derivative, yaxis label
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume.
- sort_bystr (optional)
The parameter used to bin the data. Default is ‘Cell Cycle’, xaxis legend.
- cmapstr (optional)
The desired colormap to plot the interval between bins. Default is ‘rainbow’, to remove this pass ‘None’. Check matplotlib colormaps for all options.
- linestr (optional)
The color of the line, default is black. Can be adjusted accordingly to the color map.
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_cell_lineage(df_2d, reverse_lineage, x_axis, y_axis, z_axis, c_axis, colormap='rainbow', ax=None)
Plot the cell size lineage. It’s possible to pick different varibales for each axis. The function is already removing the last value of the reverse_lineage, because the last cell has no daughter and is removed by our filters.
Parameters
- df_2dDataFrame
2D data
- reverse_lineagelist
list with the Cell ID’s to plot, check ‘lineages()’
- x_axisstr
Data to plot in the X axis, use the df_2d terms.
- y_axisstr
Data to plot in the Y axis, use the df_2d terms.
- z_axisstr
Data to use as Z axis, use the df_2d terms. In this case the Z is the size of each scatter point. It’s intrensting to use cell size as parameter, at division or at birth.
- c_axisstr
Data to use in the color of each saccater point and in the color bar, use the df_2d terms. It’s intresting to use fluorescence data.
- colormapstr (optional)
Colormap to use. Check the matplotlib documentation. Default = rainbow.
- axnd.array (optional)
Pass the ax for subplot.
Returns
None
- bacteria.functions.plot_cell_size_lineage(df_2d, reverse_lineage, ax=None)
Plot the cell size lineage. X-axis is the Cell ID and the Y-axis is the Cell Size (‘Long axis (L) death’) in px, the size of the circle is proportionald to the cell size.
Parameters
- df_2dDataFrame
2D data
- reverse_lineagelist
list with the Cell ID’s to plot, check ‘lineages()’
- axnd.array (optional)
Pass the ax for subplot.
Returns
None
- bacteria.functions.plot_column2d_mean(times, mean, ci, column='Vd-Vb', color='green', ax=None)
Plot the colunm mean for the entire experiment. Check also ‘column_mean()’.
Parameters
- timend.array
1D time vector with the uniques time points (fps) output of ‘column_mean()’
- meannd.array
1D time vector with the mean growth rate for each time point output of ‘column_mean()’
- cind.array
array(2,bins) with inferior Confidence Interval in the first column and the upper one in the second output of ‘column_mean()’
- columnstr
DataFrame column to estimate the column_mean, default is ‘Volume’
- color: str (optional)
Color to plot the growth rate.
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_column_mean(times, mean, ci, column, color='Orange', ax=None)
Plot the colunm mean for the entire experiment. Check also ‘column_mean()’.
Parameters
- timend.array
1D time vector with the uniques time points (fps) output of ‘column_mean()’
- meannd.array
1D time vector with the mean growth rate for each time point output of ‘column_mean()’
- cind.array
array(2,bins) with inferior Confidence Interval in the first column and the upper one in the second output of ‘column_mean()’
- columnstr
DataFrame column to estimate the column_mean, default is ‘Volume’
- color: str (optional)
Color to plot the growth rate.
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_corr_lineage(df_3d, reverse_lineages, mother_cell, column='Fluor1 mean', derivative_column='Derivative', method=<function var>, derivative_plot=False)
Function to produce three plots. The first one is the correlation between the lineages from the same mother cell (and same size), the second one present the variance of the column for each cell inside the lineages easy to see if the lineages are differents, and the third graph present the dV/dt, dF/dt, Volume and Fluor1 mean of the lineage, and if the ‘derivative_plot = True’, will plot the lineage oscilations using ‘plot_lineage_derivative()’
Parameters
- df_3dDataFrame
DataFrame of 3D data
- reverse_lineagedict
Dict with the lineage Cell ID’s as key, output from ‘lineages()’
- mother_cellint
Mother cell (first cell of the lineage), to plot the lineage
- columnstr (optional)
The column to extract the feature of the dataset. Default ‘Fluor1 mean’.
- methodfunction (optional)
Method to use to extract feature of each cell, default its np.mean. Other options are np.std and stats.sem.
- derivative_plotbool (optional)
If true beside plot the dV/dt, dF/dt, Volume and Fluor1 mean, will plot the lineage oscilations using ‘plot_lineage_derivative()’
Returns
None
- bacteria.functions.plot_derivative_mean(times, mean, ci, column='Fluor1 sum', derivative_column='Derivative', color='Orange', ax=None)
Plot the derivative mean for the entire experiment. Check also derivative() and column_mean().
Parameters
- timend.array
1D time vector with the uniques time points (fps) output of ‘derivative()’
- meannd.array
1D time vector with the mean derivative for each time point output of ‘derivative()’
- cind.array
array(2,bins) with inferior Confidence Interval in the first column and the upper one in the second output of ‘derivative()’
- columnstr (optional)
The feature used to calculate the derivative, yaxis label
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume.
- color: str (optional)
Color to plot the growth rate.
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_diff_minima(vol_dict, key=None, color=None, color_pre='black', color_pos='red', ax=None)
Function to plot the difference between the minimas. The function will plot the ‘pre’ and ‘pos’ moments automatically if present in the dictionary. Also, plot the histogram of the diff. It’s possible to choose the key to plot (‘all’,’pre’ or ‘pos’), if you pass just the key will plot the cloud and the histogram, if you pass the ‘key’ and the ‘ax’ will return just the cloud plot. If the ‘pre’ os ‘pos’ are less than 2, the function will plot just the all data vector, to plot those moments you should pass the ‘key’.
Parameters
- vol_dictdict
Dict with the values of the diff minima, output of ‘diff_minima()’.
- keystr (optional)
key used to plot just one moment, ‘all’, ‘pre’ or ‘pos’
- colorstr (optional)
color to plot the cloud and the histogram of ‘all’ data
- color_prestr (optional)
color to plot the cloud and the histogram of ‘pre’ data, default ‘black’
- color_posstr (optional)
color to plot the cloud and the histogram of ‘pos’ data, default ‘red’
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_distance_minima(vol_dict, key, color=None, ax=None)
Function to plot the distance between the minimas. The function will plot the volume minima by the volume at birth. It’s necessary to pass the ‘key’ perform the cloud plot (‘pre’,’pos’,’all’).
Parameters
- vol_dictdict
Dict with the values of the diff minima, output of ‘diff_minima()’.
- keystr (optional)
key used to plot just one moment, ‘all’, ‘pre’ or ‘por’
- colorstr (optional)
Cloud color
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_distance_minima_lineage(df_3d, df_2d, lineages_list, column='Fluor1 sum', derivative_column='Derivative', order=5, ax=None)
Function to plot the distance between the minimas for an specifics lineages. Here we are calculating the minima inside the lineage, so it might be better to just use the diff_minima() function. Change the diff_minima() function to return the minimum along with the Cells ID and use that data here. This may be better for the smooth (TODO) tuning issue
Parameters
- df_3dDataFrame
DataFrame of 3D data
- df_2dDataFrame
DataFrame of 2D data
- lineages_listlist
List with the lineages to plot, its better to use the output of ‘lineage_corr_filter()’
- derivative_columnstr (optional)
Derivative column to bin. Columns: ‘Derivative’, ‘Derivative/V’ is the derivative normalized by volume, ‘Log Derivative’ logarithm of the derivative, ‘Log Derivative/V’ logarithm of the derivative normalized by volume. Default is ‘Derivative’.
- orderint (optional)
The order of the polynomial used to fit the savgol_filter from scipy in ‘lineage_derivative()’ higher order is better to find more minimas.
- axnd.array (optional)
Pass the ax for subplot.
Returns
None
- bacteria.functions.plot_fluor_lineage(df_2d, df_3d, limit_inf, limit_sup, conf=0.95, method=<function mean>, ax=None)
Plot the mean fluo for the lineage for the entire experiment. Check also fluor_lineage().
Parameters
- df_2dDataFrame
DataFrame of 2D data
- df_3dDataFrame
DataFrame of 3D data
- limit_infint
Start moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
- limit_sup: int
End moment in time (fps) of the stationary phase to filter the data (use growth_rate() to see it)
- conffloat (optional)
confidence interval desired for bootstrap, default - 0.95
- methodfunction (optional)
Method to use as basis for the boostrap, default its np.mean. Other options are np.std and stats.sem.
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_fluor_lineage_single_cell(df_2d, df_3d, cell_id, ax=None)
Plot the cell’s fluo in the cell cycle from the lineage, mother and 1 or 2 daughter’s. If just plot the mother data it’s because this cell has no daughter’s, one can check this on the dataframe.
Parameters
- df_2dDataFrame
DataFrame of 2D data
- df_3dDataFrame
DataFrame of 3D data
- cell_id: int
Cell to plot the fluo
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.plot_large_lineages(df_2d, lineage_list, return_plot=False)
Plot the large lineage data without prune the data. This plot is made using graphviz, the variable can be used to save the plot in pdf.
Parameters
- df_2dDataFrame
2D data
- lineage_listlist
list with the Cell ID’s to plot
- return_plotbool (optional)
If true return the graphviz variable.
Returns
None
- bacteria.functions.plot_lineage_derivative(df_lineage, peaks, column='Fluor1 sum', derivative_column='Derivative/V', x_axis='Smoothed Volume', ax=None)
Plot a single lineages derivative with the local minima and local maxmia. The input parameters are the output of ‘lineage_derivative()’. This function can receive both volume (‘Smoothed Volume’) and time (‘Time (fps)’) as the X axis.
Parameters
- df_lineageDataFrame
DataFrame output of ‘lineage_derivative()’ with all data necesseary to plot the lineages.
- peaksdict
Dictionary data with the indexes of local minima and local maxima related to ‘Smoothed Volume’,’Smoothed Derivative’ and ‘Time (fps)’. Output of ‘lineage_derivative()’
- x_axisstr (optional)
Column to use as X axis in the plot. Should be ‘Smoothed Volume’ (default) or ‘Time (fps)’.
- axnd.array (optional)
Pass the ax for subplot.
Returns
None
- bacteria.functions.plot_lineage_ratio(df_lineage, x_axis='Smoothed Volume', ax=None)
Plot a single lineages F/V ratio. The input parameters are the output of ‘lineage_derivative()’. This function can receive both volume (‘Smoothed Volume’) and time (‘Time (fps)’) as the X axis.
Parameters
- df_lineageDataFrame
DataFrame output of ‘lineage_derivative()’ with all data necesseary to plot the lineages.
- x_axisstr (optional)
Column to use as X axis in the plot. Should be ‘Smoothed Volume’ (default) or ‘Time (fps)’.
- axnd.array (optional)
Pass the ax for subplot.
Returns
None
- bacteria.functions.plot_lineages_check(df_2d, reverse_lineages, y_axis, colormap='rainbow')
Plot all lineages using the length as x-axis. It’s possible to chose different columns to inspect. The function is already removing the last value of the reverse_lineage, because the last cell has no daughter and is removed by our filters.
Parameters
- df_2dDataFrame
2D data
- reverse_lineagesdict
Dict with all lineages, output from ‘lineages()’
- y_axisstr
Data to plot in the Y axis, use the df_2d terms.
- colormapstr (optional)
Colormap to use. Check the matplotlib documentation. Default = rainbow.
Returns
None
- bacteria.functions.plot_reverse_lineages(df_2d, lineage_list, column='Long axis (L) death', label='Cell Size ', for_ref=2, return_plot=False)
Plot the reverse lineage data with one column value. This plot remove the last value, as by the filter we dont have the data from cells without daughters. This plot is made using graphviz, the variable can be used to save the plot in pdf.
Parameters
- df_2dDataFrame
2D data
- lineage_listlist
list with the Cell ID’s to plot
- columnstr (optional)
column value to plot alongside with the ID’s
- labelstr (optional)
Label to use alongside with the column value, as usual the column name is to big.
- for_refint (optional)
The limit of the for range (in range - for_ref)
- return_plotbool (optional)
If true return the graphviz variable.
Returns
None
- bacteria.functions.plot_total_fluo_volume(df_3d, reverse_lineage, ax=None)
Plot the total fluorescence by the volume.
Parameters
- df_3dDataFrame
3D data
- reverse_lineagelist
List with the lineage Cell ID’s, output from ‘lineages()’
- axnd.array
axis to plot
Returns
None
- bacteria.functions.roll_mean_plot2D(ax, df, y, x='Cell birth time', window=50, fsize=15)
A helper function to make a roll mean plot for 2D data
Parameters
- axAxes
The axes to draw to
- dfpandas DataFrame
df from 2D data
- ystr
The y data
- xstr (optional)
The x data, using ‘Cell birth time’
- windowint (optional)
Window value to roll mean, using 50
- fsize = int (optional)
Plot font size
Returns
- outlist
list of artists added
- bacteria.functions.roll_mean_plot3D(ax, df, y, id, x='Time (fps)', window=1, fsize=15)
A helper function to make a roll mean plot for 3D data
Parameters
- axAxes
The axes to draw to
- dfpandas DataFrame
df from 2D data
- ystr
The y data
- idint
Cell ID for plot (check good cells using ‘good_cells()’)
- xstr (optional)
The x data, using ‘Cell birth time’
- windowint (optional)
Window value to roll mean, using 1
- fsize = int (optional)
Plot font size
Returns
- outlist
list of artists added
- bacteria.functions.scatter_linear_regression(df, x='Area birth', y='Area death', ax=None)
Scatter plot with linear regression.
Parameters
- dfDataFrame
DataFrame of 2D data
- xstr (optional)
X column for the Linear Regression model, usual ‘Area birth’
- y: str (optional)
Y column for the Linear Regression model, usual ‘Area death’
- axnd.array (optional)
the ax position to plot
Returns
None
- bacteria.functions.smooth(data, factor=10)
1-D smooth filter
Parameters
- datand.array
The file location in drive or HDD
- factorint
The factor to convolve and smooth the graph. The greater the value, the greater the noise attenuation. Default 10.
Example
smooth(data,10)
See Also
Developed by Mike X Cohen.