Skip to content

Commit 732989c

Browse files
committed
adding buffer for 0 division
1 parent 678dd24 commit 732989c

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

pf2rnaseq/figures/commonFuncs/plotFactors.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,19 @@ def plot_condition_factors(
1818
cond_group_labels: pd.Series | None = None,
1919
groupConditions=False,
2020
cond="Condition",
21-
log_scale=True,
22-
centering=True
21+
log_scale=True
2322
):
2423
"""Plots Pf2 condition factors"""
2524
pd.set_option("display.max_rows", None)
2625
yt = pd.Series(np.unique(data.obs[cond]))
2726
X = np.array(data.uns["Pf2_A"])
2827
if log_scale:
2928
X = np.log10(X)
30-
if centering:
31-
X -= np.median(X, axis=0)
32-
X /= np.std(X, axis=0)
33-
ind = reorder_table(X)
34-
else:
35-
ind = np.arange(len(X))
29+
30+
X -= np.median(X, axis=0)
31+
X /= np.std(X, axis=0)+1e-3
32+
ind = reorder_table(X+1e-3)
33+
3634
X = X[ind]
3735
yt = yt.iloc[ind]
3836

pf2rnaseq/figures/figureParseFactorsDeconv.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def makeFigure():
3535
X = read_h5ad("/home/nicoleb/ParsePf2_100_D11_filt.h5ad")
3636
X.uns["Pf2_A"] = correct_conditions(X)
3737

38-
W, H = deconvolution_cytokine(X.uns["Pf2_A"], alpha=9e-5, max_iter=5000)
38+
W, H = deconvolution_cytokine(X.uns["Pf2_A"], alpha=1e-1, max_iter=5000)
3939

4040

4141
# Get cytokine names in correct order
@@ -51,8 +51,7 @@ def makeFigure():
5151
samples_df["cytokine"],
5252
groupConditions=True,
5353
cond="cytokine",
54-
log_scale=False,
55-
centering=False
54+
log_scale=False
5655
)
5756
ax[0].set_title("Deconvolved matrix (H)", fontsize=12, fontweight="bold")
5857

@@ -62,8 +61,7 @@ def makeFigure():
6261
samples_df["cytokine"],
6362
groupConditions=True,
6463
cond="cytokine",
65-
log_scale=False,
66-
centering=False
64+
log_scale=False
6765
)
6866
ax[1].set_title("Original Effects (A)", fontsize=12, fontweight="bold")
6967

0 commit comments

Comments
 (0)