Skip to content

Lineage Tree Analysis

napari_relax.lineage_tree_analysis.lineage_viewer_widget.progeny_selection

Explore and Relabel entry of the Lineage tree analysis widget.

ProgenySelection

Bases: LayerCorrectorTreeProducer

Lineage Viewer, cell selection, labels and visibility controls.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

get_sublineage(cell, lT) staticmethod

Score the nodes of the lineage that contains a cell.

Nodes in the subtree of cell and its ancestors get 1; nodes in other branches get one more than the number of divisions between cell and their branching point.

Parameters:

Name Type Description Default
cell int

ID of the cell.

required
lT LineageTree

The LineageTree.

required

Returns:

Type Description
dict

Score of each node of the lineage.

select_the_lineage()

Select the whole lineage of the selected point.

point_click(viewer, event)

Select the node under a Shift + right click in the viewer.

Parameters:

Name Type Description Default
viewer Viewer

The napari viewer.

required
event Event

The mouse event with the position and view direction.

required

update_lineageviewer_colors()

Update the Lineage Viewer to show the current lineage colors.

progeny_diagram_loader()

Draw the lineage selected by the slider and update the label field.

sub_point_painter()

Select the sublineage spawned by the selected point.

points_selector()

Select the entire lineage that contains the selected node.

layer_change(event)

Switch to the LineageTree of the new active layer.

The InteractionBridge of the layer is used, and its saved slider and selection state are restored.

Parameters:

Name Type Description Default
event Event

The layer selection event.

required

label_remover()

Remove the label of the node shown in the label field.

show_all_labels()

Show and edit all labels of the LineageTree.

show_all()

Show all nodes across all layer types.

hide_all()

Hide all nodes across all layer types.

hide_lineage()

Hide the currently selected lineage across all layer types.

show_lineage()

Show only the currently selected lineage across all layer types.

cell_id_selector()

Show the lineage of the cell ID typed in the Cell ID selector.

The slider moves to the lineage containing the cell, the cell is circled in the Lineage Viewer and selected in the viewer, and the time slider moves to its first timepoint. The closest existing ID is used if the typed one does not exist.

update_time_slider_for_cell(cell_id)

Update the time slider to show when the given cell first appears.

resizeEvent(event)

Keep the help button in the top right corner.

Parameters:

Name Type Description Default
event QResizeEvent

The resize event.

required

label_changer()

Rename the node shown in the label field and broadcast the labels.

cleanup_callbacks()

Remove the point_click callback from the mouse draf callbacks because it stays on the list of signals even after the death of the plugin.

napari_relax.lineage_tree_analysis.lineage_viewer_widget.lineage_viewer.viewer

Lineage Viewer canvas drawing one lineage tree.

SingleTreeProgeny

Bases: FigureCanvasQTAgg, CanvasUtils

Matplotlib canvas showing one lineage of a LineageTree.

Node size, edge size and font size are read from the ReLAX page of napari's preferences when the module is imported.

coloring property

Return the color of each node, with selected nodes highlighted.

Returns:

Type Description
dict

Color of each node ID.

change_attributes(signal)

Apply new node size, edge size and font size, then redraw.

Parameters:

Name Type Description Default
signal object

Event whose source has node_size, edge_size and font_size attributes.

required

update_face_colors(face_colors)

Update the metadata with provided face colors.

change_lineage(root=None, lT=None, lnks_tms=None, hier=None, points_layer_metadata=None)

Show another lineage.

Parameters:

Name Type Description Default
root int

Root of the lineage.

None
lT LineageTree

The LineageTree; nothing happens if None.

None
lnks_tms dict

Graph of the lineage.

None
hier dict

Position of each node of the graph.

None
points_layer_metadata dict

Metadata of the Points layer, used for the node colors.

None

draw_graph(reset=False)

Draw the tree.

Parameters:

Name Type Description Default
reset bool

If True, reset the axes limits; otherwise keep the current zoom and pan, by default False.

False

calculate_axes()

Compute the axes limits of the tree, with a margin.

click(event)

Select the node closest to a left click.

Clicking far from any node clears the selection.

Parameters:

Name Type Description Default
event MouseEvent

The click event.

required

napari_relax.lineage_tree_analysis.lineage_viewer_widget.lineage_viewer.canvas_interaction_events

Mouse and keyboard interactions of the Lineage Viewer.

CanvasUtils

Zoom, pan, reset and time line behaviour for the Lineage Viewer.

Mixed into SingleTreeProgeny.

reset(event)

Reset the view when Z is pressed.

Parameters:

Name Type Description Default
event KeyEvent

The key press event.

required

pan_start(event)

Start panning on right button press.

Parameters:

Name Type Description Default
event MouseEvent

The button press event.

required

pan_stop(event)

Stop panning on right button release.

Parameters:

Name Type Description Default
event MouseEvent

The button release event.

required

panning(event)

Move the view while the right button is held.

Parameters:

Name Type Description Default
event MouseEvent

The mouse move event.

