eds_scikit.phenotype.base
Features
Features()
Class used to store features (i.e. DataFrames). Features are stored in the self._features dictionary.
Source code in eds_scikit/phenotype/base.py
22 23 24 |
|
Phenotype
Phenotype(data: BaseData, name: Optional[str] = None, **kwargs)
Base class for phenotyping
PARAMETER | DESCRIPTION |
---|---|
data |
A BaseData object
TYPE:
|
name |
Name of the phenotype. If left to None, the name of the class will be used instead
TYPE:
|
Source code in eds_scikit/phenotype/base.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
add_code_feature
add_code_feature(output_feature: str, codes: dict, source: str = 'icd10', additional_filtering: Optional[dict] = None)
Adds a feature from either ICD10 or CCAM codes
PARAMETER | DESCRIPTION |
---|---|
output_feature |
Name of the feature
TYPE:
|
codes |
Dictionary of codes to provide to the
TYPE:
|
source |
Either 'icd10' or 'ccam', by default 'icd10'
TYPE:
|
additional_filtering |
Dictionary passed to the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Phenotype
|
The current Phenotype object with an additional feature stored in self.features[output_feature] |
Source code in eds_scikit/phenotype/base.py
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 142 143 144 145 146 147 148 |
|
agg_single_feature
agg_single_feature(input_feature: str, output_feature: Optional[str] = None, level: str = 'patient', subphenotype: bool = True, threshold: int = 1) -> Phenotype
Simple aggregation rule on a feature:
- If level="patient", keeps patients with at least
threshold
visits showing the (sub)phenotype - If level="visit", keeps visits with at least
threshold
events (could be ICD10 codes, NLP features, biology, etc) showing the (sub)phenotype
PARAMETER | DESCRIPTION |
---|---|
input_feature |
Name of the input feature
TYPE:
|
output_feature |
Name of the input feature. If None, will be set to input_feature + "_agg"
TYPE:
|
level |
On which level to do the aggregation, either "patient" or "visit"
TYPE:
|
subphenotype |
Whether the threshold should apply to the phenotype ("phenotype" column) of the subphenotype ("subphenotype" column)
TYPE:
|
threshold |
Minimal number of events (which definition depends on the
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Phenotype
|
The current Phenotype object with an additional feature stored in self.features[output_feature] |
Source code in eds_scikit/phenotype/base.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
agg_two_features
agg_two_features(input_feature_1: str, input_feature_2: str, output_feature: str = None, how: str = 'AND', level: str = 'patient', subphenotype: bool = True, thresholds: Tuple[int, int] = (1, 1)) -> Phenotype
-
If level='patient', keeps a specific patient if
- At least
thresholds[0]
visits are found in feature_1 AND/OR - At least
thresholds[1]
visits are found in feature_2
- At least
-
If level='visit', keeps a specific visit if
- At least
thresholds[0]
events are found in feature_1 AND/OR - At least
thresholds[1]
events are found in feature_2
- At least
PARAMETER | DESCRIPTION |
---|---|
input_feature_1 |
Name of the first input feature
TYPE:
|
input_feature_2 |
Name of the second input feature
TYPE:
|
output_feature |
Name of the input feature. If None, will be set to input_feature + "_agg"
TYPE:
|
how |
Whether to perform a boolean "AND" or "OR" aggregation
TYPE:
|
level |
On which level to do the aggregation, either "patient" or "visit"
TYPE:
|
subphenotype |
Whether the threshold should apply to the phenotype ("phenotype" column) of the subphenotype ("subphenotype" column)
TYPE:
|
thresholds |
Repsective threshold for the first and second feature
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Phenotype
|
The current Phenotype object with an additional feature stored in self.features[output_feature] |
Source code in eds_scikit/phenotype/base.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
|
compute
compute(**kwargs)
Fetch all necessary features and perform aggregation
Source code in eds_scikit/phenotype/base.py
325 326 327 328 329 |
|
to_data
to_data(key: Optional[str] = None) -> BaseData
Appends the feature found in self.features[key] to the data object. If no key is provided, uses the last added feature
PARAMETER | DESCRIPTION |
---|---|
key |
Key of the self.feature dictionary
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BaseData
|
The data object with phenotype added to |
Source code in eds_scikit/phenotype/base.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
to_valid_variable_name
to_valid_variable_name(s: str)
Converts a string to a valid variable name
Source code in eds_scikit/phenotype/base.py
415 416 417 418 419 420 421 422 423 424 425 426 |
|