Compare predictions between model and RSN#
see differences in imputation for diverging cases
dumps top5
Parameters#
folder_experiment = 'runs/appl_ald_data/plasma/proteinGroups'
fn_clinical_data = "data/ALD_study/processed/ald_metadata_cli.csv"
make_plots = True # create histograms and swarmplots of diverging results
model_key = 'VAE'
sample_id_col = 'Sample ID'
target = 'kleiner'
cutoff_target: int = 2 # => for binarization target >= cutoff_target
out_folder = 'diff_analysis'
file_format = 'csv'
baseline = 'RSN' # default is RSN, but could be any other trained model
template_pred = 'pred_real_na_{}.csv' # fixed, do not change
ref_method_score = None # filepath to reference method score
# Parameters
cutoff_target = 0.5
make_plots = False
ref_method_score = None
folder_experiment = "runs/alzheimer_study"
target = "AD"
baseline = "PI"
out_folder = "diff_analysis"
fn_clinical_data = "runs/alzheimer_study/data/clinical_data.csv"
root - INFO Removed from global namespace: folder_experiment
root - INFO Removed from global namespace: fn_clinical_data
root - INFO Removed from global namespace: make_plots
root - INFO Removed from global namespace: model_key
root - INFO Removed from global namespace: sample_id_col
root - INFO Removed from global namespace: target
root - INFO Removed from global namespace: cutoff_target
root - INFO Removed from global namespace: out_folder
root - INFO Removed from global namespace: file_format
root - INFO Removed from global namespace: baseline
root - INFO Removed from global namespace: template_pred
root - INFO Removed from global namespace: ref_method_score
root - INFO Already set attribute: folder_experiment has value runs/alzheimer_study
root - INFO Already set attribute: out_folder has value diff_analysis
{'baseline': 'PI',
'cutoff_target': 0.5,
'data': PosixPath('runs/alzheimer_study/data'),
'file_format': 'csv',
'fn_clinical_data': 'runs/alzheimer_study/data/clinical_data.csv',
'folder_experiment': PosixPath('runs/alzheimer_study'),
'folder_scores': PosixPath('runs/alzheimer_study/diff_analysis/AD/scores'),
'make_plots': False,
'model_key': 'VAE',
'out_figures': PosixPath('runs/alzheimer_study/figures'),
'out_folder': PosixPath('runs/alzheimer_study/diff_analysis/AD'),
'out_metrics': PosixPath('runs/alzheimer_study'),
'out_models': PosixPath('runs/alzheimer_study'),
'out_preds': PosixPath('runs/alzheimer_study/preds'),
'ref_method_score': None,
'sample_id_col': 'Sample ID',
'target': 'AD',
'template_pred': 'pred_real_na_{}.csv'}
Write outputs to excel
root - INFO Writing to excel file: runs/alzheimer_study/diff_analysis/AD/diff_analysis_compare_DA.xlsx
Load scores#
List dump of scores:
[PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_QRILC.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_VAE.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_TRKNN.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_CF.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_PI.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_DAE.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_None.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_Median.pkl'),
PosixPath('runs/alzheimer_study/diff_analysis/AD/scores/diff_analysis_scores_RF.pkl')]
Load scores from dumps:
| model | QRILC | VAE | ... | Median | RF | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| var | SS | DF | F | p-unc | np2 | -Log10 pvalue | qvalue | rejected | SS | DF | ... | qvalue | rejected | SS | DF | F | p-unc | np2 | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | |||||||||||||||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.744 | 1 | 4.532 | 0.035 | 0.023 | 1.462 | 0.085 | False | 1.051 | 1 | ... | 0.039 | True | 0.943 | 1 | 7.097 | 0.008 | 0.036 | 2.077 | 0.024 | True |
| age | 0.013 | 1 | 0.080 | 0.777 | 0.000 | 0.110 | 0.854 | False | 0.013 | 1 | ... | 0.966 | False | 0.001 | 1 | 0.008 | 0.929 | 0.000 | 0.032 | 0.959 | False | |
| Kiel | 0.454 | 1 | 2.766 | 0.098 | 0.014 | 1.009 | 0.193 | False | 0.288 | 1 | ... | 0.532 | False | 0.200 | 1 | 1.506 | 0.221 | 0.008 | 0.655 | 0.350 | False | |
| Magdeburg | 0.990 | 1 | 6.027 | 0.015 | 0.031 | 1.824 | 0.043 | True | 0.441 | 1 | ... | 0.343 | False | 0.423 | 1 | 3.180 | 0.076 | 0.016 | 1.118 | 0.151 | False | |
| Sweden | 2.587 | 1 | 15.752 | 0.000 | 0.076 | 3.991 | 0.001 | True | 1.617 | 1 | ... | 0.016 | True | 1.576 | 1 | 11.860 | 0.001 | 0.058 | 3.152 | 0.003 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 1.908 | 1 | 1.071 | 0.302 | 0.006 | 0.520 | 0.452 | False | 2.536 | 1 | ... | 0.829 | False | 1.116 | 1 | 2.443 | 0.120 | 0.013 | 0.922 | 0.216 | False |
| age | 1.599 | 1 | 0.898 | 0.345 | 0.005 | 0.463 | 0.495 | False | 0.655 | 1 | ... | 0.194 | False | 0.983 | 1 | 2.152 | 0.144 | 0.011 | 0.842 | 0.250 | False | |
| Kiel | 10.759 | 1 | 6.038 | 0.015 | 0.031 | 1.827 | 0.043 | True | 2.799 | 1 | ... | 0.289 | False | 1.931 | 1 | 4.226 | 0.041 | 0.022 | 1.385 | 0.091 | False | |
| Magdeburg | 20.883 | 1 | 11.720 | 0.001 | 0.058 | 3.121 | 0.003 | True | 2.502 | 1 | ... | 0.631 | False | 1.500 | 1 | 3.282 | 0.072 | 0.017 | 1.145 | 0.143 | False | |
| Sweden | 0.125 | 1 | 0.070 | 0.791 | 0.000 | 0.102 | 0.865 | False | 18.771 | 1 | ... | 0.011 | True | 12.159 | 1 | 26.609 | 0.000 | 0.122 | 6.207 | 0.000 | True | |
7105 rows × 72 columns
If reference dump is provided, add it to the scores
Load frequencies of observed features#
| data | |
|---|---|
| frequency | |
| protein groups | |
| A0A024QZX5;A0A087X1N8;P35237 | 186 |
| A0A024R0T9;K7ER74;P02655 | 195 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | 174 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | 196 |
| A0A075B6H7 | 91 |
| ... | ... |
| Q9Y6R7 | 197 |
| Q9Y6X5 | 173 |
| Q9Y6Y8;Q9Y6Y8-2 | 197 |
| Q9Y6Y9 | 119 |
| S4R3U6 | 126 |
1421 rows × 1 columns
Assemble qvalues#
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | 0.085 | 0.018 | 0.023 | 0.018 | 0.670 | 0.013 | 0.043 | 0.039 | 0.024 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.074 | 0.071 | 0.071 | 0.073 | 0.111 | 0.068 | 0.092 | 0.087 | 0.074 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.466 | 0.482 | 0.394 | 0.362 | 0.174 | 0.315 | 0.586 | 0.832 | 0.520 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.461 | 0.376 | 0.396 | 0.395 | 0.644 | 0.375 | 0.404 | 0.418 | 0.386 |
| A0A075B6H7 | AD | 91 | 0.719 | 0.027 | 0.048 | 0.011 | 0.195 | 0.065 | 0.027 | 0.124 | 0.016 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 197 | 0.302 | 0.282 | 0.289 | 0.285 | 0.318 | 0.282 | 0.307 | 0.315 | 0.292 |
| Q9Y6X5 | AD | 173 | 0.141 | 0.342 | 0.205 | 0.418 | 0.203 | 0.292 | 0.501 | 0.455 | 0.289 |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 197 | 0.171 | 0.156 | 0.160 | 0.159 | 0.182 | 0.156 | 0.174 | 0.178 | 0.162 |
| Q9Y6Y9 | AD | 119 | 0.836 | 0.658 | 0.472 | 0.828 | 0.604 | 0.734 | 0.651 | 0.667 | 0.389 |
| S4R3U6 | AD | 126 | 0.452 | 0.065 | 0.080 | 0.143 | 0.872 | 0.142 | 0.803 | 0.829 | 0.216 |
1421 rows × 9 columns
Assemble pvalues#
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| p-unc | p-unc | p-unc | p-unc | p-unc | p-unc | p-unc | p-unc | p-unc | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | 0.035 | 0.006 | 0.008 | 0.006 | 0.528 | 0.004 | 0.015 | 0.012 | 0.008 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.029 | 0.032 | 0.031 | 0.032 | 0.045 | 0.031 | 0.037 | 0.033 | 0.032 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.315 | 0.354 | 0.264 | 0.238 | 0.078 | 0.202 | 0.432 | 0.736 | 0.382 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.311 | 0.254 | 0.266 | 0.268 | 0.499 | 0.253 | 0.254 | 0.259 | 0.253 |
| A0A075B6H7 | AD | 91 | 0.601 | 0.010 | 0.020 | 0.003 | 0.091 | 0.029 | 0.008 | 0.053 | 0.005 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 197 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 | 0.175 |
| Q9Y6X5 | AD | 173 | 0.066 | 0.225 | 0.113 | 0.289 | 0.096 | 0.184 | 0.344 | 0.291 | 0.173 |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 197 | 0.083 | 0.083 | 0.083 | 0.083 | 0.083 | 0.083 | 0.083 | 0.083 | 0.083 |
| Q9Y6Y9 | AD | 119 | 0.754 | 0.542 | 0.334 | 0.748 | 0.452 | 0.630 | 0.505 | 0.520 | 0.256 |
| S4R3U6 | AD | 126 | 0.302 | 0.029 | 0.036 | 0.073 | 0.791 | 0.075 | 0.698 | 0.730 | 0.120 |
1421 rows × 9 columns
Assemble rejected features#
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF | |
|---|---|---|---|---|---|---|---|---|---|
| False | 997 | 937 | 936 | 958 | 1,023 | 933 | 1,054 | 1,069 | 967 |
| True | 424 | 484 | 485 | 463 | 398 | 488 | 367 | 352 | 454 |
Tabulate rejected decisions by method:#
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF | |
|---|---|---|---|---|---|---|---|---|---|
| False | 997 | 937 | 936 | 958 | 1,023 | 933 | 1,054 | 1,069 | 967 |
| True | 424 | 484 | 485 | 463 | 398 | 488 | 367 | 352 | 454 |
Tabulate rejected decisions by method for newly included features (if available)#
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF |
|---|
Tabulate rejected decisions by method for all features#
root - INFO Written to sheet 'equality_rejected_all' in excel file.
| QRILC | VAE | TRKNN | CF | PI | DAE | None | Median | RF | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | False | True | True | True | False | True | True | True | True |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | False | False | False | False | False | False | False | False | False |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | False | False | False | False | False | False | False | False | False |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | False | False | False | False | False | False | False | False | False |
| A0A075B6H7 | AD | 91 | False | True | True | True | False | False | True | False | True |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 197 | False | False | False | False | False | False | False | False | False |
| Q9Y6X5 | AD | 173 | False | False | False | False | False | False | False | False | False |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 197 | False | False | False | False | False | False | False | False | False |
| Q9Y6Y9 | AD | 119 | False | False | False | False | False | False | False | False | False |
| S4R3U6 | AD | 126 | False | False | False | False | False | False | False | False | False |
1421 rows × 9 columns
Tabulate number of equal decison by method (True) to the ones with varying
decision depending on the method (False)
True 1,104
False 317
Name: count, dtype: int64
List frequency of features with varying decisions
| frequency | ||
|---|---|---|
| protein groups | Source | |
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 |
| A0A075B6H7 | AD | 91 |
| A0A075B6H9 | AD | 189 |
| A0A075B6J9 | AD | 156 |
| A0A075B6Q5 | AD | 104 |
| ... | ... | ... |
| Q9UP79 | AD | 135 |
| Q9UPU3 | AD | 163 |
| Q9UQ52 | AD | 188 |
| Q9Y653;Q9Y653-2;Q9Y653-3 | AD | 177 |
| Q9Y6C2 | AD | 119 |
317 rows × 1 columns
take only those with different decisions
No new features or no new ones (with diverging decisions.)
Plots for inspecting imputations (for diverging decisions)#
root - WARNING Not plots requested.
/home/runner/work/pimms/pimms/project/.snakemake/conda/43fbe714d68d8fe6f9b0c93f5652adb3_/lib/python3.12/site-packages/IPython/core/interactiveshell.py:3756: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
An exception has occurred, use %tb to see the full traceback.
SystemExit: 0
Load target#
Measurments#
plot all of the new pgs which are at least once significant which are not already dumped.
RSN prediction are based on all samples mean and std (N=455) as in original study
VAE also trained on all samples (self supervised) One could also reduce the selected data to only the samples with a valid target marker, but this was not done in the original study which considered several different target markers.
RSN : shifted per sample, not per feature!
Load all prediction files and reshape
Once imputation, reduce to target samples only (samples with target score)
Compare with target annotation#
Saved files: