SimpleColumnMapperGenerator
Convenience tool to provide mappings automatically
Try to map the columns in a dataframe by matching the name of the column to correct HPO term. This class can be used to generate SimpleColumn mappers for exact matches found in the columns names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df
|
DataFrame
|
dataframe with phenotypic data |
required |
observed
|
str
|
symbol used in table if the phenotypic feature was observed |
required |
excluded
|
str
|
symbol used if the feature was excluded |
required |
hpo_cr
|
HpoConceptRecognizer
|
instance of HpoConceptRecognizer to match HPO term and get label/id |
required |
Source code in pyphetools/creation/scm_generator.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
__init__(df, observed, excluded, hpo_cr)
Constructor
Source code in pyphetools/creation/scm_generator.py
from_map(column_name_to_hpo_label_map, observed='+', excluded='-')
staticmethod
Create SimpleColumnMapers from a map like this
items = { 'Developmental delay': ['Neurodevelopmental delay', 'HP:0012758'], 'Regression': ['Cognitive regression', 'HP:0034332'], 'Seizure': ['Seizure', 'HP:0001250'], }
The keys are column names in the original file, and the values are used for creating the corresponding HPO terms
Parameters:
Name | Type | Description | Default |
---|---|---|---|
(_type_)
|
column_name_to_hpo_label_map
|
map as described above |
required |
observed
|
Symbol used to indicate observed. Defaults to '+'. |
'+'
|
|
excluded
|
Symbol used to indicate excluded. Defaults to '+'. '-'. |
'-'
|
Returns:
Type | Description |
---|---|
List[SimpleColumnMapper]
|
list of SimpleColumnMapper |
Source code in pyphetools/creation/scm_generator.py
get_mapped_columns()
Returns:
Type | Description |
---|---|
List[str]
|
A list of names of the columns that were mapped |
get_unmapped_columns()
Returns:
Type | Description |
---|---|
List[str]
|
A list of names of the columns that could not be mapped |
to_html()
create an HTML table with names of mapped and unmapped columns
Source code in pyphetools/creation/scm_generator.py
try_mapping_columns()
As a side effect, this class initializes three lists of mapped, unmapped, and error columns
Returns:
Type | Description |
---|---|
Dict[str,ColumnMapper]
|
A dictionary with successfully mapped columns |