Figure API
Figure level functions
- figureflow.figure.Figure.__init__(name: str) None
Initialize self. See help(type(self)) for accurate signature.
- figureflow.figure.Figure.create_panel()
- figureflow.figure.Figure.show_panels()
- figureflow.figure.Figure.edit_panel()
- figureflow.figure.Figure.edit_this_panel()
- figureflow.figure.Figure.get_representative_data_from_multiple_panels()
- figureflow.figure.Figure.get_representative_data_from_multiple_panels_from_scratch()
- figureflow.figure.Figure.save()
- figureflow.figure.Figure.save_video()
Image panel functions
- figureflow.figure_panel.FigurePanel.show_images(self, images=None, channels=None, slices=None, frames=None, order_of_categories=None, focus=None, show_focus_in=None, interpolate_images='None', dimension_equal='heights', scale_images=True, flip_images=None, auto_image_sub_param=None, make_image_size_equal=None, auto_enlarge=True, enlarged_image_site='left', simple_remapping=False, channels_to_show_first_nonzoomed_timeframe=None, show_only_zoom=True, force_show_non_zoom_channels=False, show_non_zoom_channels=False, position_zoom_nb='top-left', zoom_nb_frames=0, show_single_zoom_numbers=False, show_zoom_number_in_image=True, zoom_nb_rows=None, zoom_nb_columns=None, line_width_zoom_rectangle=0.3, zoom_nb_font_size_overview=None, zoom_nb_color='white', zoom_nb_font_size=None, zoom_nb_padding=0.015, repositioning_map=None, additional_padding=None, show_axis_grid=False, use_same_LUTs=True, cmaps='gray', composite_cmaps=None, black_composite_background=True, replace_nan_with=0, sub_padding_factor=0.25)
Display images of current panel. Always use function that annotate within the image after functions that annotate outside of the image. Ranges seemingly can only be extracted from ImageJ images if the LUT is set to gray.
- Parameters:
images – List of images (integers) which should be displayed each image corresponds to one image file for the panel
channel – List of channels (integers) which should be displayed composite/composite images can be by adding a string with all channel numbers separated by “-“, e.g. channels=[0,1,2,”0-1-2”]. dimension is extracted from ImageJ Hyperstack information
slices – List of slices (integers) which should be displayed dimension is extracted from ImageJ Hyperstack information
frames – List of frames (integers) which should be displayed dimension is extracted from ImageJ Hyperstack information
order_of_categories – List of strings with order of the image dimensions (“images”, “channels”, “slices”, “frames”), determines how images will be put into a grid. Images of different dimensions values for a dimension earlier in the list will be closer together (e.g. for [“frames”, “channels”] first all frames from one channel will be shown then all frames from the other channel)
focus – String of dimensions (“images”, “channels”, “slices”, “frames”) that will be alone on one axis of the image grid (e.g. for “frames” all different frames will be along one axis (e.g. columns) while the different images and channels will be along the other axis (e.g. rows).
show_focus_in – “row” or “column” - allows to fix in which dimension the focus will be shown
interpolate_images – Type of interpolation for the matplotlib function ax.imshow
dimension_equal – Determines in which dimension (“height” or “width”) images should be similar e.g. for “height”, images in same row will be adjusted to have the same height for “width images in same column will be adjusted to have the same width
scale_images – Boolean. Whether images should be scaled to fit into an even grid. dimension_equal will only be considered if scale_images == True scaling is necessary to show zoomed regions actually enlarged however, it might be a problem if it is important for the data to be equally scaled in the entire panel
flip_images – On which axis the images should be flipped (allowed avalues: “x” or “y”). If None, images will not be flipped.
auto_image_sub_param – String. Substring in panel file names that defines how images should be grouped into image_sub automatically (without defining images manually as a nested list) image file names must have this substring together with an identifier for the specific image sub group separated by “_” on each site from the rest of the file name auto_image_sub_param must only be ONCE in each file name! e.g. if you want to group various images for a panel by the cell from which they originate and each image file name somewhere contains “_cellXXXX_” where each X is some digit then auto_image_sub_param should be “cell” to catch the right group
make_image_size_equal – List. Allows for adding px to images in one dimension (“height” or “width”) to make the size of images in that dimension equal. list must have at least two values. The first value must be “height” or “width” the second value defines at which site pxs are added “right” or “left” for “width” OR “bottom” or “top” for “height” The third value in the list is optional and defines which values will be added The default value to be added is 0
auto_enlarge – Boolean; Whether images should be enlarged automatically to fill up grid into rectangle “focus”, “show_focus_in”, the first element in “order_of_categories” and “enlarged_image_site” can determine how the enlarged images will be shown (where they will be displayed and how much they will consequently be enlarged to fill up the image grid)
enlarged_image_site – Site at which the enlarged image should be shown (“left”, “right”, “top” or “bottom” possible)
simple_remapping – Whether only the image with the identity should be increased in size
channels_to_show_first_nonzoomed_timeframe – If a zoom is defined, should the first frame of each channel be always shown (as overview)
show_only_zoom – Potentially apart from overview image, dont show any non zoom pictures
force_show_non_zoom_channels – Force to show channels that were not zoomed independent of other settings
show_non_zoom_channels – show channels that were not zoomed independent of other settings
show_zoom_mark_on_all_channels – Whether rectangle with number of zoom should be shown on top of all channels otherwise they will only be shown on overview
position_zoom_nb – position at which the zoom number shouldbe shown in the zoomed image
show_single_zoom_numbers – Show zoom number in image and at zoom rectangle in overview image, even if there is just one zoomed area
show_zoom_number_in_image – Add zoom number to edge of zoomed image
zoom_nb_rows – List of rows in image grid in which zoom numbers will be added
zoom_nb_columns – List of columns in image grid in which zoom numbers will be added
line_width_zoom_rectangle – Line width in pt of zoom rectangle added to overview iamge
zoom_nb_font_size_overview – font size of zoom number in overview image
zoom_nb_color – Color of zoom number text on images
zoom_nb_padding – Padding of zoom number text to edges of image
zoom_nb_font_size – font size of zoom number in zoom image
zoom_nb_frames – List with ints or int, Index of frames where zoom nb should be shown in zoom For each int will use the Xth frame (e.g. if frame 5,10,20 will be shown and zoom_nb_frames is [0,1] then the zoom_nb will be shown in the first and second frame (5, 10)
repositioning_map – join specific images together with another dimension (by remapping the identity) e.g. join one image from a channel with the images of another channel supply a dict where the key is a tuple corresponding to the images that should be remapped (e.g. (“channel”,1,”zoom”,0)) the value should be a tuple that identifies the group that the images should be joined to uniquely the value tuple should correspond to images that only differ in one category (e.g. frame) the images will be joined in this category differing (like being added as additional frame points in this example) if “image” is not part of the value tuple then the images will be remapped on the same image
additional_padding – Multiply padding by factor to separate elements within one category dict where key is the category and value is the factor
show_axis_grid – Show axis grid on top of image (major ticks for x and y axis)
use_same_LUTs – Should the ranges from the first image in each chanel be applied to all images
replace_nan_with – float, Replace nan in images with value
cmaps – string or list of strings corresponding to matplotlib colormaps; each entry in list corresponds to one channel in same order
composite_cmaps –
list of strings corresponding to matplotlib colors for composite channel (only if composite is defined in ‘channels’). Order of cmaps corresponds to order of channels in ImageJ, changes in order in the ‘channels’ parameter do not change the order of composite_cmaps.
Will create cmap for each channel from black/white (depending on ‘black_composite_background’ parameter to color.)
black_composite_background – Whether the background (image below image range) of the composite should be black, if False, background is white
replace_nan_with – With what values to replace nan values with
sub_padding_factor – Multiple of figure_panel padding that is used for padding in image grid
- figureflow.figure_panel.FigurePanel.add_border(self, left=False, right=False, top=False, bottom=False, row=None, column=None, color='black', line_width=2)
Add border to images.
- Parameters:
left – Whether to add left border
right – Whether to add right border
top – Whether to add top border
bottom – Whether to add bottom border
row – row (integer) in which borders should be added
column – column (integer) in which borders should be added
color – Color of added border
line_width – Line width in pt of added border
- figureflow.figure_panel.FigurePanel.add_zoom(self, xy, width, height, images=None, channels=None, frames=None, label_position_overview='left')
Append zoom parameters to dictionary. For each image/channel/frame the same number of zooms have to be added. Otherwise auto_enlarging won’t work.
- Parameters:
xy – x,y point as list for bottom-left origin of zoom rectangle
width – width of zoom rectangle
height – height of zoom rectangle
images –
- dict with each key corresponding to one category
(“images”, “channels” and “frames” allowed) and the value being a list with all allowed values
Alternative use, will be deprecated: list, which images the zoom should be applied on. If None, it will be applied to all images
channels – Will be deprecated list, which channels the zoom should be applied to. If None, it will be applied to all channels
frames – Will be deprecated list, which frames the zoom should be applied to. If None, it will be applied to all channels
label_position_overview – at which position should the number label be added to the overview image
- figureflow.figure_panel.FigurePanel.add_cropping(self, left=0, right=0, top=0, bottom=0, coords='rel', row=None, column=None, images=None)
Add cropping to an image or a set of images.
- Parameters:
left – crop from left site, either rel width of image or actual number of pixels
right – crop from right site, either rel width of image or actual number of pixels
top – crop from top, either rel width of image or actual number of pixels
bottom – crop rom bottom, either rel width of image or actual number of pixels
coords – either “rel” for relative image coords, or px for px counts
row – images in which row should be cropped, if not defined or None, in all rows
column – images in which column should be cropped, if not defined or None, in all rows
images – Apply cropping to only a subset of images, specific number of images (numbers will be given incrementally to images in alphanumerical order),
- figureflow.figure_panel.FigurePanel.add_colorbars(self, site='right', channels=None, tick_labels=None, size=0.1, tick_distance_from_edge=0.2, font_size_factor=0.6, padding=0.2, tick_length=1, label_padding=0, only_show_in_rows=None, only_show_in_columns=None)
Add colorbars to imagegrid, based on their colormaps. For each colormap in the image grid only one colorbar will be shown.
- Parameters:
site – None or str, one of [“bottom”, “top”, “left”, “right”] colorbar will be shown at the respective site of the panel If it is bottom or top, it will be shown in every column If it is left or right it will be shown in every row For now, it assumes that in the respective dimension (row or column) the image ranges are different and therefore should be displayed in every row/column site of image grid ad which colorbar/s will be shown it will never be shown within the image grid
channels – list of ints; channels for which colorbars will be shown if multiple channels have the same colormap only one of the channels has to be in the list for it to be displayed. default is that colorbars are shown for all channels
tick_labels – list of two strings, labels to put on left (first value) and right end (second value) of colorbar, instead of floats
size – float, size of colorbar in fraction of axes it is added to
tick_distance_from_edge – int, 0 to 0.4; relative distance from edge to indicate value on colorbar (relative value is indicated) Move two ticks of colorbar from outer edges away thereby preventing the numbers to overlap with neighboring images
font_size_factor – factor by which the font size is incrased, factor of 1 means that self.font_size is used
padding – padding, float; in relative units of size of colorbar
tick_length – float; length of ticks for tick values at colorbar in points
label_padding – float; padding of tick values from ticks in points
only_show_in_rows – list of ints; in which rows of the image grid should the colorbar be shown
only_show_in_columns – list of ints; in which columns of the iamge grid should the colorbar be shown
- figureflow.figure_panel.FigurePanel.add_rows_to_delete(self, rows, images=None, only_in_grid_rows=None, only_in_grid_cols=None)
Create dictionary with one dictionary entry per rows that should be deleted.
- Parameters:
rows – list of rows (integers) that should be deleted
images – list of images (integeres) in which rows should be deleted
only_in_grid_rows – List of rows in image grid in which rows should be deleted in the image array
only_in_grid_cols – List of columns in image grid in which rows should be deleted in the image array
- figureflow.figure_panel.FigurePanel.add_scale_bar(self, um_per_px, position=None, only_in_first_image_of_each=None, row=None, column=None, lengths_um=10, color='white', padding=0.015, line_width=3, always_draw_scale_bar=False)
Add scale bar to image/s.
- Parameters:
um_per_px – how large is one px in um
position – define where the scale bar should be added set as “first_dimension-second dimension” - e.g. “bottom-left” or “top-right”
only_in_first_image_of_each – Defines in which dimension only the first image should show scale bar, if None, all images will show scale bar
row – row position that the image needs to be in grid to draw scale bar if None, any position in that dimension is allowed can be used to apply different um_per_px settings to different images
column – column position that the image needs to be in grid to draw scale bar if None, any position in that dimension is allowed can be used to apply different um_per_px settings to different images
lengths_um – list of lengths of scale bar in um, if more than one and more than one scales of images (e.g. with zoom) are there smaller scale bars will be mapped on zooms and larger on non-zooms ideally provide as many
color – color of scale bar
padding – distance of scale bar from border of image in inches can be single value (then used for both dimension) or can be list of two values, then the first will be for the x and the second for the y axis
line_width – line thickness in points
always_draw_scale_bar – Whether to draw scale bars in every image even though they are the same scale. Only recommended in very special cases. Normally several scale bars for images with the same scale look like the scales are slightly different.
- figureflow.figure_panel.FigurePanel.add_text_within_at_coords(self, text, x, y, font_size=7, line_spacing=1, hor_align='left', vert_align='bottom', orientation='hor', images=None, only_show_in_rows=None, only_show_in_columns=None, correct_for_cropping=True, color='white')
Add text on image at coordinates.
- Parameters:
text – String of text to add. Linebreaks can be added with n
x – x coordinate at which to add the text
y – y coordinate at which to add the text
line_spacing – Line spacing when including a line break
font_size – font size either in pt or as “small”, “medium” or “large”
hor_align – horizontal alignment of text (“left, “center” and “right” allowed
vert_align – Vertical alignment of text (“bottom”, “center” and “top” allowed)
orientation – Orientation of text (“hor” or “vert” or degrees)
images – dict that specifies on which images should be drawn the key is the category and the value is the allowed value
only_show_in_rows – List of rows in which to add the text on images
only_show_in_columns – List of columns in which to add the text on images
correct_for_cropping – Correct coordinates for applied cropping
color – Font color
- figureflow.figure_panel.FigurePanel.add_timestamp(self, time_per_frame, start_time=0, format='mm:ss', color='white', show_only_in_zoom=False, show_unit=False, first_time_difference=1, frame_jumps=None, only_show_in_rows=None, only_show_in_columns=None, show_unit_only_once=True, long_unit_names=False, all_units_shown=False, position=None, font_size=None, padding=0.015)
Add timestamp text to each image in panel. timestamps MUST be added after other annotations were added to the figure. Otherwise the timestamp might be cut off.
- Parameters:
time_per_frame – how much frame is between frames, add as string with unit (s, sec, m, min or h) after number
start_time – what frame-frame does number 1 equal (start at negative value positive to indicate it was before e.g. a treatment)
time_per_frame – string of number and unit (“m” for min, “h” for hour, or “s” for second) for time difference between frames
format – format of how time should be displayed. The number of letter indicates the number of digits in that category. Possible categories are “s” for seconds, “m” for minutes or “h” for hours.
show_unit – Whether to show unit name in the label of the time
first_time_difference – Difference of timesteps from first to second frame (helpful if after a first frame there was an imaging break, longer than the normal time between frames)
frame_jumps – Dictionary with keys being timepoint before which timejumps happened and values being number of frames that the jump was long (e.g. {4: 2, 10:20} for a timejump of 2 timeframes before timeframe 5 and a timejump of 20 timeframes before timeframe 11)
long_unit_names – Whether to use long unit names (“min” instead of “m”, “hour” instead of “h” and “sec” instead of “s”).
all_units_shown – Whether to show the unit name of the first unit in the format (e.g. “h” for “hh:mm) (if False) or both unit names separated by “:” (if True)
position – define where the timestamp should be added set as “first_dimension-second dimension” - e.g. “bottom-left” or “top-right”
font_size – font size of timestamp label
padding – padding of timestamp from edges of image in inches
- figureflow.figure_panel.FigurePanel.set_image_scaling(self, x_scale=1, y_scale=1)
Set scaling for how values on image axes should be scaled for displaying the values on the axes ticks (does not change the size of images but only the axes tick values)
- Parameters:
x_scale – Relative scale of x values
y_scale – Relative scale of y values
- figureflow.figure_panel.FigurePanel.add_x_axis(self, axis_title='', site='bottom', show_in_rows=None, show_in_columns=None, show_title_in_rows=None, show_title_in_columns=None, axis_padding=0, show_tick_labels=True, always_show_all_tick_values=False, tick_values=None, tick_color='black', tick_width=0.4, tick_length=5, shift=True, direction='in')
Add x axis to images in image grid.
- Parameters:
axis_title – String of axis title
site – Site of axis
show_in_rows – List of rows in image grid in which to add x axis
show_in_columns – List of columns in image grid in which to add x axis
show_title_in_rows – List of rows in image grid in which to show title
show_title_in_columns – List of columns in image grid in which to show title
axis_padding – padding of axis ticks
show_tick_labels – Whether to show tick labels
always_show_all_tick_values – Show all tick values, even those outside of the range of the image
tick_values – list, manually define x tick values to be shown on the inside of the image values provided must be after scaling with set_image_scaling
tick_color – string, color of x ticks
tick_width – tick width in pt
tick_length – tick length in pt
shift – whether to shift images after adding axis
direction – direction of ticks (“in” or “out” of image)
- figureflow.figure_panel.FigurePanel.add_y_axis(self, axis_title='', site='left', show_in_rows=None, show_in_columns=None, show_title_in_rows=None, show_title_in_columns=None, axis_padding=0, show_tick_labels=True, always_show_all_tick_values=False, tick_values=None, tick_color='black', tick_width=0.4, tick_length=5, shift=True, direction='in')
Add y axis to images in image grid.
- Parameters:
axis_title – String of axis title
site – Site of axis
show_in_rows – List of rows in image grid in which to add y axis
show_in_columns – List of columns in image grid in which to add y axis
show_title_in_rows – List of rows in image grid in which to show title
show_title_in_columns – List of columns in image grid in which to show title
axis_padding – padding of axis ticks
show_tick_labels – Whether to show tick labels
always_show_all_tick_values – Show all tick values, even those outside of the range of the image
tick_values – list, manually define y tick values to be shown on the inside of the image values provided must be after scaling with set_image_scaling
tick_color – string, color of y ticks
tick_width – tick width in pt
tick_length – tick length in pt
shift – whether to shift images after adding axis
direction – direction of ticks (“in” or “out” of image)
- figureflow.figure_panel.FigurePanel.annotate_channel_within_image(self, channel_names, channel_colors=None, position=None, color='white', images=None, only_show_in_rows=None, only_show_in_columns=None, font_size=None, string_separating_channels=' / ', padding=0.015)
Extract channel number from file name (__cx..x-x…x-x…x). Annotate corresponding channel_names with corresponding color in image. Each file cannhave multiple channels specified (for overlap images with more than one channel in different colors).
- Parameters:
channel_names – Names of channels that will be annotated in image. The index in the list corresponds to the channel number in the image filename
channel_colors – Colors in which names of channels will be annotated in image. The index in the list corresponds to the channel number in the image filename if None, defaults for colors to cmaps used to display channel/s
position – define where the timestamp should be added set as “first_dimension-second dimension” - e.g. “bottom-left” or “top-right”
color – Color of label
images –
- list of dict or dict
dict specifies on which images should be drawn
the key is the category and the value is a list of allowed values
only_show_in_rows – list of rows in which the labels should be displayed, if None display in all rows
only_show_in_columns – list of columns in which the labels should be displayed, if None display in all columns
string_separating_channels – For composites with multiple channels add this string between channels maximum one space in a row is allowed
padding – Padding in inches of label from image edges
- figureflow.figure_panel.FigurePanel.draw_line_on_images(self, position, orientation='hor', line_width=1, color='white', line_style='-', only_show_in_rows=None, only_show_in_columns=None, **kwargs)
Draw a line on images.
- Parameters:
position – positions (x or y) of adding line
orientation – either “hor” / “horizontal” or “vert” / “vertical”
line_width – line width in pt
color – color of line
line_style – linestyle as typical matplotlib linestyle (e.g. “-” or “–” or “-.-“)
only_show_in_rows – list of rows in which line should be added
only_show_in_columns – list of columns in which line should be added
- figureflow.figure_panel.FigurePanel.draw_marker(self, frames=None, channels=None, images=None, radius=0.15, color='white', show_only_in_zoom=False, only_show_in_columns=None, only_show_in_rows=None, position=None)
Add marker (circle) to specific upper left edge in images.
- Parameters:
frames – Will be deprecated list, which frames the zoom should be applied to. If None, it will be applied to all channels
channels – Will be deprecated list, which channels the zoom should be applied to. If None, it will be applied to all channels
images –
- dict with each key corresponding to one category
(“images”, “channels” and “frames” allowed) and the value being a list with all allowed values
Alternative use, will be deprecated: list, which images the zoom should be applied on. If None, it will be applied to all images
radius – radius in inches
color – color of circle
show_only_in_zoom – Whether show marker only in zoomed images
only_show_in_columns – List of columns of image grid in which to add the marker
only_show_in_rows – List of rows of image grid in which to add the marker
position – Not implemented
- figureflow.figure_panel.FigurePanel.draw_on_image(self, targets, direction, images=None, style='arrow', color='white', size=40, direction_from_head_to_tail=True, fill_circle=False, arrow_width_factor=0.125, arrow_head_width_factor=0.625, arrow_head_length_factor=0.625, **kwargs)
Draw on each of the images specified.
- Parameters:
targets – target position in form [x,y] or list of positions, will determine where the shape ends
direction – direction of object from the target, can be supplied in three different forms: position in form [x,y], will determine direction, starting from target degrees as int, while 12o’clock is 0 degree string like “top” or “top-left” or “bottom-right” by default direction starts at head and goes towards tail (see param direction_from_head_to_tail)
images – dict that specifies on which images should be drawn the key is the category and the value is the allowed value
style – can be “arrow” or “*”
color – color of drawn shape
size – size of marker in pt, also scaled for current figure size to have a good standard value
direction_from_head_to_tail – Bool; Whether direction supplied as string should be considered starting from the head going towards the tail (True) or the other way around (False)
arrow_width_factor – width of arrow_tail in axes coords if style == arrow
arrow_head_width_factor – width of arrow head in axes coords if style == arrow
arrow_head_length_factor – length of arrow head in axes coords if style == arrow
- figureflow.figure_panel.FigurePanel.label(self, text, position=None, span=None, site='left', font_size=None, padding=2, label_orientation=None, **kwargs)
Label specific positions in image grid directly.
- Parameters:
text – Text to use as label
position – Position (integer) in image grid to label
span – Number of images that should be spanned by label
site – site at which the label should be added (“top”,”bottom”, “left” or “right”)
font_size – font size of label added
padding – Padding from images in pt of label
label_orientation – Orientation of labels (“hor” or “vert”) default is horizontal for “top” and “bottom” site and vertical for “left” and “right” site
- figureflow.figure_panel.FigurePanel.label_category(self, category, texts, site=None, font_size=None, padding=2, font_size_factor=None, label_orientation=None, **kwargs)
Label a category (images, channels, frames or slices; also _subs).
- Parameters:
category – String of category that should be labeled (“images”, “channels”, “frames” or “slices”)
texts – Text that should be used as labels; should match the number of different values in the defined category Same labels that are adjacent are only labeled once across all affected images
site – String of site at image grid at which labels should be adde (“top”, “bottom”, “left” or “right”). Depending on the dimension (columns or rows) in which the category is, top/bottom (for columns) might is better for left/right (for rows).
font_size – font_size of labels; if None default for figure_panel will be used
padding – Padding in pt of labels from images
font_size_factor – Factor by which the default font_size should be scaled to obtain font size for labels
label_orientation – “hor” or “vert” default is horizontal for “top” and “bottom” site and vertical for “left” and “right” site
- figureflow.figure_panel.FigurePanel.label_channels(self, texts, site=None, label_composites=False, default_composite_label=None, font_size=None, padding=2, font_size_factor=None, label_orientation=None, **kwargs)
Label a category (images, channels, frames or slices; also _subs).
- Parameters:
texts – Text that should be used as labels; should match the number of different values in the defined category Same labels that are adjacent are only labeled once across all affected images
site – String of site at image grid at which labels should be adde (“top”, “bottom”, “left” or “right”). Depending on the dimension (columns or rows) in which the category is, top/bottom (for columns) might is better for left/right (for rows).
label_composites – Whether to label composite channels
font_size – font_size of labels; if None default for figure_panel will be used
default_composite_label – Default composite label to use, otherwise composites will be labeled as a combination of the channel names which are composited together
padding – Padding in pt of labels from images
font_size_factor – Factor by which the default font_size should be scaled to obtain font size for labels
label_orientation – “hor” or “vert” default is horizontal for “top” and “bottom” site and vertical for “left” and “right” site
- figureflow.figure_panel.FigurePanel.label_frames(self, texts=None, site=None, label_sub_remapped=False, font_size=None, padding=2, font_size_factor=None, label_orientation=None, start_time=0, time_per_frame='1m', format='hh:mm', show_unit=True, first_time_difference=1, frame_jumps=None, long_unit_names=True, all_units_shown=False, **kwargs)
Label a category (images, channels, frames or slices; also _subs).
- Parameters:
texts – Text that should be used as labels; should match the number of different values in the defined category Same labels that are adjacent are only labeled once across all affected images
site – String of site at image grid at which labels should be adde (“top”, “bottom”, “left” or “right”). Depending on the dimension (columns or rows) in which the category is, top/bottom (for columns) might is better for left/right (for rows).
label_sub_remapped – Whether the new image numbers after remapped accoding to defined _sub categories should be used (if True) or whether original image numbers should be used (if False)
font_size – font_size of labels; if None default for figure_panel will be used
padding – Padding in pt of labels from images
font_size_factor – Factor by which the default font_size should be scaled to obtain font size for labels
label_orientation – “hor” or “vert” default is horizontal for “top” and “bottom” site and vertical for “left” and “right” site
start_time – number of first timeframe
time_per_frame – string of number and unit (“m” for min, “h” for hour, or “s” for second) for time difference between frames
format – format of how time should be displayed. The number of letter indicates the number of digits in that category. Possible categories are “s” for seconds, “m” for minutes or “h” for hours.
show_unit – Whether to show unit name in the label of the time
first_time_difference – Difference of timesteps from first to second frame (helpful if after a first frame there was an imaging break, longer than the normal time between frames)
frame_jumps – Dictionary with keys being timepoint before which timejumps happened and values being number of frames that the jump was long (e.g. {4: 2, 10:20} for a timejump of 2 timeframes before timeframe 5 and a timejump of 20 timeframes before timeframe 11)
long_unit_names – Whether to use long unit names (“min” instead of “m”, “hour” instead of “h” and “sec” instead of “s”).
all_units_shown – Whether to show the unit name of the first unit in the format (e.g. “h” for “hh:mm) (if False) or both unit names separated by “:” (if True)
- figureflow.figure_panel.FigurePanel.label_images(self, texts=None, text_prefix=None, site=None, label_sub_remapped=False, font_size=None, padding=2, font_size_factor=None, label_orientation=None, **kwargs)
Label images in panel. If no texts are supplied, images will be labeled with incrementing numbers.
- Parameters:
texts – Text that should be used as labels; should match the number of different values in the defined category Same labels that are adjacent are only labeled once across all affected images
text_prefix – If texts is None, what text should be added in front of incrementing numbers
site – String of site at image grid at which labels should be adde (“top”, “bottom”, “left” or “right”). Depending on the dimension (columns or rows) in which the category is, top/bottom (for columns) might is better for left/right (for rows).
label_sub_remapped – Whether the new image numbers after remapped accoding to defined _sub categories should be used (if True) or whether original image numbers should be used (if False)
font_size – font_size of labels; if None default for figure_panel will be used
padding – Padding in pt of labels from images
font_size_factor – Factor by which the default font_size should be scaled to obtain font size for labels
label_orientation – “hor” or “vert” default is horizontal for “top” and “bottom” site and vertical for “left” and “right” site
- figureflow.figure_panel.FigurePanel.rescale_font_size(self, font_size_factor=None, font_size=None, linespacing=0.92, add_new_text=True)
Only possible for single images with single pptx files for now! Only the first slide of the pptx file will be considered. Text boxes in powerpoint MUST BE 99% opacity for this script to work properly… before saving it as an image! It therefore also just works with pngs saved from powerpoint (not with e.g. jpeg) Font sizes of at least 30 will be scaled according to font_size_factor. For all other text self.font_size will be used and optionally multiplied with font_size_factor Font color is not extracted at the moment. Instead, black text is used on top of a lighter background and white text on top of a darker background.
- Parameters:
font_size_factor – font_size factor by which to scale text that has a font size >= 30 pt in powerpoint
font_size – font_size to use, if None, use default of figure_panel
linespacing – spacing of lines when text includes line breaks
add_new_text – Whether new text should be added after powerpoint text was removed. This is useful when editing the text first using the edit_panel function to change text position. New text can then be added through the printed add_text functions. Thus adding the powerpoint text through rescale_font_size directly is not needed and would lead to duplicated text. Alternatively to doing this, text can also be directly deleted in the powerpoint file (then rescale_font_size is not needed at all anymore) (but deleting it in the pptx file is irreversible of course).
- figureflow.figure_panel.FigurePanel.add_text_on_image(self, texts, images=None, show_in_rows=None, show_in_columns=None, position_in_abs_data_coords=True, remove_rescaled_text=False)
Add text on image, also delete all text that was added by function “rescale_font_size”. Therefore should be specifically used for adding text on illustrations. Figure editor GUI will output code that uses this function.
- Parameters:
texts – list of dicts describing text. Each key of dict is one parameter to axis.text function and each value the corresponding parameter value (x, y and s have to be defined. Other parameters like font_size are optional. See matplotlib docs: “https://matplotlib.org/stable/api/_as_gen/ matplotlib.axes.Axes.text.html”) Changing the font size is not recommended, so that font size is uniform across the entire figure.
images –
- list of dict or dict
dict specifies on which images should be drawn
the key is the category and the value is a list of allowed values
show_in_rows – list of ints, In which row to show all texts
show_in_columns – list of ints, In which row to show all texts
position_in_abs_data_coords – Whether the position of the text is in data coordinates, which means that they will be at the same x,y coordinate position, for each zoom and the overview image - this can be at completely different positions in the axes and may not be in the axes at all (and will therefore not be shown); if False position is as axes fraction and will not be corrected for zoom
Dataplot panel functions
- figureflow.figure_panel.FigurePanel.show_data(self, x=None, y=None, x_labels=[], hue=None, hue_labels=[], col=None, col_labels=[], row=None, ratio=None, row_labels=[], x_order=None, col_order=None, hue_order=None, row_order=None, ratio_pairs=None, ratio_func=None, y_operation_cols=None, y_operation_func=None, order_vals_before_changing_vals=False, inclusion_criteria=None, show_legend=None, round_columns=None, round_digits=0, pair_unit_columns=None, remove_outliers=False, nb_stds_outliers=4, scale_columns=None, norm_y_cats=None, normalize_y_by='mean', normalize_y=False, norm_x_cats=None, normalize_x_by='mean', normalize_x=False, smoothing_rad=None, average_columns=None, baseline=0, columns_same_in_groups=None, renaming_dicts=None, nan_fill_val=-1, width_y_axis=0, col_labels_every_row=False, sub_padding_y_factor=0.25, show_y_label_in_all_rows=None, normalize_after_data_exclusion=True, video_frame=None, use_same_y_ranges=True, increase_padding_above=True, digits_round_all_columns=6, for_measuring=False, **kwargs)
Plot data of file for panel. All column names (e.g. x, x_order, x_labels, hue, etc. ) must be strings, independent of which type they are in the dataframe. Statistics will be performed automatically and annotated by statannot. For parameters that can be set additionally, see statannot package “add_stat_annotation” function.
- Parameters:
x – Column name of data to be used for x axis
y – Column name or list of column names of data to be used for y axis. Multiple y values will be plotted as several rows.
x_labels – list of tuples to change values in x column, first value in tuple is original name and second value is what the name should be replaced by (e.g. [(“2”, “No axon”), (“3”, “With axon”)] to replace “2” and “3” with the respective text). Alternatively each tuple can contain a standard text in which the placeholder __$$__ will be replaced by the column value. (e.g. [[“Rate value = __$$__”]] would mean that each column value is replaced by the defined string with __$$__ replaced by the column value.
hue – column name of data to be used for hue
hue_labels – list of tuples to change values in hue column. See description of x_labels for details.
col – column name of data used for plots in different columns (generating a row of plots)
col_labels – list of tuples to change values in col column. See description of x_labels for details.
row – column of data used for plots in different rows (generating a columns of plots)
ratio – Column for which to calculate ratio of rows with defined ratio_pair values. If a function other than a simple ratio should be calculated, use the ratio_func argument.
row_labels – list of tuples to change values in row column. See description of x_labels for details.
x_order – list of x values after applying the changes of x_labels, if order_vals_before_changing_vals is False. If order_vals_before_changing_vals is True, x values should be the original values before applying the changes of x_labels. Determines the order of x values. Each value has to contain a unique part only present in one column value and not part of multiple different column values and does not need to contain the entire column value. Alternatively, can be a function that takes all unique values of the column and returns an iterable of strings of the unique values that defines the order. Can also be the string “ascending” or “descending” to sort values ascendingly or descendingly, respectively.
col_order – list of col values after applying the changes of col_labels, if order_vals_before_changing_vals is False. If order_vals_before_changing_vals is True, col values should be the original values before applying the changes of col_labels. Determines the order of col values. Can also be a nested list in which case, the columns will be split in one row per nested list (e.g. [[1,2,3],[2,3,4],[5,6,7]], will be split into three rows, the first with the col values 1, 2 and 3. In that case, the values in the order must be the values before changes through col_labels are applied. Each row must have the same number of columns to allow the same size for each plot, otherwise plots in the row with fewer elements will be wider. For more details see “x_order”.
hue_order – list of hue values after applying the changes of hue_labels, if order_vals_before_changing_vals is False. If order_vals_before_changing_vals is True, hue values should be the original values before applying the changes of hue_labels. Determines the order of hue values. For more details see “x_order”.
row_order – list of row values after applying the changes of row_labels, if order_vals_before_changing_vals is False. If order_vals_before_changing_vals is True, row values should be the original values before applying the changes of row_labels. Determines the order of row values. For more details see “x_order”.
ratio_pairs – List with pairs of values in the ratio column that should be used to calculate the ratio (or, if defined, used as input to the ratio_func. The first value in each pair is the first input to the ratio_func or the numerator in the ratio, while the second value in each pair is the second input to the ratio_func or the denominator in the ratio.
ratio_func – Function that receives two inputs, the first and second are the data (pandas.Series objects) from the first and second value of each ratio pair in the ratio column, respectively. Allows calculating arbitrary computations of data.
y_operation_cols – Columns which should be supplied to y_operation_func to calculate a new y value. The original set y value will not be used, instead the newly calculated values will be used for y.
y_operation_func – Function to which the y_operation_cols will be supplied. It should have as many arguments as there are columns in y_operation_cols defined. The original set y value will not be used, instead the newly calculated values will be used for y.
order_vals_before_changing_vals – Whether the _order parameters (e.g. x_order, hue_order, etc) include values before changing values with the _labels parameters or not. Default to allow compatibility with previous scripts is False (use values after replacing with _labels). This will be done automatically for col_order though when using nested lists for col_order to plot cols in different rows.
inclusion_criteria – list of Dictionaries with columns as key and list of values or one value that the column should match, since value all matches from each dictionary will be concatanated. If no matches are found (ValueError ‘The inclusion criteria […] did not match with any data’) but you expected matches and the matched values are numbers, try to use float numbers instead of int (e.g. 9.0 instead of 9, or 200529.0 instead of 200529). Columns might be converted from int to float if NaN values (e.g. empty cells) are found. This type conversion can also happen if some rows in excel are not complete deleted (some column values are left) or a single cell accidentally was added below the rows - this would be visible as rows added in the csv file which are mostly empty. BE CAREFUL NOT TO INTRODUCE DUPLICATES LIKE THIS!
show_legend – Whether to show legend of plot for different values in hue column (will not be shown if there is only one hue value)
round_columns – List of columns for which values should be rounded. Can also choose column for ‘x’/’hue’/’y’/’col’/’row’ parameter directly, by flanking the respective name of the parameter with a double underscore - e.g. __x__.
round_digits – How many digits to round round_columns to. Will only be used if no digits were specified for each round_columns.
pair_unit_columns – list of columns that uniquely identify one set of dependent datapoints (needed to connect paired datapoints and also needed as preprocessing to allow statistics tests for paired data)
remove_outliers – Whether outliers should be removed from data
nb_stds_outliers – Number of stds that outliers need to differ at least from the mean to be excluded (if remove_outliers = True)
scale_columns – Dictionary for scaling values, with key as column name and value the factor by which values are scaled (e.g. for changing the unit of the y column)
norm_y_cats – list of categories / data columns from which the groups will be build (groupby object) within which it should be normalized (e.g. to normalize values within neurites) can be “hue” or “col” or “x” and will then take the column names that were used for these variables as arguments to the “show_data” function can also be any other column name directly
normalize_y_by – value form the group by which the group will be normalized; any function name that can be performed on a series works
norm_x_cats – See norm_y_cats, but will be applied to x column
normalize_x_by – See normalize_y_by, but will be applied to x column
smoothing_rad – Radius for smoothing y values
average_columns – List of column names; create new data frame where data will be averages for data rows with same values in average_columns can be used e.g. to average all values of the same neuron
normalize – Whether to normalize y values
baseline – value that will be subtracted from all y-values before normalization, smoothing etc. helpful e.g. for background subtraction of data from images
columns_same_in_groups – list of column names; exclude data with column values not present in all groups - allows to define for different plot groups (by hue, col and x) to only include rows with values in the defined columns that are present in all groups
renaming_dicts – list of dicts, IMPORTANT: renaming is done after replacing strings through _labels (e.g. x_labels, hue_labels) parameters each dict is for one renaming one key in the dict has to be “__from__” and the value determines what should be changed one key in the dict has to be “__to__” and the value determines the value it should be changed to one key in the dict has to be “__target_column__” and the value determines in which column the change should occur the other keys are column names and the corresponding values determine the value the column must have for checking for matches, values must be lists otherwise, it is assumed that it is a query and will be executed as pandas dataframe query string
nan_fill_val – Value that should be used to fill up NaN values in DataFrame. A numeric value is recommended to prevent type conversion problems for columns that are numeric. NaN values in the y column/s will not be replaced.
col_labels_every_row – Bool; whether column labels above should be shown in every row of the facet plot only matters if row is not None
sub_padding_y_factor – multiple of figure_panel padding for plots from multiple y values
show_y_label_in_all_rows – Whether to show y axis label in all rows (even though they all show the same y axis)
normalize_after_data_exclusion – Boolean; whether data should be normalized after data exclusion normalization should usually be done before exclusion of data otherwise excluded units would change normalization depending on what is shown
video_frame – Int; for animating data in a video; indicates the current frame of the video and thereby the current maximum x value that should be plotted
use_same_y_ranges – Use the same y ranges for all plots. Will use the range from the lowest y value in all groups to the highest y value in all groups
increase_padding_above – Whether to increase padding above plots can sometimes be useful to improve layout
digits_round_all_columns – Number of digits all columns for excluding data should be rounded to. Prevents floating point imprecisions that lead to mismatching during excluding data.
for_measuring – INTERNAL PARAMETER, used when plots are plotted to measure dimensions for perfect alignment, while the plot is removed afterwards again
kwargs – Keyword arguments for plotting data and adding annotations, passed to function statannot.plot_and_add_stat_annotation.
KEYWORD ARGUMENTS FOR show_data (passed to statannot.plot_and_add_stat_annotation)—————————————————————————————————————————-
- figureflow.statannot.plot_and_add_stat_annotation(data=None, x=None, y=None, hue=None, col=None, x_order=[], hue_order=[], col_order=[], show_legend=True, pair_unit_columns=None, plot_type='box', data_plot_kwds=None, show_data_points=True, connect_paired_data_points=True, plot_colors=None, box_pairs=[], perform_stat_test=True, pvalues=None, test=None, stats_params=None, text_format='star', show_test_name=False, stat_star_annot_font_size_factor=1.5, test_short_name=None, pvalue_format_string=<object object>, pvalue_thresholds=<object object>, annotate_nonsignificant=False, show_stats_to_control_without_lines=False, loc='inside', print_stat_test_results=False, plot_title=None, plot_title_across_whole_width=True, plot_boxed_title=None, title_box_colors=None, show_col_labels_above=False, show_col_labels_below=True, add_line_above_x_axis_label=False, always_show_col_label=False, col_label_padding=2, col_label_padding_without_col_labels=4, col_label_weight='normal', show_row_label=False, row_label_text=None, row_label_orientation='vert', x_range=None, show_x_axis=True, x_axis_label=None, show_x_label_in_all_columns=True, center_x_axis_label_under_all_plots=False, x_tick_interval=None, x_tick_label_rotation=False, leave_space_for_x_tick_overhang=False, y_range=None, y_scale='linear', x_scale='linear', show_y_axis=True, neg_y_vals=True, y_axis_label=None, y_tick_interval=None, show_y_minor_ticks=False, y_tick_interval_minor=None, x_ticks=None, y_ticks=None, y_tick_labels=None, x_tick_labels=None, zero_x_tick_as_int=True, zero_y_tick_as_int=True, axis_padding=10, hor_alignment='left', use_fixed_offset=False, line_offset_to_box=0.02, line_offset=0.03, text_offset=2, line_width=0.8, line_width_thin=0.3, line_height=0.1, legend_title=None, legend_handle_length=2, legend_handle_vert_alignment='top', n_legend_columns=1, legend_spacing=0.25, leave_space_for_legend=False, borderaxespad_=0.2, box_width=0.4, group_padding=0.04, auto_scale_group_padding=False, inner_padding=1, vertical_lines=False, add_background_lines=True, color='black', background_color='0.98', outer_border=None, fig=None, figure_panel=None, letter=None, fontsize='medium', for_measuring=False, size_factor=1, _letter_text=None)
Plot data row and add statistical annotations on top.
Optionally computes statistical test between pairs of data series, and add statistical annotation on top of the boxes. Uses the same exact arguments data, x, y,`hue`, order, hue_order as the seaborn boxplot function. This function works in one of the two following modes: a) perform_stat_test is True: statistical test as given by argument test` is performed. b) perform_stat_test is False: no statistical test is performed, list of custom p-values pvalues are used for each pair of boxes. The test_short_name argument is then used as the name of the custom statistical test. data :param x: Column name of data to be used for x axis
(already a parameter for figure_panel.show_data)
- Parameters:
y – Column name or list of column names of data to be used for y axis. Multiple y values will be plotted as several rows. (already a parameter for figure_panel.show_data)
hue – column name of data to be used for hue (already a parameter for figure_panel.show_data)
col – column name of data used for plots in different columns (generating a row of plots) (already a parameter for figure_panel.show_data)
x_order –
- list of x values after applying the changes
of x_labels, determining the order of c values
(already a parameter for figure_panel.show_data)
hue_order –
- list of hue values after applying the changes
of hue_labels, determining the order of c values
(already a parameter for figure_panel.show_data)
col_order –
- list of col values after applying the changes
of col_labels, determining the order of c values
(already a parameter for figure_panel.show_data)
show_legend – Whether to show legend of plot for different values in hue column (will not be shown if there is only one hue value)
pair_unit_columns – list of columns that uniquely identify one set of dependent datapoints (needed to connect paired datapoints and also needed as preprocessing to allow statistics tests for paired data)
plot_type – string of plot-type name (e.g. “box”, “bar”, “line”, “regression”, “scatter”, “swarm”). Available values are determined by modules in figureflow.plots. Alowed strings are either the complete module name or the module name without the “_plot” ending.
data_plot_kwds – dictionary with keywords for plotting object used in function “plot_data” depending on the plot_type defined; see respective data_plot object for parameters which can be used
show_data_points – Whether to show single datapoints as swarm plot. This is only possible for non continuous x vals.
connect_paired_data_points – Whether to connect paired data points of paired data in different groups with lines
plot_colors – List of plot colors
box_pairs –
Pairs of data groups (boxes) that should be statistically compared. Can be of any of the following forms: For non-grouped boxplot: [[cat1, cat2], [cat3, cat4]]. For boxplot grouped by hue: `[[(cat1, hue1), (cat2, hue2)],
[(cat3, hue3), (cat4, hue4)]]`
- For boxplots grouped by hue and an additional column (col):
- ’[[(col1,cat1, hue1), (col2,cat2, hue2)],
[(col3,cat3, hue3), (col4,cat4, hue4)]]’
perform_stat_test – Whether to perform stat tests
pvalues – list of p-values for each box pair comparison, if no stat test should be performed
test – statistics test that should be performed. For comparing two groups can be a list with one element or just a string. For comparing more than two groups has to be a list with two strings with the first string being the group test Statistics test can either be from scipy.stats or scikit-posthocs, for tests in the scikit-posthocs package the test name should start with “posthocs.” while for tests under scipy.stats should start with “stats.”. Scipy stats test work for group comparisons and for comparing two groups without control.
stats_params – Dictionary with parameters for the used stat test
text_format – Type of stat annotation, “star” for “*” and “simple” for direct p values.
show_test_name – Whether to show the test name if text_format is “simple”
stat_star_annot_font_size_factor – Factor by which the fontsize for the annotation of significance with stars will be multiplied. Increase to increase the size of significance stars in plots
test_short_name – Short name of stat test. If show_text_name is True, is displayed in annotation if text_format is “simple”
pvalue_format_string – defaults to “{.3e}”
pvalue_thresholds – list of lists, or tuples. Default is: For “star” text_format: [[1e-4, “****”], [1e-3, “***”], [1e-2, “**”], [0.05, “*”], [1, “ns”]]. For “simple” text_format : [[1e-5, “1e-5”], [1e-4, “1e-4”], [1e-3, “0.001”], [1e-2, “0.01”]]
annotate_nonsignificant – Annotate nonsignificant values as n.s. if text_format is “star”
show_stats_to_control_without_lines – When annotating statistics, do not draw lines when comparing to control, instead just add annotation on top of respective bar/box/points. This is helpful if too many lines would be drawn otherwise.
loc – location of statistics annotation, “inside” or “outside” of plot
print_stat_test_results – Whether all the statistic test information should be printed
plot_title – String; Title of the plot that will be added above the plot
plot_title_across_whole_width – Whether the plot_title should be extended across the whole axis or just across the plot itself (excluding the width of the axis label, tick labels, legend width, etc.)
plot_boxed_title – String, Title that will be in a colored box above all other title of the plot and across the entire width of the plot
title_box_colors – List of colors to use for boxed title. The box will be divided into as many even parts as colors are defined. The order of the colors will also be used for the parts of the box.
show_col_labels_above – Whether to show col labels above the plot, if True, show_col_labels_below will be set to False
show_col_labels_below – Whether to show col labels below the plot
always_show_col_label – Whether to always show col labels (also if there was only one col value)
col_label_padding – Label padding for cols
col_label_weight – Font weight of col labels: “normal” or “bold”
show_row_label – Bool; Whether there should be a label displayed right of the rightmost plot when True, legend will not be displayed automatically (both together is not implemented at the moment)
row_label_text – Text that should be used as row label instead of the value in the row column
row_label_orientation – Text orientation of row label, “hor” or “vert”
x_range – List of minimum and maximum x value
show_x_axis – Whether to show x axis
x_axis_label – Label of x axis.
show_x_label_in_all_columns – Whether to show x axis in all columns even if they have the same x axis.
center_x_axis_label_under_all_plots – Whether the x axis label should be plotted once, centered under all plots, instead of being plotted below separate plots.
x_tick_label_rotation – Boolean, Whether the x tick labels should be rotated by 45 degree
x_tick_interval – Interval between major ticks on x axis
leave_space_for_x_tick_overhang – For plotting multiple rows where only the last row might have an x axis with potential x tick overhangs. Whether to leave space for these overhangs in the last row in the other rows.
y_range – List of minimum and maximum y value
y_scale – Scale on y_axis (e.g. “linear” or “log”)
x_scale – Scale on x_axis (e.g. “linear” or “log”)
show_y_axis – Whether to show the y axis
neg_y_vals – are there data points below zero, if not lowest y axis value is 0 (margin settings will make it lower than zero otherwise)
y_axis_label – Label of y axis
y_tick_interval – Interval between major ticks on y axis
show_y_minor_ticks – Whether to show minor ticks on y axis
y_ticks – List of specific tick values that should be used for y axis
x_ticks – List of specific tick values that should be used for x axis
zero_y_tick_as_int – Whether to show 0 tick for y axis as integer (0) and not as a float (0.0).
zero_x_tick_as_int – Whether to show 0 tick for x axis as integer (0) and not as a float (0.0).
axis_padding – padding between plot and y_axis ticks in points
hor_alignment – “right”, “left” or “center”, horizontal alignment of plots in panel plots always will the entire y space but not necessarily the entire x space. therefore alignment in x matters but not in y
use_fixed_offset – Whether to use a fixed distance of stat annotations (if True) or whether to plot annotations above highest y datapoint.
line_offset_to_box – Offset of stat annotation lines to highest point in data
line_offset – Offset of annotation lines to highest annotation lines.
text_offset – Offset of annotation text from annotation line in points
line_width – Width of annotation lines and grid lines in plot
line_width_thin – Width of minor tick grid lines in plot
line_height – in arbitrary units
legend_title – Title of legend, displayed above legend.
legend_handle_length – Length of colored bars used in legend
legend_handle_vert_alignment – Alignment of legend handle relative to text. “center” will align it in the vertical center of the whole legend label, while “top” will align it vertically centered to the first line of the legend label. For a multiline legend label with 4 lines (3 line breaks), “center” will align the legend handle between the second and third line and “top” will align it in the middle of the first line.
n_legend_columns – The number of columns for the legend.
legend_spacing – space between legend handles (color boxes) and legend text
leave_space_for_legend – Internal parameter to indicate whether space for legend should be kept free even if legend was removed
borderaxespad – in points, padding of legend from plot and also of row label from plot
box_width – maximum box width in inches - scaled by width of one column in inches / 2
group_padding – space between two cols in inches - scaled by width of one column in inches / 2
auto_scale_group_padding –
Bool; NOT WORKING AT THE MOMENT! Whether defined group_padding should be scaled automatically Autoscaling scales space between plots as much as the size of plots Thereby boxes becoming too small due to group padding is prevented automatically this reduces a bit of manual work,
however, for facet plots it cannot
be used since the exact size of the group padding is necessary for a proper grid-like arrangement
inner_padding – Padding of axis labels to plots
vertical_lines – Boolean, Whether thin vertical lines should be drawn for each box
add_background_lines – Whether to add lines between plots in different columns (different col values). Adding lines makes plots seem connected, not adding them makes them look like separate plots.
color – Color of lines and text
background_color – Background color of plot
outer_border – Outer border of plot (cannot be manually set, will be set by figure_panel)
fig – matplotlib figure object (cannot be manually set, will be set by figure_panel)
figure_panel – figureflow figure_panel object (cannot be manually set, will be set by figure_panel)
letter – Letter of figure_panel (cannot be manually set, will be set by figure_panel)
padding – padding between panels in inches (cannot be manually set, will be set by figure_panel)
- figureflow.figure_panel.FigurePanel.set_data_params(self, x=None, y=None, hue=None, col=None, row=None)
Set data parameters for showing data.
- Parameters:
x – Column name of data to be used for x axis
y – Column name or list of column names of data to be used for y axis. Multiple y values will be plotted as several rows.
hue – column name of data to be used for hue
col – column name of data used for plots in different columns (generating a row of plots)
row – column of data used for plots in different rows (generating a columns of plots)
- figureflow.figure_panel.FigurePanel.show_data_columns(self, nb_vals=10, show_min_max=True)
Show type and some values for all columns of the data file.
- Parameters:
nb_vals – number of values for column to show
- figureflow.figure_panel.FigurePanel.calculate_fractions(self, group_criteria, new_group_name='fraction_group')
Allow calculating the fraction of specific groups in the data. Will generate a new dataframe with different rows that also will be used to plot data afterwards.
- Parameters:
criteria – Dict of dicts. Each dict defines one fraction to calculate The key in the upper dict defines the name of the new group in each sub dict the key is a column and the value is a string to be used in a “query” expression, without the column e.g. for col_x to be larger than 10, the dict should be like this: ‘col_x’ : ‘> 10’
- figureflow.figure_panel.FigurePanel.add_data_transformation(self, function)
Add a transformation for the data that will be plotted on the y-column.
- Parameters:
function – Function that will be applied to the column (pd.series object)
- figureflow.figure_panel.FigurePanel.draw_line_on_plots(self, positions, axis, line_width=1, color='white', line_style='-', **kwargs)
Draw lines on data plots. This is not implemented for multiple rows of data plots yet.
- Parameters:
positions – list of positions (x or y) of adding line
axis – axis of positions (“x” or “y”)
line_width – line width in pt
color – color of line
line_style – linestyle as typical matplotlib linestyle (e.g. “-” or “–” or “-.-“)
- figureflow.figure_panel.FigurePanel.get_basic_statistics(self, N_columns=None, n_columns=None, show_stats=False, show_from_ungrouped_data=None, show_from_grouped_data=None)
Get basic statistics of different datagroups. (mean, number of experiments, number of cells, etc).
- Parameters:
N_columns – is column or list of columns in which the number of different values will be calculated
n_columns – is a column or list of columns that define the number of n that should be returned if not defined, will count number of measurements
show_stats – Whether to show statistics test results
show_from_ungrouped_data – Whether to show basic statistics from ungrouped data (particularly important for continuous data)
show_from_grouped_data – Whether to show basic statistics from grouped data (when there are any data groups)
- figureflow.figure_panel.FigurePanel.get_representative_data(self, unit_columns=None, cols_to_show=None, nb_of_measurements_matter=True, sort_by_relative_difference=True, print_results=True, nb_vals_to_show=20, column_suffix='___d___')
Get list of units (cells etc) that are closest to average of data. Data from one unit is in a single image, therefore cannot be separated the function will rank units than regarding their difference to the mean. If you want a representative neuron but did measure neurites, a unit should be a neuron but the function will account the difference from the mean of all measured neurites. It will weigh larger differences from the mean more (squared difference of mean).
- Parameters:
unit_column – columns which uniquely identify one “unit”, only necessary if there is more than one datapoint in one image with list_of_columns being the columns that define one unit that was analyzed (e.g. for a neurite it could be [“date”, “neuron”, “neurite”]).
cols_to_show – Columns to show in summary
nb_of_measurements_matter – Whether representative data should be sorted by number of measurements. When one unit can have more than one datapoint, this means first showing the units with the most datapoints, independent of their deviation from the mean. This can be helpful when most units have e.g. 2 datapoints and only a few 1, then you may only want to use units with 2 datapoints.
sort_by_relative_difference – Whether to sort by relative difference from the mean (if True) Otherwise will sort by absolute difference. When having more than one measure, relative difference can help making them comparable (keeping the contribution of all measures similar). But in that case a mean close to 0 might also artificially increase the relative difference.
print_results – Whether to print results or just calculate them. When printing comparisons for multiple plots later, just calculating can be enough.
nb_vals_to_show – Number of units to show for each group.
column_suffix – suffix that should be added for difference columns this should be something that is not present in any current column name.