Skip to content

Commit d78ea79

Browse files
authored
Merge pull request #348 from lenatr99/dictybase-genes
Marker Genes: Add DictyBase.
2 parents 01c18df + 8003344 commit d78ea79

File tree

3 files changed

+48
-13
lines changed

3 files changed

+48
-13
lines changed

doc/widgets/marker_genes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ Database sources:
1919
- CellMarker
2020

2121
<cite>[CellMarker: a manually curated resource of cell markers in human and mouse.][1] Nucleic Acids Research. 2018.</cite>
22+
23+
</br>
24+
25+
- DictyBase
26+
27+
<cite>Fey, P., Dodson, R., Basu, S., Chisholm, R. L., One Stop Shop for Everything Dictyostelium: dictyBase and the Dicty Stock Center. Dictyostelium discoideum Protocols. Methods Mol. Biol. 983:59-92, edited by Ludwig Eichinger and Francisco Rivero.</cite>
2228

2329

2430
Data is preprocessed in Orange readable format and it is hosted [here.][2] One can use [Databases update](databases_update.md)

orangecontrib/bioinformatics/tests/widgets/test_OWMarkerGenes.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ def test_available_sources(self):
306306
When more available unittest will be changed.
307307
"""
308308
self.assertListEqual(
309-
["CellMarker", "Panglao"], list(self.widget.available_sources.keys())
309+
["CellMarker", "DictyBase", "Panglao"],
310+
list(self.widget.available_sources.keys()),
310311
)
311312

312313
def test_source_changed(self):
@@ -319,7 +320,7 @@ def test_source_changed(self):
319320
self.assertEqual(len(self.panglao), len(self.widget.data))
320321

321322
# Panglao data
322-
simulate.combobox_activate_index(self.widget.controls.source_index, 1)
323+
simulate.combobox_activate_index(self.widget.controls.source_index, 2)
323324
self.assertEqual("CellMarker", self.widget.db_source_cb.currentText())
324325
self.assertTrue(isinstance(self.widget.data, Table))
325326
self.assertEqual(len(self.cell_markers), len(self.widget.data))
@@ -363,7 +364,7 @@ def test_organism_changed(self):
363364
len(np.unique(cell_types[~human_rows])), len(model.rootItem.childItems)
364365
)
365366

366-
simulate.combobox_activate_index(self.widget.controls.source_index, 1)
367+
simulate.combobox_activate_index(self.widget.controls.source_index, 2)
367368
simulate.combobox_activate_index(self.widget.controls.organism_index, 0)
368369
self.assertEqual("CellMarker", self.widget.db_source_cb.currentText())
369370
self.assertEqual("Human", self.widget.group_cb.currentText())
@@ -379,7 +380,7 @@ def test_organism_changed(self):
379380
len(np.unique(cell_types[human_rows])), len(model.rootItem.childItems)
380381
)
381382

382-
simulate.combobox_activate_index(self.widget.controls.source_index, 1)
383+
simulate.combobox_activate_index(self.widget.controls.source_index, 2)
383384
simulate.combobox_activate_index(self.widget.controls.organism_index, 1)
384385
self.assertEqual("CellMarker", self.widget.db_source_cb.currentText())
385386
self.assertEqual("Mouse", self.widget.group_cb.currentText())

orangecontrib/bioinformatics/widgets/OWMarkerGenes.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
""" OWMarkerGenes """
2+
23
from typing import List, Tuple, Iterable, Optional
34
from functools import partial
45

@@ -41,10 +42,14 @@
4142
)
4243

4344
SERVER_FILES_DOMAIN = 'marker_genes'
44-
GROUP_BY_ITEMS = ["Cell Type", "Function"]
45+
GROUP_BY_ITEMS = ["Cell Type", "Function", "Milestones", "Regulon cluster"]
4546
FILTER_COLUMNS_DEFAULT = ["Name", "Entrez ID"]
4647
NUM_LINES_TEXT = 5
47-
MAP_GROUP_TO_TAX_ID = {'Human': '9606', 'Mouse': '10090'}
48+
MAP_GROUP_TO_TAX_ID = {
49+
'Human': '9606',
50+
'Mouse': '10090',
51+
"Dictyostelium discoideum": '44689',
52+
}
4853

4954

5055
class TreeItem(object):
@@ -655,10 +660,11 @@ def setup_model_data(
655660
names = data_table.get_column("Name")
656661
types = data_table.get_column(parent_column)
657662
for n, pt, row in zip(names, types, data_table):
658-
if pt not in parents_dict:
659-
parents_dict[pt] = TreeItem(pt, True, None, parent)
663+
if pt != "?":
664+
if pt not in parents_dict:
665+
parents_dict[pt] = TreeItem(pt, True, None, parent)
660666

661-
TreeItem(n, False, row, parents_dict[pt])
667+
TreeItem(n, False, row, parents_dict[pt])
662668

663669
def set_expanded(self, index: QModelIndex, expanded: bool) -> None:
664670
"""
@@ -854,8 +860,12 @@ class Outputs:
854860

