Skip to content

Commit

Permalink
add boxplots for rate and tmrca
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmeaton committed May 13, 2021
1 parent 6b03980 commit 4e0f6de
Show file tree
Hide file tree
Showing 2 changed files with 262 additions and 175 deletions.
11 changes: 7 additions & 4 deletions workflow/notebooks/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def linregress_bootstrap(
"x_intercept_peak": [],
"y_intercepts": [],
"p_value": p_value,
"r_squared": r_squared,
}

for _ in range(nboots):
Expand Down Expand Up @@ -475,6 +476,7 @@ def linregress_bootstrap(
)
bootstrap_dict["slope_peak"] = peak_slope
bootstrap_dict["slope_ci"] = slope_ci
bootstrap_dict["slope_kde"] = slope_kde

# Estimate a kernel density of the x_intercept/mrca
x_int_kde = sma.nonparametric.KDEUnivariate(bootstrap_dict["x_intercepts"])
Expand All @@ -491,6 +493,7 @@ def linregress_bootstrap(
x_int_ci_pretty = str([round(n) for n in x_int_ci]).strip("[]")
bootstrap_dict["x_intercept_peak"] = peak_x_int
bootstrap_dict["x_intercept_ci"] = x_int_ci
bootstrap_dict["x_intercept_kde"] = x_int_kde

if plot:

Expand All @@ -501,7 +504,7 @@ def linregress_bootstrap(
plt.rc("font", size=FONTSIZE)

fig, axes = plt.subplots(1, 3, figsize=FIGSIZE, dpi=DPI)
fig.subplots_adjust(wspace=0.25)
fig.subplots_adjust(wspace=0.40)
for ax in axes:
ax.ticklabel_format(axis="y", style="sci", scilimits=(0, 0))
for spine in ax.spines:
Expand Down Expand Up @@ -579,17 +582,17 @@ def linregress_bootstrap(
(
" Clade: {}".format(label)
+ "\n"
+ "\n R²: {}".format(round(r_squared, 2))
+ "\n R²: {}".format(round(bootstrap_dict["r_squared"], 2))
+ "\n"
+ "\n p: {:.2e}{}".format(p_value, p_sig)
+ "\n p: {:.2e}{}".format(bootstrap_dict["p_value"], p_sig)
+ "\n"
+ "\n Rate: {:.2e}".format(bootstrap_dict["slope_peak"])
+ "\n ({})".format(slope_ci_pretty,)
+ "\n"
+ "\nMRCA: {}".format(round(bootstrap_dict["x_intercept_peak"]))
+ "\n ({})".format(x_int_ci_pretty,)
),
xy=(-1, 0.5),
xy=(-1.15, 0.5),
xycoords="axes fraction",
size=5,
ha="left",
Expand Down
426 changes: 255 additions & 171 deletions workflow/notebooks/iqtree_stats.py.ipynb

Large diffs are not rendered by default.

0 comments on commit 4e0f6de

Please sign in to comment.