Statistical Modelling
Calculates differences in the probability distributions of each feature for the different classes. This is only available to supervised datasets (i.e. data must has class labels).
2 Classes for end user usage:
-
ClassificationStatModel For analysis when the target data is categorical (classification). Can only use two classes at a time (i.e., binary classification)
-
RegressionStatModel For analysis when the target data is continuous (regression).
These classes both inherit from a parent class called "_ProteinStatModel" which abstracts as much as their shared behavior as possible.
ClassificationStatModel
dataclass
Bases: _ProteinStatModel
Handles the generation of statistical models for PyContact data sets when the target is made up of two unqiue class labels.
Note that most attributes are inherited from _ProteinStatModel.
Attributes:
Name | Type | Description |
---|---|---|
dataset |
DataFrame
|
Input dataframe. |
class_names |
list
|
Class labels inside the column "Target" of the dataset to model. You can only use two classes for this approach. |
out_dir |
str
|
Directory path to store results files to. Default = "" |
interaction_types_included |
(list, optional)
|
What types of molecular interactions to generate the correlation matrix for. options are one or more of: ["Hbond", "Hydrophobic", "Saltbr", "Other"] Default is to include all 4 types. |
scaled_dataset |
DataFrame
|
Input dataset with all features scaled. |
feature_list |
list
|
List of all feature labels in the dataset. |
x_values |
ndarray
|
Values on the x-axis for plotting the kernel density estimations. |
kdes |
dict
|
Nested dictionary. Outer layer keys are class names, and values are a dictionary of each feature (as inner key) and values of a nested array of kernel density estimations (kdes). |
js_distances |
dict
|
Dictionary with each feature's (keys) and Jensen Shannon distance (values). Dictionary is sorted from largest Jensen Shannon distance to smallest. |
mutual_infos |
dict
|
Dictionary with each feature's (keys) and mutual informations (values). Dictionary is sorted from largest mutual information to smallest. |
Methods:
Name | Description |
---|---|
calc_mutual_info_to_target |
Calculate the mutual information between each feature to the target classes. |
calc_js_distances |
Calculate the Jensen-Shannon (JS) distance (metric) between each feature to the target classes. |
Source code in key_interactions_finder/stat_modelling.py
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 235 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 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
__post_init__()
Filter, rescale and calc the kdes for each feature.
Source code in key_interactions_finder/stat_modelling.py
calc_js_distances(kde_bandwidth=0.02, save_result=True)
Calculate the Jensen-Shannon (JS) distance (metric) between each feature to the target classes. Requires that each feature is described by a probabilty distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kde_bandwidth
|
Optional[float]
|
Bandwidth used to generate the probabilty distribtions for each feature set. Note that features are all scaled to be between 0 and 1 before this step. Optional, default = 0.02 |
0.02
|
save_result
|
Optional[bool] = True
|
Save result to disk or not. Optional, default is to save. |
True
|
Source code in key_interactions_finder/stat_modelling.py
calc_mutual_info_to_target(save_result=True)
Calculate the mutual information between each feature to the 2 target classes. Note that Sklearns implementation (used here) is designed for "raw datasets" (i.e., do not feed in a probability distribution, instead feed in the observations).
Further, the mutual information values calculated from Sklearns implementation are scaled by the natural logarithm of 2. In this implementation, the results are re-scaled to be linear.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_result
|
Optional[bool] = True
|
Save result to disk or not. Optional, default is to save. |
True
|
Source code in key_interactions_finder/stat_modelling.py
RegressionStatModel
dataclass
Bases: _ProteinStatModel
Handles the generation of statistical models for PyContact data sets when the target variable is continous.
Note that several attributes listed below are inherited from _ProteinStatModel.
Attributes:
Name | Type | Description |
---|---|---|
dataset |
DataFrame
|
Input dataframe. |
out_dir |
str
|
Directory path to store results files to. Default = "" |
interaction_types_included |
(list, optional)
|
What types of molecular interactions to generate the correlation matrix for. options are one or more of: ["Hbond", "Hydrophobic", "Saltbr", "Other"] Default is to include all 4 types. |
scaled_dataset |
DataFrame
|
Input dataset with all features scaled. |
feature_list |
list
|
List of all feature labels in the dataset. |
mutual_infos |
dict
|
Dictionary with each feature's (keys) and mutual informations (values). Dictionary is sorted from largest mutual information to smallest. |
linear_correlations |
dict
|
Dictionary with each feature's (keys) and linear correlations (values). Dictionary is sorted from largest (absolute) linear correlation to smallest. |
Methods:
Name | Description |
---|---|
calc_mutual_info_to_target |
Calculate the mutual information between each feature and the target. |
calc_linear_correl_to_target |
Calculate the pearson correlation coeffcient between each feature and the target. |
Source code in key_interactions_finder/stat_modelling.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
|
__post_init__()
Filter and rescale the features.
Source code in key_interactions_finder/stat_modelling.py
calc_linear_correl_to_target(save_result=True)
Calculate the pearson correlation coeffcient between each feature and the target.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_result
|
Optional[bool] = True
|
Save result to disk or not. Optional, default is to save. |
True
|
Source code in key_interactions_finder/stat_modelling.py
calc_mutual_info_to_target(save_result=True)
Calculate the mutual information between each feature and the target. The target variable should be continuous. Note that Sklearns implementation (used here) is designed for "raw datasets" (i.e., do not feed in a probability distribution, instead feed in the observations).
Further, the mutual information values calculated from Sklearns implementation are scaled by the natural logarithm of 2. In this implementation, the results are re-scaled to be linear.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
save_result
|
Optional[bool] = True
|
Save result to disk or not. Optional, default is to save. |
True
|