API details.

prerequisite code for in function examples

from ratioimage.ratio_images import (
    create_img_dict_from_folder,
    ratiometric_measure_region_props_to_tidy_df,
    sample_id_to_categories,
    split_img_key_col_to_sample_id_and_replicates,
)

C0_imgs = create_img_dict_from_folder(load_pattern="data/PercevalHR_data/imgs/*C0.tiff")
C1_imgs = create_img_dict_from_folder(load_pattern="data/PercevalHR_data/imgs/*C1.tiff")
lab_imgs = create_img_dict_from_folder(
    load_pattern="data/PercevalHR_data/segs/*.tif", label=True
)
df = ratiometric_measure_region_props_to_tidy_df(C1_imgs, C0_imgs, lab_imgs)

df = split_img_key_col_to_sample_id_and_replicates(
    df, sample_id_colname="genotype", split_regex=r"g"
)

df = sample_id_to_categories(
    df, sample_id_colname="genotype", old_to_new_sample_ids={"a1": "ctrl", "a2": "mut"}
)

df.head()
label area mean_intensity_num centroid-0 centroid-1 img_key mean_intensity_denom ratio_mean_int genotype rep_id
0 1 342 0.017960 7.400585 295.084795 a1g01 0.010094 1.779309 ctrl 01
1 2 200 0.012017 35.585000 80.495000 a1g01 0.006473 1.856478 ctrl 01
2 3 269 0.013259 79.152416 174.858736 a1g01 0.027961 0.474173 ctrl 01
3 4 213 0.013988 76.201878 282.995305 a1g01 0.019588 0.714101 ctrl 01
4 5 546 0.025333 86.560440 322.816850 a1g01 0.013664 1.854012 ctrl 01

plot_results functions

tidy_create_strip_box_plot[source]

tidy_create_strip_box_plot(y_axis_start:int=0, y_axis_limit:int=None, y_label:str='set y label', notch:bool=True, **kwargs)

Creates sns plots. Pass **kwargs to sns.stripplot and sns.boxplot.

fig, ax = plt.subplots(figsize=(1.75, 2.5))

tidy_create_strip_box_plot(
    x="genotype",
    y="ratio_mean_int",
    data=df,
    ax=ax,
    y_axis_limit=4,
    y_label="PercevalHR 488/405\n(Relative ATP/ADP)",
    palette=["#95a5a6", "#95a5a6"],
)

tidy_create_swarm_box_plot[source]

tidy_create_swarm_box_plot(y_axis_start:int=0, y_axis_limit:int=None, y_label:str='set y label', **kwargs)

Creates sns plots. Pass **kwargs to sns.swarmplot and sns.boxplot.

grouped_df = (
    df.groupby(["genotype", "rep_id"]).agg({"ratio_mean_int": "mean"}).reset_index()
)
fig, ax = plt.subplots(figsize=(1.75, 2.5))

tidy_create_swarm_box_plot(
    x="genotype",
    y="ratio_mean_int",
    ax=ax,
    data=grouped_df,
    y_axis_limit=2.5,
    y_label="PercevalHR 488/405\n(Relative ATP/ADP)",
    palette=["#95a5a6", "#95a5a6"],
)
fig, ax = plt.subplots(figsize=(4.5, 2.5), ncols=2)

tidy_create_swarm_box_plot(
    x="genotype",
    y="ratio_mean_int",
    ax=ax[0],
    data=grouped_df,
    y_axis_limit=2.5,
    y_label="PercevalHR 488/405\n(Relative ATP/ADP)",
    palette=["#95a5a6", "#95a5a6"],
)

tidy_create_strip_box_plot(
    x="genotype",
    y="ratio_mean_int",
    ax=ax[1],
    data=df,
    y_axis_limit=4,
    y_label="PercevalHR 488/405\n(Relative ATP/ADP)",
    palette=["#95a5a6", "#95a5a6"],
)
plt.tight_layout()