celltraj.utilities
- celltraj.utilities.generate_xcoords_violin(violinplot, sample_data)
Generate random x-coordinates within the width of each violin plot at the corresponding y-values.
- Parameters:
violinplot – The matplotlib Violin plot object returned by ax.violinplot().
sample_data – List or array of sample data used to create the violin plot.
- Returns:
A list of (x, y) coordinates representing random points within the violin’s width.
- celltraj.utilities.ternary_coords_from_3d(data_3d)
Converts a (N, 3) numpy array of compositional data into a (N, 2) array of 2D coordinates for a ternary plot.
The function first normalizes each row of the input array so that the three components sum to 1. It then transforms these normalized values into 2D Cartesian coordinates for plotting within an equilateral triangle.
- Parameters:
data_3d (
np.ndarray) – A numpy array of shape (N, 3) where each row contains three values representing compositional data.- Returns:
- A numpy array of shape (N, 2) containing the 2D coordinates
suitable for a ternary scatterplot.
- Return type:
np.ndarray
- celltraj.utilities.progress_bar(current_id, id_list, *, text_str='', bar_length=40, show_eta=True, use_unicode=True)
Single-line terminal progress bar.
- Parameters:
current_id (
int) – Current id in iteration.id_list (
array-like) – Full list of ids being iterated.text_str (
str) – Custom text displayed before progress bar.bar_length (
int) – Length of progress bar.show_eta (
bool) – If True, estimate remaining time.use_unicode (
bool) – If True, uses smooth unicode blocks.