cellxgene_ontology_guide.entities
1from collections import Counter 2from enum import Enum 3from typing import Any, Dict, List 4 5 6class Ontology(Enum): 7 """ 8 Enum for the set of ontologies supported by CZ CellXGene. 9 """ 10 11 CL = "cl" 12 EFO = "efo" 13 MONDO = "mondo" 14 UBERON = "uberon" 15 HANCESTRO = "hancestro" 16 HsapDv = "hsapdv" 17 MmusDv = "mmusdv" 18 PATO = "pato" 19 NCBITaxon = "ncbitaxon" 20 FBbt = "fbbt" 21 FBdv = "fbdv" 22 ZFA = "zfa" 23 WBbt = "wbbt" 24 WBls = "wbls" 25 26 27class CuratedOntologyTermList(Enum): 28 """ 29 Enum for the set of curated ontology term lists supported by CZ CellXGene 30 """ 31 32 CELL_CLASS = "cell_class" 33 CELL_SUBCLASS = "cell_subclass" 34 ORGAN = "organ" 35 SYSTEM = "system" 36 TISSUE_GENERAL = "tissue_general" 37 UBERON_DEVELOPMENT_STAGE = "uberon_development_stage" 38 39 40class OntologyNode: 41 """ 42 Class to represent an ontology term and its subclasses 43 """ 44 45 def __init__(self, term_id: str, name: str): 46 self._term_id = term_id 47 self._name = name 48 self._children: List["OntologyNode"] = [] 49 self._term_counter: Counter[str] = Counter({self.term_id: 1}) 50 51 @property 52 def term_id(self) -> str: 53 """ 54 Ontology term ID represented by this OntologyNode. 55 """ 56 return self._term_id 57 58 @property 59 def name(self) -> str: 60 """ 61 Human-readable label for ontology term represented by this OntologyNode. 62 """ 63 return self._name 64 65 @property 66 def children(self) -> List["OntologyNode"]: 67 """ 68 List of children OntologyNode of this OntologyNode. 69 """ 70 return self._children 71 72 @property 73 def term_counter(self) -> Counter[str]: 74 """ 75 Mapping of unique ontology term ID descendants of this OntologyNode to the number of times each term 76 appears in the graph rooted at this node. 77 :return: 78 """ 79 return self._term_counter 80 81 def add_child(self, child: "OntologyNode") -> None: 82 self._children.append(child) 83 self._term_counter.update(child.term_counter) 84 85 def to_dict(self) -> Dict[str, Any]: 86 return { 87 "term_id": self.term_id, 88 "name": self.name, 89 "children": [child.to_dict() for child in self.children], 90 }
class
Ontology(enum.Enum):
7class Ontology(Enum): 8 """ 9 Enum for the set of ontologies supported by CZ CellXGene. 10 """ 11 12 CL = "cl" 13 EFO = "efo" 14 MONDO = "mondo" 15 UBERON = "uberon" 16 HANCESTRO = "hancestro" 17 HsapDv = "hsapdv" 18 MmusDv = "mmusdv" 19 PATO = "pato" 20 NCBITaxon = "ncbitaxon" 21 FBbt = "fbbt" 22 FBdv = "fbdv" 23 ZFA = "zfa" 24 WBbt = "wbbt" 25 WBls = "wbls"
Enum for the set of ontologies supported by CZ CellXGene.
CL =
<Ontology.CL: 'cl'>
EFO =
<Ontology.EFO: 'efo'>
MONDO =
<Ontology.MONDO: 'mondo'>
UBERON =
<Ontology.UBERON: 'uberon'>
HANCESTRO =
<Ontology.HANCESTRO: 'hancestro'>
HsapDv =
<Ontology.HsapDv: 'hsapdv'>
MmusDv =
<Ontology.MmusDv: 'mmusdv'>
PATO =
<Ontology.PATO: 'pato'>
NCBITaxon =
<Ontology.NCBITaxon: 'ncbitaxon'>
FBbt =
<Ontology.FBbt: 'fbbt'>
FBdv =
<Ontology.FBdv: 'fbdv'>
ZFA =
<Ontology.ZFA: 'zfa'>
WBbt =
<Ontology.WBbt: 'wbbt'>
WBls =
<Ontology.WBls: 'wbls'>
class
CuratedOntologyTermList(enum.Enum):
28class CuratedOntologyTermList(Enum): 29 """ 30 Enum for the set of curated ontology term lists supported by CZ CellXGene 31 """ 32 33 CELL_CLASS = "cell_class" 34 CELL_SUBCLASS = "cell_subclass" 35 ORGAN = "organ" 36 SYSTEM = "system" 37 TISSUE_GENERAL = "tissue_general" 38 UBERON_DEVELOPMENT_STAGE = "uberon_development_stage"
Enum for the set of curated ontology term lists supported by CZ CellXGene
CELL_CLASS =
<CuratedOntologyTermList.CELL_CLASS: 'cell_class'>
CELL_SUBCLASS =
<CuratedOntologyTermList.CELL_SUBCLASS: 'cell_subclass'>
ORGAN =
<CuratedOntologyTermList.ORGAN: 'organ'>
SYSTEM =
<CuratedOntologyTermList.SYSTEM: 'system'>
TISSUE_GENERAL =
<CuratedOntologyTermList.TISSUE_GENERAL: 'tissue_general'>
UBERON_DEVELOPMENT_STAGE =
<CuratedOntologyTermList.UBERON_DEVELOPMENT_STAGE: 'uberon_development_stage'>
class
OntologyNode:
41class OntologyNode: 42 """ 43 Class to represent an ontology term and its subclasses 44 """ 45 46 def __init__(self, term_id: str, name: str): 47 self._term_id = term_id 48 self._name = name 49 self._children: List["OntologyNode"] = [] 50 self._term_counter: Counter[str] = Counter({self.term_id: 1}) 51 52 @property 53 def term_id(self) -> str: 54 """ 55 Ontology term ID represented by this OntologyNode. 56 """ 57 return self._term_id 58 59 @property 60 def name(self) -> str: 61 """ 62 Human-readable label for ontology term represented by this OntologyNode. 63 """ 64 return self._name 65 66 @property 67 def children(self) -> List["OntologyNode"]: 68 """ 69 List of children OntologyNode of this OntologyNode. 70 """ 71 return self._children 72 73 @property 74 def term_counter(self) -> Counter[str]: 75 """ 76 Mapping of unique ontology term ID descendants of this OntologyNode to the number of times each term 77 appears in the graph rooted at this node. 78 :return: 79 """ 80 return self._term_counter 81 82 def add_child(self, child: "OntologyNode") -> None: 83 self._children.append(child) 84 self._term_counter.update(child.term_counter) 85 86 def to_dict(self) -> Dict[str, Any]: 87 return { 88 "term_id": self.term_id, 89 "name": self.name, 90 "children": [child.to_dict() for child in self.children], 91 }
Class to represent an ontology term and its subclasses
term_id: str
52 @property 53 def term_id(self) -> str: 54 """ 55 Ontology term ID represented by this OntologyNode. 56 """ 57 return self._term_id
Ontology term ID represented by this OntologyNode.
name: str
59 @property 60 def name(self) -> str: 61 """ 62 Human-readable label for ontology term represented by this OntologyNode. 63 """ 64 return self._name
Human-readable label for ontology term represented by this OntologyNode.
children: List[OntologyNode]
66 @property 67 def children(self) -> List["OntologyNode"]: 68 """ 69 List of children OntologyNode of this OntologyNode. 70 """ 71 return self._children
List of children OntologyNode of this OntologyNode.
term_counter: collections.Counter[str]
73 @property 74 def term_counter(self) -> Counter[str]: 75 """ 76 Mapping of unique ontology term ID descendants of this OntologyNode to the number of times each term 77 appears in the graph rooted at this node. 78 :return: 79 """ 80 return self._term_counter
Mapping of unique ontology term ID descendants of this OntologyNode to the number of times each term appears in the graph rooted at this node.