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_PI.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_None.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_RF.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_QRILC.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_TRKNN.pkl')]
Load scores from dumps:
| model | PI | VAE | ... | CF | TRKNN | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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.261 | 1 | 0.456 | 0.501 | 0.002 | 0.301 | 0.653 | False | 1.005 | 1 | ... | 0.020 | True | 0.994 | 1 | 7.134 | 0.008 | 0.036 | 2.085 | 0.023 | True |
| age | 0.036 | 1 | 0.063 | 0.802 | 0.000 | 0.096 | 0.878 | False | 0.011 | 1 | ... | 0.907 | False | 0.004 | 1 | 0.029 | 0.864 | 0.000 | 0.063 | 0.913 | False | |
| Kiel | 1.631 | 1 | 2.848 | 0.093 | 0.015 | 1.031 | 0.198 | False | 0.262 | 1 | ... | 0.281 | False | 0.269 | 1 | 1.933 | 0.166 | 0.010 | 0.780 | 0.277 | False | |
| Magdeburg | 4.653 | 1 | 8.127 | 0.005 | 0.041 | 2.315 | 0.018 | True | 0.416 | 1 | ... | 0.125 | False | 0.519 | 1 | 3.727 | 0.055 | 0.019 | 1.259 | 0.114 | False | |
| Sweden | 7.129 | 1 | 12.451 | 0.001 | 0.061 | 3.281 | 0.003 | True | 1.584 | 1 | ... | 0.002 | True | 1.796 | 1 | 12.893 | 0.000 | 0.063 | 3.378 | 0.002 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.832 | 1 | 0.895 | 0.345 | 0.005 | 0.462 | 0.508 | False | 1.745 | 1 | ... | 0.068 | False | 2.295 | 1 | 4.480 | 0.036 | 0.023 | 1.449 | 0.080 | False |
| age | 0.017 | 1 | 0.019 | 0.891 | 0.000 | 0.050 | 0.934 | False | 0.489 | 1 | ... | 0.396 | False | 0.398 | 1 | 0.777 | 0.379 | 0.004 | 0.421 | 0.516 | False | |
| Kiel | 0.472 | 1 | 0.508 | 0.477 | 0.003 | 0.322 | 0.630 | False | 2.470 | 1 | ... | 0.055 | False | 2.981 | 1 | 5.819 | 0.017 | 0.030 | 1.775 | 0.043 | True | |
| Magdeburg | 1.695 | 1 | 1.824 | 0.178 | 0.009 | 0.749 | 0.320 | False | 2.088 | 1 | ... | 0.035 | True | 3.440 | 1 | 6.716 | 0.010 | 0.034 | 1.987 | 0.028 | True | |
| Sweden | 13.108 | 1 | 14.110 | 0.000 | 0.069 | 3.640 | 0.001 | True | 15.708 | 1 | ... | 0.000 | True | 27.114 | 1 | 52.939 | 0.000 | 0.217 | 11.062 | 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#
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | 0.653 | 0.020 | 0.043 | 0.017 | 0.020 | 0.039 | 0.103 | 0.020 | 0.023 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.092 | 0.067 | 0.092 | 0.077 | 0.072 | 0.087 | 0.080 | 0.084 | 0.071 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.214 | 0.428 | 0.586 | 0.474 | 0.523 | 0.832 | 0.517 | 0.707 | 0.394 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.747 | 0.377 | 0.404 | 0.375 | 0.389 | 0.418 | 0.455 | 0.385 | 0.396 |
| A0A075B6H7 | AD | 91 | 0.146 | 0.019 | 0.027 | 0.024 | 0.007 | 0.124 | 0.283 | 0.023 | 0.048 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 197 | 0.317 | 0.282 | 0.307 | 0.283 | 0.291 | 0.315 | 0.304 | 0.285 | 0.289 |
| Q9Y6X5 | AD | 173 | 0.136 | 0.332 | 0.501 | 0.473 | 0.323 | 0.455 | 0.078 | 0.171 | 0.205 |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 197 | 0.183 | 0.155 | 0.174 | 0.157 | 0.162 | 0.178 | 0.171 | 0.158 | 0.160 |
| Q9Y6Y9 | AD | 119 | 0.697 | 0.822 | 0.651 | 0.939 | 0.518 | 0.667 | 0.891 | 0.449 | 0.472 |
| S4R3U6 | AD | 126 | 0.508 | 0.122 | 0.803 | 0.080 | 0.159 | 0.829 | 0.603 | 0.068 | 0.080 |
1421 rows × 9 columns
Assemble pvalues#
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 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.501 | 0.007 | 0.015 | 0.006 | 0.007 | 0.012 | 0.044 | 0.007 | 0.008 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.035 | 0.030 | 0.037 | 0.035 | 0.031 | 0.033 | 0.032 | 0.038 | 0.031 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.102 | 0.298 | 0.432 | 0.343 | 0.385 | 0.736 | 0.366 | 0.598 | 0.264 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.620 | 0.253 | 0.254 | 0.250 | 0.256 | 0.259 | 0.304 | 0.259 | 0.266 |
| A0A075B6H7 | AD | 91 | 0.063 | 0.007 | 0.008 | 0.009 | 0.002 | 0.053 | 0.160 | 0.008 | 0.020 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 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.057 | 0.215 | 0.344 | 0.342 | 0.200 | 0.291 | 0.031 | 0.092 | 0.113 |
| 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.561 | 0.742 | 0.505 | 0.904 | 0.380 | 0.520 | 0.829 | 0.317 | 0.334 |
| S4R3U6 | AD | 126 | 0.345 | 0.062 | 0.698 | 0.037 | 0.082 | 0.730 | 0.462 | 0.030 | 0.036 |
1421 rows × 9 columns
Assemble rejected features#
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN | |
|---|---|---|---|---|---|---|---|---|---|
| False | 1,025 | 947 | 1,054 | 951 | 973 | 1,069 | 995 | 932 | 936 |
| True | 396 | 474 | 367 | 470 | 448 | 352 | 426 | 489 | 485 |
Tabulate rejected decisions by method:#
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN | |
|---|---|---|---|---|---|---|---|---|---|
| False | 1,025 | 947 | 1,054 | 951 | 973 | 1,069 | 995 | 932 | 936 |
| True | 396 | 474 | 367 | 470 | 448 | 352 | 426 | 489 | 485 |
Tabulate rejected decisions by method for newly included features (if available)#
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN |
|---|
Tabulate rejected decisions by method for all features#
root - INFO Written to sheet 'equality_rejected_all' in excel file.
| PI | VAE | None | DAE | RF | Median | QRILC | CF | TRKNN | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | False | True | True | True | True | True | False | 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 | True | False | False | True | 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,098
False 323
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 |
| A0A075B6I0 | AD | 194 |
| A0A075B6J9 | AD | 156 |
| ... | ... | ... |
| Q9UP79 | AD | 135 |
| Q9UPU3 | AD | 163 |
| Q9UQ52 | AD | 188 |
| Q9Y281;Q9Y281-3 | AD | 51 |
| Q9Y6C2 | AD | 119 |
323 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:3755: 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: