Skip to content

Commit 2f17279

Browse files
committed
fix: plot gaussian distribution with a peak of the fpkm value at mu, not at the maximum fpkm distribution
Signed-off-by: Josh Loecker <joshloecker@icloud.com>
1 parent 31cb4d4 commit 2f17279

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

main/como/rnaseq_gen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ def zfpkm_plot(results: dict[str, _ZFPKMResult], *, output_png_dirpath: Path, pl
447447
y: npt.NDArray[float] = result.density.y.flatten()
448448

449449
fitted: npt.NDArray[float] = np.exp(-0.5 * ((x - result.mu) / stddev) ** 2) / (stddev * np.sqrt(2 * np.pi))
450-
max_fpkm: float = float(y.max())
450+
fpkm_at_mu: float = result.fpkm_at_mu
451451
max_fitted: float = float(fitted.max())
452-
scale_fitted: float = fitted * max_fpkm / max_fitted
453-
to_concat.append(pd.DataFrame({"sample_name": name, "log2fpkm": x, "fpkm_density": y, "fitted_density_scaled": scale_fitted}))
452+
scale_fitted: float = fitted * fpkm_at_mu / max_fitted
453+
to_concat.append(pd.DataFrame({"sample_name": name, "log2fpkm": x, "fpkm_density": y, "zfpkm_density": scale_fitted}))
454454

455455
mega_df = pd.concat(to_concat, ignore_index=True)
456-
mega_df.columns = pd.Series(data=["sample_name", "log2fpkm", "fpkm_density", "fitted_density_scaled"])
456+
mega_df.columns = pd.Series(data=["sample_name", "log2fpkm", "fpkm_density", "zfpkm_density"])
457457
mega_df = mega_df.melt(id_vars=["log2fpkm", "sample_name"], var_name="source", value_name="density")
458458

459459
fig: plt.Figure

0 commit comments

Comments
 (0)