API details.
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()
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"],
)
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()