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_Median.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_TRKNN.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_VAE.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_CF.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_QRILC.pkl')]
Load scores from dumps:
| model | Median | RF | ... | DAE | QRILC | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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.830 | 1 | 6.377 | 0.012 | 0.032 | 1.907 | 0.039 | True | 1.010 | 1 | ... | 0.016 | True | 0.741 | 1 | 4.819 | 0.029 | 0.025 | 1.532 | 0.075 | False |
| age | 0.001 | 1 | 0.006 | 0.939 | 0.000 | 0.027 | 0.966 | False | 0.002 | 1 | ... | 0.903 | False | 0.010 | 1 | 0.062 | 0.803 | 0.000 | 0.095 | 0.871 | False | |
| Kiel | 0.106 | 1 | 0.815 | 0.368 | 0.004 | 0.435 | 0.532 | False | 0.206 | 1 | ... | 0.279 | False | 0.394 | 1 | 2.560 | 0.111 | 0.013 | 0.954 | 0.214 | False | |
| Magdeburg | 0.219 | 1 | 1.680 | 0.197 | 0.009 | 0.707 | 0.343 | False | 0.388 | 1 | ... | 0.142 | False | 0.877 | 1 | 5.702 | 0.018 | 0.029 | 1.747 | 0.050 | True | |
| Sweden | 1.101 | 1 | 8.461 | 0.004 | 0.042 | 2.392 | 0.016 | True | 1.521 | 1 | ... | 0.003 | True | 2.352 | 1 | 15.296 | 0.000 | 0.074 | 3.894 | 0.001 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.051 | 1 | 0.119 | 0.730 | 0.001 | 0.136 | 0.829 | False | 1.041 | 1 | ... | 0.087 | False | 7.824 | 1 | 3.739 | 0.055 | 0.019 | 1.262 | 0.122 | False |
| age | 1.214 | 1 | 2.845 | 0.093 | 0.015 | 1.030 | 0.194 | False | 0.807 | 1 | ... | 0.367 | False | 0.011 | 1 | 0.005 | 0.941 | 0.000 | 0.026 | 0.965 | False | |
| Kiel | 0.861 | 1 | 2.018 | 0.157 | 0.010 | 0.804 | 0.289 | False | 1.830 | 1 | ... | 0.068 | False | 6.913 | 1 | 3.303 | 0.071 | 0.017 | 1.150 | 0.150 | False | |
| Magdeburg | 0.216 | 1 | 0.506 | 0.478 | 0.003 | 0.321 | 0.631 | False | 1.832 | 1 | ... | 0.036 | True | 21.543 | 1 | 10.294 | 0.002 | 0.051 | 2.805 | 0.006 | True | |
| Sweden | 3.965 | 1 | 9.288 | 0.003 | 0.046 | 2.580 | 0.011 | True | 12.678 | 1 | ... | 0.000 | True | 0.048 | 1 | 0.023 | 0.879 | 0.000 | 0.056 | 0.926 | False | |
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#
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | qvalue | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | 0.039 | 0.019 | 0.023 | 0.043 | 0.019 | 0.397 | 0.020 | 0.016 | 0.075 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.087 | 0.072 | 0.071 | 0.092 | 0.071 | 0.139 | 0.077 | 0.074 | 0.085 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.832 | 0.540 | 0.394 | 0.586 | 0.392 | 0.103 | 0.510 | 0.380 | 0.454 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.418 | 0.390 | 0.396 | 0.404 | 0.372 | 0.580 | 0.376 | 0.376 | 0.453 |
| A0A075B6H7 | AD | 91 | 0.124 | 0.026 | 0.048 | 0.027 | 0.014 | 0.075 | 0.013 | 0.036 | 0.288 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 197 | 0.315 | 0.292 | 0.289 | 0.307 | 0.283 | 0.316 | 0.284 | 0.283 | 0.302 |
| Q9Y6X5 | AD | 173 | 0.455 | 0.327 | 0.205 | 0.501 | 0.390 | 0.159 | 0.301 | 0.240 | 0.199 |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 197 | 0.178 | 0.162 | 0.160 | 0.174 | 0.156 | 0.182 | 0.158 | 0.156 | 0.171 |
| Q9Y6Y9 | AD | 119 | 0.667 | 0.468 | 0.472 | 0.651 | 0.531 | 0.512 | 0.733 | 0.808 | 0.891 |
| S4R3U6 | AD | 126 | 0.829 | 0.238 | 0.080 | 0.802 | 0.120 | 0.623 | 0.117 | 0.087 | 0.122 |
1421 rows × 9 columns
Assemble pvalues#
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 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.012 | 0.006 | 0.008 | 0.015 | 0.007 | 0.240 | 0.007 | 0.005 | 0.029 |
| A0A024R0T9;K7ER74;P02655 | AD | 195 | 0.033 | 0.031 | 0.031 | 0.037 | 0.032 | 0.059 | 0.035 | 0.033 | 0.035 |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 174 | 0.736 | 0.403 | 0.264 | 0.432 | 0.266 | 0.040 | 0.380 | 0.257 | 0.305 |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 196 | 0.259 | 0.257 | 0.266 | 0.254 | 0.249 | 0.420 | 0.251 | 0.253 | 0.303 |
| A0A075B6H7 | AD | 91 | 0.053 | 0.009 | 0.020 | 0.008 | 0.005 | 0.027 | 0.004 | 0.014 | 0.165 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 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.291 | 0.203 | 0.113 | 0.344 | 0.265 | 0.070 | 0.189 | 0.143 | 0.101 |
| 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.520 | 0.328 | 0.334 | 0.505 | 0.403 | 0.348 | 0.628 | 0.723 | 0.832 |
| S4R3U6 | AD | 126 | 0.730 | 0.135 | 0.036 | 0.698 | 0.060 | 0.469 | 0.058 | 0.041 | 0.055 |
1421 rows × 9 columns
Assemble rejected features#
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC | |
|---|---|---|---|---|---|---|---|---|---|
| False | 1,069 | 961 | 936 | 1,054 | 939 | 1,031 | 952 | 938 | 999 |
| True | 352 | 460 | 485 | 367 | 482 | 390 | 469 | 483 | 422 |
Tabulate rejected decisions by method:#
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC | |
|---|---|---|---|---|---|---|---|---|---|
| False | 1,069 | 961 | 936 | 1,054 | 939 | 1,031 | 952 | 938 | 999 |
| True | 352 | 460 | 485 | 367 | 482 | 390 | 469 | 483 | 422 |
Tabulate rejected decisions by method for newly included features (if available)#
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC |
|---|
Tabulate rejected decisions by method for all features#
root - INFO Written to sheet 'equality_rejected_all' in excel file.
| Median | RF | TRKNN | None | VAE | PI | CF | DAE | QRILC | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | rejected | |||
| protein groups | Source | frequency | |||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 186 | True | True | True | True | True | False | True | True | False |
| 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 | True | True | False |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 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,106
False 315
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 |
| ... | ... | ... |
| Q9UNW1 | AD | 171 |
| Q9UP79 | AD | 135 |
| Q9UPU3 | AD | 163 |
| Q9UQ52 | AD | 188 |
| Q9Y6C2 | AD | 119 |
315 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: