Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/theislab/pertpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson committed Jun 6, 2024
2 parents 5830057 + 2e4bc55 commit 21d8bf6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
hooks:
- id: prettier
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.5
rev: v0.4.7
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --unsafe-fixes]
Expand Down
10 changes: 4 additions & 6 deletions pertpy/tools/_differential_gene_expression/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,11 @@ def _map_genes_categories_highlight(
print("0s encountered for p value, replacing with 1e-323")
df.loc[df[pvalue_col] == 0, pvalue_col] = 1e-323

# max for y-axis
max_log2fc = df[log2fc_col].max()

# convert p value threshold to nlog10
pval_thresh = -np.log10(pval_thresh)
# make nlog10 column
df["nlog10"] = -np.log10(df[pvalue_col])
y_max = df["nlog10"].max() + 1
# make a column to pick top genes
df["top_genes"] = df["nlog10"] * df[log2fc_col]

Expand Down Expand Up @@ -401,7 +399,7 @@ def _map_genes_categories_highlight(

# plot vertical and horizontal lines
if s_curve:
x = np.arange((log2fc_thresh + 0.000001), max_log2fc + 1, 0.01)
x = np.arange((log2fc_thresh + 0.000001), y_max, 0.01)
y = _pval_reciprocal(x)
ax.plot(x, y, zorder=1, c="k", lw=2, ls="--")
ax.plot(-x, y, zorder=1, c="k", lw=2, ls="--")
Expand All @@ -410,7 +408,7 @@ def _map_genes_categories_highlight(
ax.axhline(pval_thresh, zorder=1, c="k", lw=2, ls="--")
ax.axvline(log2fc_thresh, zorder=1, c="k", lw=2, ls="--")
ax.axvline(log2fc_thresh * -1, zorder=1, c="k", lw=2, ls="--")
plt.ylim(0, max_log2fc + 1)
plt.ylim(0, y_max)
ax.xaxis.set_major_locator(MaxNLocator(integer=True))

# make labels
Expand All @@ -437,7 +435,7 @@ def _map_genes_categories_highlight(
ax.spines["right"].set_visible(False)

ax.tick_params(width=2)
plt.xticks(size=11)
plt.xticks(size=11, fontsize=10)
plt.yticks(size=11)

# Set default axis titles
Expand Down

0 comments on commit 21d8bf6

Please sign in to comment.