diff --git a/orangecontrib/single_cell/widgets/load_data.py b/orangecontrib/single_cell/widgets/load_data.py index 6018382..530405b 100644 --- a/orangecontrib/single_cell/widgets/load_data.py +++ b/orangecontrib/single_cell/widgets/load_data.py @@ -488,10 +488,18 @@ def leading_cols(self, value): def _set_annotation_files(self): dir_name, _ = os.path.split(self._file_name) - genes_path = os.path.join(dir_name, "genes.tsv") - if os.path.isfile(genes_path): - self.col_annotation_file = RecentPath.create(genes_path, []) - barcodes_path = os.path.join(dir_name, "barcodes.tsv") + genes_paths = ['genes.tsv', 'features.tsv', 'genes.tsv.gz', 'features.tsv.gz'] + for genes_path in genes_paths: + genes_path = os.path.join(dir_name, genes_path) + if os.path.isfile(genes_path): + self.col_annotation_file = RecentPath.create(genes_path, []) + break + barcodes_paths = ['barcodes.tsv', 'barcodes.tsv.gz'] + for barcodes_path in barcodes_paths: + barcodes_path = os.path.join(dir_name, barcodes_path) + if os.path.isfile(barcodes_path): + self.row_annotation_file = RecentPath.create(barcodes_path, []) + break if os.path.isfile(barcodes_path): self.row_annotation_file = RecentPath.create(barcodes_path, []) @@ -756,13 +764,21 @@ def key(var): metas=sorted(metas, key=key)) concat_data_t = concat_data.transform(domain) data_t = data.transform(domain) - source_var.values + (source_name, ) + + new_values = source_var.values + (source_name,) + new_source_var = DiscreteVariable(source_var.name, values=new_values) + new_metas = tuple(var if var.name != source_var.name else new_source_var for var in domain.metas) + new_domain = Domain(domain.attributes, metas=new_metas) + concat_data_t = concat_data_t.transform(new_domain) + data_t = data_t.transform(new_domain) + source_var_index = new_source_var.values.index(source_name) # metas can be unlocked, source_var added to metas by append_source_name with data_t.unlocked(data_t.metas): - data_t[:, source_var] = np.full( - (len(data), 1), len(source_var.values) - 1, dtype=object + data_t[:, new_source_var] = np.full( + (len(data_t), 1), source_var_index, dtype=object ) concat_data = Table.concatenate((concat_data_t, data_t), axis=0) + source_var = new_source_var # Update source_var for the next iteration return concat_data @staticmethod diff --git a/orangecontrib/single_cell/widgets/owloaddata.py b/orangecontrib/single_cell/widgets/owloaddata.py index db82f20..ab38d6a 100644 --- a/orangecontrib/single_cell/widgets/owloaddata.py +++ b/orangecontrib/single_cell/widgets/owloaddata.py @@ -613,6 +613,7 @@ def browse_row_annotations(self): pathitem = RecentPath.create(filename, []) index = insert_recent_path(m, pathitem) self.row_annotations_combo.setCurrentIndex(index) + self._row_annotations_combo_changed() self._invalidate() @Slot() @@ -632,6 +633,7 @@ def browse_col_annotations(self): pathitem = RecentPath.create(filename, []) index = insert_recent_path(m, pathitem) self.col_annotations_combo.setCurrentIndex(index) + self._col_annotations_combo_changed() self._invalidate() def _invalidate(self):