Compare outcomes from differential analysis based on different imputation methods#
load scores based on
10_1_ald_diff_analysis
Parameters#
Default and set parameters for the notebook.
folder_experiment = 'runs/appl_ald_data/plasma/proteinGroups'
target = 'kleiner'
model_key = 'VAE'
baseline = 'RSN'
out_folder = 'diff_analysis'
selected_statistics = ['p-unc', '-Log10 pvalue', 'qvalue', 'rejected']
disease_ontology = 5082 # code from https://disease-ontology.org/
# split diseases notebook? Query gene names for proteins in file from uniprot?
annotaitons_gene_col = 'PG.Genes'
# Parameters
disease_ontology = 10652
folder_experiment = "runs/alzheimer_study"
target = "AD"
baseline = "PI"
model_key = "RF"
out_folder = "diff_analysis"
annotaitons_gene_col = "None"
Add set parameters to configuration
root - INFO Removed from global namespace: folder_experiment
root - INFO Removed from global namespace: target
root - INFO Removed from global namespace: model_key
root - INFO Removed from global namespace: baseline
root - INFO Removed from global namespace: out_folder
root - INFO Removed from global namespace: selected_statistics
root - INFO Removed from global namespace: disease_ontology
root - INFO Removed from global namespace: annotaitons_gene_col
root - INFO Already set attribute: folder_experiment has value runs/alzheimer_study
root - INFO Already set attribute: out_folder has value diff_analysis
{'annotaitons_gene_col': 'None',
'baseline': 'PI',
'data': PosixPath('runs/alzheimer_study/data'),
'disease_ontology': 10652,
'folder_experiment': PosixPath('runs/alzheimer_study'),
'freq_features_observed': PosixPath('runs/alzheimer_study/freq_features_observed.csv'),
'model_key': 'RF',
'out_figures': PosixPath('runs/alzheimer_study/figures'),
'out_folder': PosixPath('runs/alzheimer_study/diff_analysis/AD/PI_vs_RF'),
'out_metrics': PosixPath('runs/alzheimer_study'),
'out_models': PosixPath('runs/alzheimer_study'),
'out_preds': PosixPath('runs/alzheimer_study/preds'),
'scores_folder': PosixPath('runs/alzheimer_study/diff_analysis/AD/scores'),
'selected_statistics': ['p-unc', '-Log10 pvalue', 'qvalue', 'rejected'],
'target': 'AD'}
Excel file for exports#
files_out = dict()
writer_args = dict(float_format='%.3f')
fname = args.out_folder / 'diff_analysis_compare_methods.xlsx'
files_out[fname.name] = fname
writer = pd.ExcelWriter(fname)
logger.info("Writing to excel file: %s", fname)
root - INFO Writing to excel file: runs/alzheimer_study/diff_analysis/AD/PI_vs_RF/diff_analysis_compare_methods.xlsx
Load scores#
Load baseline model scores#
Show all statistics, later use selected statistics
| model | PI | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| var | SS | DF | F | p-unc | np2 | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.274 | 1 | 0.399 | 0.528 | 0.002 | 0.277 | 0.670 | False |
| age | 0.212 | 1 | 0.309 | 0.579 | 0.002 | 0.237 | 0.712 | False | |
| Kiel | 2.676 | 1 | 3.897 | 0.050 | 0.020 | 1.303 | 0.121 | False | |
| Magdeburg | 5.765 | 1 | 8.393 | 0.004 | 0.042 | 2.376 | 0.016 | True | |
| Sweden | 8.898 | 1 | 12.955 | 0.000 | 0.064 | 3.391 | 0.002 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.074 | 1 | 0.070 | 0.791 | 0.000 | 0.102 | 0.872 | False |
| age | 0.829 | 1 | 0.785 | 0.377 | 0.004 | 0.424 | 0.538 | False | |
| Kiel | 0.040 | 1 | 0.038 | 0.846 | 0.000 | 0.073 | 0.909 | False | |
| Magdeburg | 3.442 | 1 | 3.263 | 0.072 | 0.017 | 1.140 | 0.163 | False | |
| Sweden | 6.688 | 1 | 6.340 | 0.013 | 0.032 | 1.899 | 0.041 | True | |
7105 rows × 8 columns
Load selected comparison model scores#
| model | RF | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| var | SS | DF | F | p-unc | np2 | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.943 | 1 | 7.097 | 0.008 | 0.036 | 2.077 | 0.024 | True |
| age | 0.001 | 1 | 0.008 | 0.929 | 0.000 | 0.032 | 0.959 | False | |
| Kiel | 0.200 | 1 | 1.506 | 0.221 | 0.008 | 0.655 | 0.350 | False | |
| Magdeburg | 0.423 | 1 | 3.180 | 0.076 | 0.016 | 1.118 | 0.151 | False | |
| Sweden | 1.576 | 1 | 11.860 | 0.001 | 0.058 | 3.152 | 0.003 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 1.116 | 1 | 2.443 | 0.120 | 0.013 | 0.922 | 0.216 | False |
| age | 0.983 | 1 | 2.152 | 0.144 | 0.011 | 0.842 | 0.250 | False | |
| Kiel | 1.931 | 1 | 4.226 | 0.041 | 0.022 | 1.385 | 0.091 | False | |
| Magdeburg | 1.500 | 1 | 3.282 | 0.072 | 0.017 | 1.145 | 0.143 | False | |
| Sweden | 12.159 | 1 | 26.609 | 0.000 | 0.122 | 6.207 | 0.000 | True | |
7105 rows × 8 columns
Combined scores#
show only selected statistics for comparsion
| model | PI | RF | |||||||
|---|---|---|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | rejected | p-unc | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.528 | 0.277 | 0.670 | False | 0.008 | 2.077 | 0.024 | True |
| Kiel | 0.050 | 1.303 | 0.121 | False | 0.221 | 0.655 | 0.350 | False | |
| Magdeburg | 0.004 | 2.376 | 0.016 | True | 0.076 | 1.118 | 0.151 | False | |
| Sweden | 0.000 | 3.391 | 0.002 | True | 0.001 | 3.152 | 0.003 | True | |
| age | 0.579 | 0.237 | 0.712 | False | 0.929 | 0.032 | 0.959 | False | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.791 | 0.102 | 0.872 | False | 0.120 | 0.922 | 0.216 | False |
| Kiel | 0.846 | 0.073 | 0.909 | False | 0.041 | 1.385 | 0.091 | False | |
| Magdeburg | 0.072 | 1.140 | 0.163 | False | 0.072 | 1.145 | 0.143 | False | |
| Sweden | 0.013 | 1.899 | 0.041 | True | 0.000 | 6.207 | 0.000 | True | |
| age | 0.377 | 0.424 | 0.538 | False | 0.144 | 0.842 | 0.250 | False | |
7105 rows × 8 columns
Models in comparison (name mapping)
{'PI': 'PI', 'RF': 'RF'}
Describe scores#
| model | PI | RF | ||||
|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | p-unc | -Log10 pvalue | qvalue |
| count | 7,105.000 | 7,105.000 | 7,105.000 | 7,105.000 | 7,105.000 | 7,105.000 |
| mean | 0.259 | 2.472 | 0.336 | 0.234 | 3.078 | 0.292 |
| std | 0.301 | 5.305 | 0.328 | 0.297 | 5.787 | 0.324 |
| min | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 25% | 0.004 | 0.343 | 0.016 | 0.001 | 0.383 | 0.003 |
| 50% | 0.123 | 0.910 | 0.246 | 0.071 | 1.146 | 0.143 |
| 75% | 0.454 | 2.409 | 0.605 | 0.414 | 3.101 | 0.552 |
| max | 1.000 | 144.895 | 1.000 | 0.999 | 84.938 | 0.999 |
One to one comparison of by feature:#
/tmp/ipykernel_77384/3761369923.py:2: FutureWarning: Starting with pandas version 3.0 all arguments of to_excel except for the argument 'excel_writer' will be keyword-only.
scores.to_excel(writer, 'scores', **writer_args)
| model | PI | RF | |||||||
|---|---|---|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | rejected | p-unc | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.528 | 0.277 | 0.670 | False | 0.008 | 2.077 | 0.024 | True |
| A0A024R0T9;K7ER74;P02655 | AD | 0.045 | 1.351 | 0.111 | False | 0.032 | 1.496 | 0.074 | False |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 0.078 | 1.106 | 0.174 | False | 0.382 | 0.418 | 0.520 | False |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 0.499 | 0.302 | 0.644 | False | 0.253 | 0.596 | 0.386 | False |
| A0A075B6H7 | AD | 0.091 | 1.040 | 0.195 | False | 0.005 | 2.281 | 0.016 | True |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 0.175 | 0.756 | 0.318 | False | 0.175 | 0.756 | 0.292 | False |
| Q9Y6X5 | AD | 0.096 | 1.019 | 0.203 | False | 0.173 | 0.761 | 0.289 | False |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 0.083 | 1.079 | 0.182 | False | 0.083 | 1.079 | 0.162 | False |
| Q9Y6Y9 | AD | 0.452 | 0.345 | 0.604 | False | 0.256 | 0.592 | 0.389 | False |
| S4R3U6 | AD | 0.791 | 0.102 | 0.872 | False | 0.120 | 0.922 | 0.216 | False |
1421 rows × 8 columns
And the descriptive statistics of the numeric values:
| model | PI | RF | ||||
|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | p-unc | -Log10 pvalue | qvalue |
| count | 1,421.000 | 1,421.000 | 1,421.000 | 1,421.000 | 1,421.000 | 1,421.000 |
| mean | 0.251 | 1.400 | 0.333 | 0.248 | 1.517 | 0.313 |
| std | 0.290 | 1.600 | 0.314 | 0.296 | 1.759 | 0.319 |
| min | 0.000 | 0.000 | 0.000 | 0.000 | 0.001 | 0.000 |
| 25% | 0.012 | 0.371 | 0.038 | 0.009 | 0.362 | 0.025 |
| 50% | 0.124 | 0.907 | 0.247 | 0.100 | 1.002 | 0.187 |
| 75% | 0.426 | 1.934 | 0.583 | 0.435 | 2.055 | 0.572 |
| max | 0.999 | 21.057 | 1.000 | 0.997 | 18.918 | 0.998 |
and the boolean decision values
| model | PI | RF |
|---|---|---|
| var | rejected | rejected |
| count | 1421 | 1421 |
| unique | 2 | 2 |
| top | False | False |
| freq | 1023 | 967 |
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
Plot qvalues of both models with annotated decisions#
Prepare data for plotting (qvalues)
| PI | RF | frequency | Differential Analysis Comparison | |
|---|---|---|---|---|
| protein groups | ||||
| A0A024QZX5;A0A087X1N8;P35237 | 0.670 | 0.024 | 186 | PI (no) - RF (yes) |
| A0A024R0T9;K7ER74;P02655 | 0.111 | 0.074 | 195 | PI (no) - RF (no) |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | 0.174 | 0.520 | 174 | PI (no) - RF (no) |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | 0.644 | 0.386 | 196 | PI (no) - RF (no) |
| A0A075B6H7 | 0.195 | 0.016 | 91 | PI (no) - RF (yes) |
| ... | ... | ... | ... | ... |
| Q9Y6R7 | 0.318 | 0.292 | 197 | PI (no) - RF (no) |
| Q9Y6X5 | 0.203 | 0.289 | 173 | PI (no) - RF (no) |
| Q9Y6Y8;Q9Y6Y8-2 | 0.182 | 0.162 | 197 | PI (no) - RF (no) |
| Q9Y6Y9 | 0.604 | 0.389 | 119 | PI (no) - RF (no) |
| S4R3U6 | 0.872 | 0.216 | 126 | PI (no) - RF (no) |
1421 rows × 4 columns
List of features with the highest difference in qvalues
| PI | RF | frequency | Differential Analysis Comparison | diff_qvalue | |
|---|---|---|---|---|---|
| protein groups | |||||
| Q96PQ0 | 0.005 | 0.995 | 177 | PI (yes) - RF (no) | 0.990 |
| P52758 | 0.000 | 0.974 | 119 | PI (yes) - RF (no) | 0.974 |
| F5GWE5;I3L2X8;I3L3W1;I3L459;I3L471;I3L4C0;I3L4H1;I3L4U7;Q00169 | 0.991 | 0.024 | 78 | PI (no) - RF (yes) | 0.968 |
| P22748 | 0.999 | 0.038 | 159 | PI (no) - RF (yes) | 0.961 |
| A0A087X1Z2;C9JTV4;H0Y4Y4;Q8WYH2;Q96C19;Q9BUP0;Q9BUP0-2 | 0.000 | 0.954 | 66 | PI (yes) - RF (no) | 0.954 |
| ... | ... | ... | ... | ... | ... |
| F5GY80;F5H7G1;P07358 | 0.057 | 0.049 | 197 | PI (no) - RF (yes) | 0.008 |
| P00740;P00740-2 | 0.053 | 0.045 | 197 | PI (no) - RF (yes) | 0.008 |
| K7ERG9;P00746 | 0.052 | 0.044 | 197 | PI (no) - RF (yes) | 0.008 |
| Q9UJ14 | 0.050 | 0.047 | 169 | PI (no) - RF (yes) | 0.004 |
| Q16706 | 0.050 | 0.052 | 195 | PI (yes) - RF (no) | 0.002 |
198 rows × 5 columns
Differences plotted with created annotations#
pimmslearn.plotting - INFO Saved Figures to runs/alzheimer_study/diff_analysis/AD/PI_vs_RF/diff_analysis_comparision_1_RF
also showing how many features were measured (“observed”) by size of circle
pimmslearn.plotting - INFO Saved Figures to runs/alzheimer_study/diff_analysis/AD/PI_vs_RF/diff_analysis_comparision_2_RF
Only features contained in model#
this block exist due to a specific part in the ALD analysis of the paper
root - INFO No features only in new comparision model.
DISEASES DB lookup#
Query diseases database for gene associations with specified disease ontology id.
pimmslearn.databases.diseases - WARNING There are more associations available
| ENSP | score | |
|---|---|---|
| None | ||
| APP | ENSP00000284981 | 5.000 |
| PSEN1 | ENSP00000326366 | 5.000 |
| APOE | ENSP00000252486 | 5.000 |
| PSEN2 | ENSP00000355747 | 5.000 |
| TREM2 | ENSP00000362205 | 4.825 |
| ... | ... | ... |
| hsa-miR-760 | hsa-miR-760 | 0.682 |
| PCDH11Y | ENSP00000355419 | 0.682 |
| JPH1 | ENSP00000344488 | 0.682 |
| RCN1 | ENSP00000054950 | 0.682 |
| RNF157 | ENSP00000269391 | 0.682 |
10000 rows × 2 columns
only by model#
Only by model which were significant#
Only significant by RSN#
mask = (scores_common[(str(args.baseline), 'rejected')] & mask_different)
mask.sum()