Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: unusually large multi-target polarity plot #189

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Loading