Skip to content

Commit

Permalink
fix: multi-target polarity plot
Browse files Browse the repository at this point in the history
  • Loading branch information
ptajvar committed Sep 16, 2024
1 parent 8526c31 commit ed0d201
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/pixelator/plot/spatial_analysis_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"]

Expand All @@ -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"]]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ed0d201

Please sign in to comment.