Skip to content

Commit 58a7e3e

Browse files
committed
Small fix
1 parent 085183e commit 58a7e3e

File tree

2 files changed

+9
-27
lines changed

2 files changed

+9
-27
lines changed

orangecontrib/single_cell/widgets/load_data.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -488,18 +488,10 @@ def leading_cols(self, value):
488488

489489
def _set_annotation_files(self):
490490
dir_name, _ = os.path.split(self._file_name)
491-
genes_paths = ['genes.tsv', 'features.tsv', 'genes.tsv.gz', 'features.tsv.gz']
492-
for genes_path in genes_paths:
493-
genes_path = os.path.join(dir_name, genes_path)
494-
if os.path.isfile(genes_path):
495-
self.col_annotation_file = RecentPath.create(genes_path, [])
496-
break
497-
barcodes_paths = ['barcodes.tsv', 'barcodes.tsv.gz']
498-
for barcodes_path in barcodes_paths:
499-
barcodes_path = os.path.join(dir_name, barcodes_path)
500-
if os.path.isfile(barcodes_path):
501-
self.row_annotation_file = RecentPath.create(barcodes_path, [])
502-
break
491+
genes_path = os.path.join(dir_name, "genes.tsv")
492+
if os.path.isfile(genes_path):
493+
self.col_annotation_file = RecentPath.create(genes_path, [])
494+
barcodes_path = os.path.join(dir_name, "barcodes.tsv")
503495
if os.path.isfile(barcodes_path):
504496
self.row_annotation_file = RecentPath.create(barcodes_path, [])
505497

@@ -764,21 +756,13 @@ def key(var):
764756
metas=sorted(metas, key=key))
765757
concat_data_t = concat_data.transform(domain)
766758
data_t = data.transform(domain)
767-
768-
new_values = source_var.values + (source_name,)
769-
new_source_var = DiscreteVariable(source_var.name, values=new_values)
770-
new_metas = tuple(var if var.name != source_var.name else new_source_var for var in domain.metas)
771-
new_domain = Domain(domain.attributes, metas=new_metas)
772-
concat_data_t = concat_data_t.transform(new_domain)
773-
data_t = data_t.transform(new_domain)
774-
source_var_index = new_source_var.values.index(source_name)
759+
source_var.values + (source_name, )
775760
# metas can be unlocked, source_var added to metas by append_source_name
776761
with data_t.unlocked(data_t.metas):
777-
data_t[:, new_source_var] = np.full(
778-
(len(data_t), 1), source_var_index, dtype=object
762+
data_t[:, source_var] = np.full(
763+
(len(data), 1), len(source_var.values) - 1, dtype=object
779764
)
780765
concat_data = Table.concatenate((concat_data_t, data_t), axis=0)
781-
source_var = new_source_var # Update source_var for the next iteration
782766
return concat_data
783767

784768
@staticmethod
@@ -791,4 +775,4 @@ def append_source_name(data, name):
791775
# since we added new column to metas
792776
with data.unlocked(data.metas):
793777
data[:, source_var] = np.full((len(data), 1), 0, dtype=object)
794-
return data, source_var
778+
return data, source_var

orangecontrib/single_cell/widgets/owloaddata.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ def browse_row_annotations(self):
613613
pathitem = RecentPath.create(filename, [])
614614
index = insert_recent_path(m, pathitem)
615615
self.row_annotations_combo.setCurrentIndex(index)
616-
self._row_annotations_combo_changed()
617616
self._invalidate()
618617

619618
@Slot()
@@ -633,7 +632,6 @@ def browse_col_annotations(self):
633632
pathitem = RecentPath.create(filename, [])
634633
index = insert_recent_path(m, pathitem)
635634
self.col_annotations_combo.setCurrentIndex(index)
636-
self._col_annotations_combo_changed()
637635
self._invalidate()
638636

639637
def _invalidate(self):
@@ -717,4 +715,4 @@ def main(argv=None):
717715

718716

719717
if __name__ == "__main__":
720-
sys.exit(main(sys.argv))
718+
sys.exit(main(sys.argv))

0 commit comments

Comments
 (0)