Skip to content

Commit

Permalink
fix: Fix issue with forward-only in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianMichelsen committed May 4, 2022
1 parent cc18f9d commit 7d5310f
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/metaDMG/viz/results.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#%%
import warnings
from pathlib import Path

Expand Down Expand Up @@ -59,14 +60,19 @@ def wide_to_long_df(group_wide):
direction="Forward",
)

group_long_reverse = pd_wide_to_long_forward_reverse(
group_wide,
sep="-",
direction="Reverse",
)
try:
group_long_reverse = pd_wide_to_long_forward_reverse(
group_wide,
sep="-",
direction="Reverse",
)

group_long = pd.concat([group_long_forward, group_long_reverse])
# group_long.loc[:, ["k", "N"]] = group_long.loc[:, ["k", "N"]].astype(int)

group_long = pd.concat([group_long_forward, group_long_reverse])
# group_long.loc[:, ["k", "N"]] = group_long.loc[:, ["k", "N"]].astype(int)
# happens when forward only
except ValueError:
group_long = group_long_forward

group_long["sample"] = group_wide["sample"].iloc[0]

Expand Down Expand Up @@ -107,7 +113,11 @@ def correct_for_non_LCA(df):

def compute_variance_scaling(df, phi_string):
phi = df[phi_string]
N = np.mean([df["N_x=1_forward"], df["N_x=1_reverse"]])
if "N_x=1_reverse" in df.columns:
N_x = [df["N_x=1_forward"], df["N_x=1_reverse"]]
else:
N_x = [df["N_x=1_forward"]]
N = np.mean(N_x)
return (phi + N) / (phi + 1)


Expand Down

0 comments on commit 7d5310f

Please sign in to comment.