required

on_scroll(event)

Zoom in or out around the cursor.

Parameters:

Name Type Description Default
event MouseEvent

The scroll event.

required

time_line(time)

Draw the current viewer timepoint as a grey line.

Parameters:

Name Type Description Default
time Event

The current_step event of the viewer dims.

required

connect_signals()

Connect the matplotlib events to the canvas.

napari_relax.lineage_tree_analysis.comparison_widget.comparisons_handler

Distance Calculation entry of the Lineage tree analysis widget.

ComparisonsHandler

Bases: LayerCorrectorTreeProducer

Tabs to configure, run and inspect pairwise lineage comparisons.

The Configuration Panel tab (ConfigurationPanel) sets up and runs the comparisons; the Clustermap tab (Clustermap) shows the results.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

update_dictionary(product)

Send the results yielded by the comparison thread to the clustermap.

Parameters:

Name Type Description Default
product tuple

Comparisons, sublineage names, normalizations and timepoints, one entry per timepoint computed so far.

required

thread_handler()

Start the comparisons in a background thread.

The results are sent to update_dictionary as each timepoint is computed.

kill_thread(dummy_event=None)

Stop the comparison thread and close the progress bar.

Parameters:

Name Type Description Default
dummy_event object

Event of the signal that triggered the stop, unused.

None

__init__(napari_viewer)

Build the tabs and the Run/Stop buttons.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

napari_relax.lineage_tree_analysis.comparison_widget.config

Configuration Panel tab of the Distance Calculation.

ConfigurationPanel

Bases: LayerCorrectorTreeProducer

Widget to calculate the pairwise comparisons of any configuration selected.

thread_worker()

Compute the pairwise distances of sublineages for each timepoint.

Timepoints after the crop time or with a single cell are skipped.

Yields:

Type Description
tuple

Comparisons, sublineage names, normalizations and timepoints, one entry per timepoint computed so far.

times_selector()

Read the timepoints to compare.

They are either a comma-separated list or a range built from start, stop and step.

specific_roots_selector()

Store the roots selected in the list.

With no selection, all roots at the first timepoint are used.

time_cropping()

Read the crop time typed by the user.

label_update()

Refresh the list of labelled roots after a label change.

layer_change(event)

Update the panel for the LineageTree of the new active layer.

Parameters:

Name Type Description Default
event Event

The layer selection event; exactly one layer must be selected.

required

update_tree_style()

Show the downsampling box only for the downsampled style.

__init__(napari_viewer)

Build the configuration widgets.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

resizeEvent(event)

Keep the help button in the top right corner.

Parameters:

Name Type Description Default
event QResizeEvent

The resize event.

required

napari_relax.lineage_tree_analysis.comparison_widget.clustermap

Clustermap tab of the Distance Calculation.

Clustermap

Bases: LayerCorrectorTreeProducer

Contains the clustermap and its interactions.

send_data()

Plot the comparisons of the timepoint selected by the slider.

add_spot_on_graph(cell, val, color, ax)

Draw a cell that is in the middle of a chain on a tree plot.

Parameters:

Name Type Description Default
cell int

ID of the cell.

required
val int

Index of the graph in the list of graphs.

required
color color

Color of the spot.

required
ax Axes

Axes of the tree plot.

required

reset_colorer()

Restore the original colors of the points.

time_changer()

Show the clustermap of the timepoint selected by the slider.

save_dictionary()

Save the comparisons to the selected .pkl file.

The file holds a dict with times, comparisons, norms, names, end_time and labels.

layer_change(event)

Update the tab for the LineageTree of the new active layer.

Parameters:

Name Type Description Default
event Event

The layer selection event; exactly one layer must be selected.

required

receive_new_labels()

Redraw the clustermap after a label change.

__init__(napari_viewer, configuration=None)

Build the tree plots, clustermap and save widgets.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required
configuration ConfigurationPanel

The configuration tab providing the timepoints.

None

resizeEvent(event)

Keep the help button in the top right corner.

Parameters:

Name Type Description Default
event QResizeEvent

The resize event.

required

napari_relax.lineage_tree_analysis.comparison_widget.clustermap_canvas

Matplotlib canvas drawing the interactive clustermap.

ClusterMapCanvas

Bases: FigureCanvasQTAgg

Matplotlib canvas showing pairwise comparisons as a clustermap.

Parameters:

Name Type Description Default
figure Figure

The figure to draw on.

required
ax Axes

The axes of the clustermap.

required

__init__(figure, ax)

Create the canvas and connect the click and hover events.

Parameters:

Name Type Description Default
figure Figure

The figure to draw on.

required
ax Axes

The axes of the clustermap.

required

clear_data()

Clear the plot and remove all data.

remove_annotation()

Remove the hover box from the axes.

is_mouse_on_figure()

Check whether the mouse is on the figure.

Returns:

Type Description
bool

True if the mouse is on the figure else False.

remove_on_leave()

Remove the hover box once the mouse has left the figure.

