@@ -92,10 +92,6 @@ def generate_result_files(self, col, genes, rest, groups, clean_val, qual):
9292
9393 Then final format should have type 0 type 1 in the title, and genes, logfoldchanges, qval, and mean as columns
9494 """
95- # for i in clean_val:
96- # val_to_sort = [i[0], i[1]]
97- # sorted_list = sort_comparison(val_to_sort)
98- # i[0], i[1] = sorted_list
9995
10096 names_dict = {}
10197 all_group = []
@@ -153,6 +149,12 @@ def generate_result_files(self, col, genes, rest, groups, clean_val, qual):
153149 if "rest" in i :
154150 i = i .split ("--" )[0 ]
155151
152+ else :
153+ first_group = i .split ("--" )[0 ]
154+ second_group = i .split ("--" )[1 ]
155+ sorted_list = sort_comparison ([first_group , second_group ])
156+ i = f'{ sorted_list [0 ]} --{ sorted_list [1 ]} '
157+
156158 comparison = '--' .join ([DifferentialExpression .sanitize_strings (group ) for group in i .split ('--' )])
157159
158160 tsv_name = f'{ self .stem } --{ comparison } --{ self .annot_scope } --{ self .method } .tsv'
@@ -287,11 +289,12 @@ def check_group(names_dict, name):
287289def sort_comparison (ls ):
288290 """
289291 Naturally sort groups in a pairwise comparison; specially handle one-vs-rest
290- this should take in only a list of two, ex (type1 type2)
292+ this should take in a list of groups, such as ['B cells', 'CSN1S1 macrophages']
291293
292294 https://en.wikipedia.org/wiki/Natural_sort_order
293295
294296 """
297+
295298 if any (i .isdigit () for i in ls ):
296299 sorted_arr = sorted (ls , key = lambda x : int ("" .join ([i for i in x if i .isdigit ()])))
297300 return sorted_arr
0 commit comments