From 6cae71060550d1081286d046f6069269a5e858bf Mon Sep 17 00:00:00 2001 From: jonbrenas <51911846+jonbrenas@users.noreply.github.com> Date: Fri, 24 May 2024 10:38:43 +0100 Subject: [PATCH 1/2] Changed the unique function used to avoid sorting --- malariagen_data/anoph/fst.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/malariagen_data/anoph/fst.py b/malariagen_data/anoph/fst.py index 695ab2203..bf0fd1112 100644 --- a/malariagen_data/anoph/fst.py +++ b/malariagen_data/anoph/fst.py @@ -493,7 +493,9 @@ def plot_pairwise_average_fst( **kwargs, ): # setup df - cohort_list = np.unique(fst_df[["cohort1", "cohort2"]].values) + cohort_list = pd.unique( + [c for cl in fst_df[["cohort1", "cohort2"]].values for c in cl] + ) # df to fill fig_df = pd.DataFrame(columns=cohort_list, index=cohort_list) # fill df from fst_df From 3622b972b9551843fd4c4d26ed787e46475ebce0 Mon Sep 17 00:00:00 2001 From: jonbrenas <51911846+jonbrenas@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:30:15 +0200 Subject: [PATCH 2/2] A line was missing and used flatten. --- malariagen_data/anoph/fst.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/malariagen_data/anoph/fst.py b/malariagen_data/anoph/fst.py index 8458afd09..a4f1654f6 100644 --- a/malariagen_data/anoph/fst.py +++ b/malariagen_data/anoph/fst.py @@ -492,9 +492,7 @@ def plot_pairwise_average_fst( **kwargs, ): # setup df - cohort_list = pd.unique( - [c for cl in fst_df[["cohort1", "cohort2"]].values for c in cl] - ) + cohort_list = pd.unique(fst_df[["cohort1", "cohort2"]].values.flatten()) # df to fill fig_df = pd.DataFrame(columns=cohort_list, index=cohort_list) # fill df from fst_df @@ -502,6 +500,7 @@ def plot_pairwise_average_fst( index = fst_df.iloc[index_key]["cohort1"] col = fst_df.iloc[index_key]["cohort2"] fst = fst_df.iloc[index_key]["fst"] + fig_df.loc[col, index] = fst if annotate_se is True: se = fst_df.iloc[index_key]["se"] fig_df.loc[index, col] = se