annotation_maker(x, y, offset_xy, ha, value)

Create the hover box of a clustermap cell.

Parameters:

Name Type Description Default
x float

Column of the cell.

required
y float

Row of the cell.

required
offset_xy tuple of int

Offset of the box from the cell, in points.

required
ha str

Horizontal alignment of the box.

required
value float

Score shown in the box.

required

print_text(pos)

Show the hover box of the cell under the cursor.

Parameters:

Name Type Description Default
pos tuple[int, int]

The position of the cursor.

required

napari_relax.lineage_tree_analysis.recoloring_with_attributes_widget.recoloring_widget

Attribute Based Recoloring entry of the Lineage tree analysis widget.

RecoloringWidget

Bases: LayerCorrectorTreeProducer

Tabs to recolor a dataset by clone or by node attribute.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

napari_relax.lineage_tree_analysis.recoloring_with_attributes_widget.clone_based_recoloring

Clone based Recoloring tab.

CloneRecoloring

Bases: LayerCorrectorTreeProducer

Recolor a dataset by the clones present at a chosen timepoint.

A population graph shows the number of cells over time; each cell present at the selected timepoint gives its color to its subtree.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

slider_change()

Move the timepoint marker on the population graph.

color_clones(*args, **kwargs)

Color each clone of the selected timepoint with the colormap.

Parameters:

Name Type Description Default
*args

Button signal arguments, unused.

()
**kwargs

Button signal arguments, unused.

{}

layer_change()

Update the population graph for the new active layer.

reset_colors()

Restore the original colors of the dataset.

create_layout()

Create the layout of the tab.

resizeEvent(event)

Keep the help button in the top right corner.

Parameters:

Name Type Description Default
event QResizeEvent

The resize event.

required

napari_relax.lineage_tree_analysis.recoloring_with_attributes_widget.node_based_recoloring

Node based Recoloring tab.

LineeditCheckbox

Bases: QCheckBox

Checkbox with a text field for a custom numeric value.

text()

Return the value typed in the text field.

Returns:

Type Description
int

The value, truncated to an integer.

setText(value)

Set the value of the text field.

Parameters:

Name Type Description Default
value float

The value to show.

required

MissingData

Bases: QWidget

Choice of how to color nodes without a value for the attribute.

"Default Value" reveals the Custom value, Mean, Median and Min options.

Parameters:

Name Type Description Default
parent QWidget

The parent widget.

None

selected()

Return the selected method.

Returns:

Type Description
str or int or None

The label of the selected option, the custom value, or None if nothing is selected.

Quantitative

Bases: LayerCorrectorTreeProducer

Recolor the dataset by a numeric node attribute.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

generate_colors()

Color every node by the selected attribute and missing-data method.

reset_button_pr()

Restore the original colors of the dataset.

layer_change()

List the numeric attributes of the new active LineageTree.

Qualitative

Bases: QWidget

Placeholder for recoloring by qualitative attributes (not implemented).

Coloring

Bases: LayerCorrectorTreeProducer

Node based Recoloring tab: quantitative or qualitative attributes.

Only quantitative attributes are supported for now.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

resizeEvent(event)

Keep the help button in the top right corner.

Parameters:

Name Type Description Default
event QResizeEvent

The resize event.

required

filter_dicts_of_objects_by_values(obj, type_of_object)

Find the dict attributes of an object whose values have a type.

Parameters:

Name Type Description Default
obj object

The object to inspect, typically a LineageTree.

required
type_of_object type

The type the values must have.

required

Returns:

Type Description
list[str]

Names of the matching attributes.

napari_relax.lineage_tree_analysis.cells_size

Shared panel shown at the bottom of the Lineage tree analysis widget.

CellSize

Bases: LayerCorrectorTreeProducer

Point size, layer visibility, tracks and saving tools.

It is shown under every entry of the Lineage tree analysis widget.

Parameters:

Name Type Description Default
napari_viewer Viewer

The napari viewer.

required

add_tracks(event)

Add a Tracks layer for the LineageTree of the active layer.

Parameters:

Name Type Description Default
event object

The button click event, unused.

required

reset_slider(value=None)

Set the point size and move the slider to match it.

Parameters:

Name Type Description Default
value float

Size in Points layer units. If None, the size estimated from the distances between neighboring cells is used.

None

see_one_layer()

Hide every layer except the active one.

see_all_layers()

Show every layer.

layer_change()

Update the panel when the selected layer changes.

Hides the other layers if "Toggle visibility of other layers" is ticked, and moves the size slider to the size of the new layer.

write_embryo()

Save the LineageTree of the active layer to the selected file.

is_lt_layer(layer)

Check whether a layer is a Points layer holding a LineageTree.

Parameters:

Name Type Description Default
layer Layer

The layer to check.

required

Returns:

Type Description
bool

True if the layer holds a LineageTree.

force_viewer_select_if_lt_layer(event)

Select a newly added LineageTree layer and set its size range.

Parameters:

Name Type Description Default
event Event

The layer insertion event.

required