|
10 | 10 | from backend.cellguide.pipeline.constants import CELLGUIDE_PIPELINE_NUM_CPUS |
11 | 11 | from backend.cellguide.pipeline.ontology_tree.types import OntologyTree, OntologyTreeState |
12 | 12 | from backend.common.census_cube.data.ontology_labels import ontology_term_label |
13 | | -from backend.common.census_cube.utils import ontology_parser, rollup_across_cell_type_descendants, to_dict |
| 13 | +from backend.common.census_cube.utils import ( |
| 14 | + ancestors, |
| 15 | + descendants, |
| 16 | + ontology_parser, |
| 17 | + rollup_across_cell_type_descendants, |
| 18 | + to_dict, |
| 19 | +) |
14 | 20 |
|
15 | 21 | logger = logging.getLogger(__name__) |
16 | 22 |
|
@@ -88,7 +94,7 @@ def __init__(self, cell_counts_df, root_node="CL:0000000"): |
88 | 94 |
|
89 | 95 | logger.info("Initializing cell type data structures from the input cell counts dataframe...") |
90 | 96 |
|
91 | | - self.all_cell_type_ids = self.ontology.get_term_descendants(root_node, include_self=True) |
| 97 | + self.all_cell_type_ids = descendants(root_node) |
92 | 98 |
|
93 | 99 | self.cell_counts_df, self.cell_counts_df_rollup = self._initialize_cell_counts_df_rollup(cell_counts_df) |
94 | 100 | self.all_cell_type_ids_in_corpus = self.cell_counts_df_rollup.index.values[ |
@@ -392,15 +398,13 @@ def _process_tissue__parallel(self, tissueId: str) -> OntologyTreeState: |
392 | 398 | """ |
393 | 399 | end_nodes = self.uberon_by_celltype[tissueId] |
394 | 400 | tissue_label = ontology_term_label(tissueId) |
395 | | - uberon_ancestors = self.ontology.get_term_ancestors(tissueId, include_self=True) |
| 401 | + uberon_ancestors = ancestors(tissueId) |
396 | 402 |
|
397 | 403 | # filter out hemaotoietic cell types from non-whitelisted tissues |
398 | 404 | uberon_ancestors_in_whitelist = list(set(TISSUES_IMMUNE_CELL_WHITELIST).intersection(uberon_ancestors)) |
399 | 405 | if len(uberon_ancestors_in_whitelist) == 0: |
400 | 406 | end_nodes_that_are_not_hematopoietic = [ |
401 | | - e |
402 | | - for e in end_nodes |
403 | | - if HEMATOPOIETIC_CELL_TYPE_ID not in self.ontology.get_term_ancestors(e, include_self=True) |
| 407 | + e for e in end_nodes if HEMATOPOIETIC_CELL_TYPE_ID not in ancestors(e) |
404 | 408 | ] |
405 | 409 | if len(end_nodes_that_are_not_hematopoietic) == 0: |
406 | 410 | logger.info(f"Not filtering out immune cell for {tissue_label}") |
|
0 commit comments