diff --git a/src/pixelator/plot/spatial_analysis_plots.py b/src/pixelator/plot/spatial_analysis_plots.py index b70a0466..5b07ca45 100644 --- a/src/pixelator/plot/spatial_analysis_plots.py +++ b/src/pixelator/plot/spatial_analysis_plots.py @@ -194,7 +194,7 @@ def plot_colocalization_diff_heatmap( cmap=cmap, ) g.figure.suptitle( - f"Differential colocalization between {reference} and {target}" + f"Differential colocalization between {target} and {reference}" ) plt.tight_layout() figs[target] = plt.gcf() @@ -215,7 +215,10 @@ def _add_top_marker_labels( # Labels for marker pair withs highest negative differential colocalization scores for _, row in plot_data.head(n_top_pairs).iterrows(): if "marker_1" not in row.index: - name = row["marker"] + if "marker" in row.index: + name = row["marker"] + else: + name = row.name else: name = row["marker_1"] + "/" + row["marker_2"] @@ -234,7 +237,10 @@ def _add_top_marker_labels( # Labels for marker pair with highest positive differential colocalization scores for _, row in plot_data.tail(n_top_pairs).iterrows(): if "marker_1" not in row.index: - name = row["marker"] + if "marker" in row.index: + name = row["marker"] + else: + name = row.name else: name = row["marker_1"] + "/" + row["marker_2"] x, y = row[["median_difference", "p_adj"]] @@ -344,7 +350,7 @@ def plot_colocalization_diff_volcano( ax.set( xlabel="Median difference", ylabel=r"$-\log_{10}$(adj. p-value)", - title=f"Differential colocalization\nbetween {reference}\nand {target}", + title=f"Differential colocalization\nbetween {target}\nand {reference}", ) ax.title.set_y(1.05) fig.colorbar(p, label="Mean target colocalization score", cmap=cmap) @@ -417,7 +423,7 @@ def plot_polarity_diff_volcano( ax = axes[i] if len(targets) > 1 else axes target_differential_polarity = differential_polarity.loc[ differential_polarity["target"] == target, : - ] + ].set_index("marker") target_differential_polarity["target_mean"] = ( polarity_data[polarity_data[contrast_column] == target] .groupby("marker")[value_column] @@ -436,7 +442,7 @@ def plot_polarity_diff_volcano( ax.set( xlabel="Median difference", ylabel=r"$-\log_{10}$(adj. p-value)", - title=f"Differential polarity\nbetween {reference}\nand {target}", + title=f"Differential polarity\nbetween {target}\nand {reference}", ) ax.title.set_y(1.05) fig.colorbar(p, label="Mean target polarity score", cmap=cmap) diff --git a/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano/test_plot_colocalization_diff_volcano.png b/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano/test_plot_colocalization_diff_volcano.png index 367bf6d5..463800f7 100644 Binary files a/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano/test_plot_colocalization_diff_volcano.png and b/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano/test_plot_colocalization_diff_volcano.png differ diff --git a/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano_multiple/test_plot_colocalization_diff_volcano_multiple.png b/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano_multiple/test_plot_colocalization_diff_volcano_multiple.png index 22d86112..63f73eab 100644 Binary files a/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano_multiple/test_plot_colocalization_diff_volcano_multiple.png and b/tests/snapshots/test_plot/test_plot_colocalization_diff_volcano_multiple/test_plot_colocalization_diff_volcano_multiple.png differ diff --git a/tests/snapshots/test_plot/test_plot_polarity_diff_volcano/test_plot_polarity_diff_volcano.png b/tests/snapshots/test_plot/test_plot_polarity_diff_volcano/test_plot_polarity_diff_volcano.png index ab34f428..b70132d7 100644 Binary files a/tests/snapshots/test_plot/test_plot_polarity_diff_volcano/test_plot_polarity_diff_volcano.png and b/tests/snapshots/test_plot/test_plot_polarity_diff_volcano/test_plot_polarity_diff_volcano.png differ diff --git a/tests/snapshots/test_plot/test_plot_polarity_diff_volcano_multiple/test_plot_polarity_diff_volcano_multiple.png b/tests/snapshots/test_plot/test_plot_polarity_diff_volcano_multiple/test_plot_polarity_diff_volcano_multiple.png index f0906b71..a00aed83 100644 Binary files a/tests/snapshots/test_plot/test_plot_polarity_diff_volcano_multiple/test_plot_polarity_diff_volcano_multiple.png and b/tests/snapshots/test_plot/test_plot_polarity_diff_volcano_multiple/test_plot_polarity_diff_volcano_multiple.png differ