From 021b22dc1f741c4446ab3d80371b63f09e005ff4 Mon Sep 17 00:00:00 2001 From: Michelle Velyunskiy Date: Wed, 28 Jun 2023 12:48:08 -0500 Subject: [PATCH 1/3] fixed sorting issue --- ingest/author_de.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ingest/author_de.py b/ingest/author_de.py index bdce0c08..60ebb4ac 100644 --- a/ingest/author_de.py +++ b/ingest/author_de.py @@ -81,10 +81,10 @@ def generate_result_files(self, col, genes, rest, groups, clean_val, qual): Then final format should have type 0 type 1 in the title, and genes, logfoldchanges, qval, and mean as columns """ - # for i in clean_val: - # val_to_sort = [i[0], i[1]] - # sorted_list = sort_comparison(val_to_sort) - # i[0], i[1] = sorted_list + #for i in clean_val: + # val_to_sort = [i[0], i[1]] + # sorted_list = sort_comparison(val_to_sort) + # i[0], i[1] = sorted_list names_dict = {} all_group = [] @@ -142,6 +142,12 @@ def generate_result_files(self, col, genes, rest, groups, clean_val, qual): if "rest" in i: i = i.split("--")[0] + else: + first_group = i.split("--")[0] + second_group = i.split("--")[1] + sorted_list = sort_comparison([first_group, second_group]) + i = f'{sorted_list[0]}--{sorted_list[1]}' + comparison = '--'.join([DifferentialExpression.sanitize_strings(group) for group in i.split('--')]) tsv_name = f'{self.stem}--{comparison}--{self.annot_scope}--{self.method}.tsv' @@ -276,11 +282,12 @@ def check_group(names_dict, name): def sort_comparison(ls): """ Naturally sort groups in a pairwise comparison; specially handle one-vs-rest - this should take in only a list of two, ex (type1 type2) + this should take in a combined name, such as B cells--CSN1S1 macrophages https://en.wikipedia.org/wiki/Natural_sort_order """ + if any(i.isdigit() for i in ls): sorted_arr = sorted(ls, key=lambda x: int("".join([i for i in x if i.isdigit()]))) return sorted_arr From c3ecd6bf87352037bb1260699dc0c2b69b7c1ec8 Mon Sep 17 00:00:00 2001 From: michelle-vel Date: Wed, 28 Jun 2023 14:23:19 -0500 Subject: [PATCH 2/3] Update ingest/author_de.py Co-authored-by: Eric Weitz --- ingest/author_de.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ingest/author_de.py b/ingest/author_de.py index 60ebb4ac..6dbc460b 100644 --- a/ingest/author_de.py +++ b/ingest/author_de.py @@ -282,7 +282,7 @@ def check_group(names_dict, name): def sort_comparison(ls): """ Naturally sort groups in a pairwise comparison; specially handle one-vs-rest - this should take in a combined name, such as B cells--CSN1S1 macrophages + this should take in a list of groups, such as ['B cells', 'CSN1S1 macrophages'] https://en.wikipedia.org/wiki/Natural_sort_order From c0dd940b6b909673810810890b0ae8e819e2c9b0 Mon Sep 17 00:00:00 2001 From: michelle-vel Date: Wed, 28 Jun 2023 14:23:27 -0500 Subject: [PATCH 3/3] Update ingest/author_de.py Co-authored-by: Eric Weitz --- ingest/author_de.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ingest/author_de.py b/ingest/author_de.py index 6dbc460b..4a6a0bce 100644 --- a/ingest/author_de.py +++ b/ingest/author_de.py @@ -81,10 +81,6 @@ def generate_result_files(self, col, genes, rest, groups, clean_val, qual): Then final format should have type 0 type 1 in the title, and genes, logfoldchanges, qval, and mean as columns """ - #for i in clean_val: - # val_to_sort = [i[0], i[1]] - # sorted_list = sort_comparison(val_to_sort) - # i[0], i[1] = sorted_list names_dict = {} all_group = []