855861
settings_version = 2
856862

863+
available_groups = GROUP_BY_ITEMS
864+
_available_groups = None
865+
857866
_data = None
858867
_available_sources = None
868+
_selected_root_attribute = None
859869

860870
def __init__(self) -> None:
861871
super().__init__()
@@ -937,7 +947,6 @@ def _init_control_area(self) -> None:
937947
box,
938948
self,
939949
'selected_root_attribute',
940-
items=GROUP_BY_ITEMS,
941950
callback=self._setup,
942951
)
943952

@@ -1018,6 +1027,16 @@ def data(self, value: Table):
10181027
max(self.organism_index, 0), len(group_values) - 1
10191028
)
10201029

1030+
self.available_groups = [
1031+
item
1032+
for item in GROUP_BY_ITEMS
1033+
if any(meta.name == item for meta in domain.metas)
1034+
]
1035+
1036+
self.group_by_cb.clear()
1037+
self.group_by_cb.addItems(self.available_groups)
1038+
self.group_by_cb.setCurrentIndex(self.selected_root_attribute)
1039+
10211040
self._set_group_index(self.organism_index)
10221041

10231042
def _load_data(self) -> None:
@@ -1068,8 +1087,15 @@ def _setup(self) -> None:
10681087
self.openContext((self.selected_organism, self.selected_source))
10691088
data_not_selected, data_selected = self._filter_data_group(self.data)
10701089

1090+
if self._available_groups:
1091+
if (
1092+
self._available_groups[self._selected_root_attribute]
1093+
not in self.available_groups
1094+
):
1095+
self.selected_root_attribute = 0
1096+
10711097
# add model to available markers view
1072-
group_by = GROUP_BY_ITEMS[self.selected_root_attribute]
1098+
group_by = self.available_groups[self.selected_root_attribute]
10731099
tree_model = TreeModel(data_not_selected, group_by)
10741100
proxy_model = FilterProxyModel(self.filter_line_edit)
10751101
proxy_model.setSourceModel(tree_model)
@@ -1096,6 +1122,8 @@ def _setup(self) -> None:
10961122

10971123
# update output and messages
10981124
self._selected_markers_changed()
1125+
self._selected_root_attribute = self.selected_root_attribute
1126+
self._available_groups = self.available_groups
10991127

11001128
def _filter_data_group(self, data: Table) -> Tuple[Table, Tuple]:
11011129
"""
@@ -1126,7 +1154,7 @@ def _filter_data_group(self, data: Table) -> Tuple[Table, Tuple]:
11261154
# divide data based on selected_genes variable (context)
11271155
unique_gene_names = np.core.defchararray.add(
11281156
data.get_column("Entrez ID").astype(str),
1129-
data.get_column("Cell Type").astype(str),
1157+
data.get_column(self.available_groups[0]).astype(str),
11301158
)
11311159
mask = np.isin(unique_gene_names, self.selected_genes)
11321160
data_not_selected = data[~mask]
@@ -1184,7 +1212,7 @@ def _selected_markers_changed(self) -> None:
11841212
"""
11851213
rows = self.selected_markers_view.model().sourceModel().rootItem.get_data_rows()
11861214
self.selected_genes = [
1187-
row["Entrez ID"].value + row["Cell Type"].value for row in rows
1215+
row["Entrez ID"].value + row[self.available_groups[0]].value for row in rows
11881216
]
11891217
self.commit()
11901218

0 commit comments

Comments
 (0)