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 = "CF"
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': 'CF',
'out_figures': PosixPath('runs/alzheimer_study/figures'),
'out_folder': PosixPath('runs/alzheimer_study/diff_analysis/AD/PI_vs_CF'),
'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_CF/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.180 | 1 | 0.291 | 0.590 | 0.002 | 0.229 | 0.728 | False |
| age | 0.084 | 1 | 0.135 | 0.713 | 0.001 | 0.147 | 0.817 | False | |
| Kiel | 2.216 | 1 | 3.588 | 0.060 | 0.018 | 1.224 | 0.140 | False | |
| Magdeburg | 5.950 | 1 | 9.634 | 0.002 | 0.048 | 2.657 | 0.010 | True | |
| Sweden | 10.249 | 1 | 16.595 | 0.000 | 0.080 | 4.169 | 0.000 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.367 | 1 | 0.390 | 0.533 | 0.002 | 0.273 | 0.680 | False |
| age | 1.453 | 1 | 1.542 | 0.216 | 0.008 | 0.666 | 0.365 | False | |
| Kiel | 0.099 | 1 | 0.105 | 0.746 | 0.001 | 0.127 | 0.840 | False | |
| Magdeburg | 3.254 | 1 | 3.453 | 0.065 | 0.018 | 1.189 | 0.148 | False | |
| Sweden | 8.790 | 1 | 9.329 | 0.003 | 0.047 | 2.589 | 0.011 | True | |
7105 rows × 8 columns
Load selected comparison model scores#
| model | CF | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| var | SS | DF | F | p-unc | np2 | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 1.004 | 1 | 7.146 | 0.008 | 0.036 | 2.088 | 0.023 | True |
| age | 0.011 | 1 | 0.080 | 0.777 | 0.000 | 0.109 | 0.851 | False | |
| Kiel | 0.282 | 1 | 2.006 | 0.158 | 0.010 | 0.801 | 0.263 | False | |
| Magdeburg | 0.458 | 1 | 3.264 | 0.072 | 0.017 | 1.140 | 0.142 | False | |
| Sweden | 1.854 | 1 | 13.200 | 0.000 | 0.065 | 3.444 | 0.002 | True | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 2.139 | 1 | 4.030 | 0.046 | 0.021 | 1.336 | 0.098 | False |
| age | 0.663 | 1 | 1.250 | 0.265 | 0.007 | 0.577 | 0.393 | False | |
| Kiel | 3.146 | 1 | 5.926 | 0.016 | 0.030 | 1.800 | 0.040 | True | |
| Magdeburg | 3.688 | 1 | 6.947 | 0.009 | 0.035 | 2.042 | 0.025 | True | |
| Sweden | 16.290 | 1 | 30.686 | 0.000 | 0.138 | 7.002 | 0.000 | True | |
7105 rows × 8 columns
Combined scores#
show only selected statistics for comparsion
| model | CF | PI | |||||||
|---|---|---|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | rejected | p-unc | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.008 | 2.088 | 0.023 | True | 0.590 | 0.229 | 0.728 | False |
| Kiel | 0.158 | 0.801 | 0.263 | False | 0.060 | 1.224 | 0.140 | False | |
| Magdeburg | 0.072 | 1.140 | 0.142 | False | 0.002 | 2.657 | 0.010 | True | |
| Sweden | 0.000 | 3.444 | 0.002 | True | 0.000 | 4.169 | 0.000 | True | |
| age | 0.777 | 0.109 | 0.851 | False | 0.713 | 0.147 | 0.817 | False | |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| S4R3U6 | AD | 0.046 | 1.336 | 0.098 | False | 0.533 | 0.273 | 0.680 | False |
| Kiel | 0.016 | 1.800 | 0.040 | True | 0.746 | 0.127 | 0.840 | False | |
| Magdeburg | 0.009 | 2.042 | 0.025 | True | 0.065 | 1.189 | 0.148 | False | |
| Sweden | 0.000 | 7.002 | 0.000 | True | 0.003 | 2.589 | 0.011 | True | |
| age | 0.265 | 0.577 | 0.393 | False | 0.216 | 0.666 | 0.365 | False | |
7105 rows × 8 columns
Models in comparison (name mapping)
{'CF': 'CF', 'PI': 'PI'}
Describe scores#
| model | CF | PI | ||||
|---|---|---|---|---|---|---|
| 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.227 | 3.208 | 0.282 | 0.261 | 2.486 | 0.338 |
| std | 0.294 | 6.075 | 0.321 | 0.304 | 5.378 | 0.332 |
| min | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 | 0.000 |
| 25% | 0.001 | 0.402 | 0.002 | 0.004 | 0.327 | 0.015 |
| 50% | 0.066 | 1.184 | 0.131 | 0.119 | 0.925 | 0.238 |
| 75% | 0.396 | 3.240 | 0.528 | 0.471 | 2.440 | 0.628 |
| max | 1.000 | 86.062 | 1.000 | 1.000 | 143.804 | 1.000 |
One to one comparison of by feature:#
/tmp/ipykernel_102923/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 | CF | PI | |||||||
|---|---|---|---|---|---|---|---|---|---|
| var | p-unc | -Log10 pvalue | qvalue | rejected | p-unc | -Log10 pvalue | qvalue | rejected | |
| protein groups | Source | ||||||||
| A0A024QZX5;A0A087X1N8;P35237 | AD | 0.008 | 2.088 | 0.023 | True | 0.590 | 0.229 | 0.728 | False |
| A0A024R0T9;K7ER74;P02655 | AD | 0.036 | 1.446 | 0.080 | False | 0.059 | 1.228 | 0.139 | False |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | AD | 0.809 | 0.092 | 0.874 | False | 0.114 | 0.944 | 0.230 | False |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | AD | 0.263 | 0.580 | 0.391 | False | 0.524 | 0.281 | 0.672 | False |
| A0A075B6H7 | AD | 0.000 | 3.467 | 0.001 | True | 0.109 | 0.964 | 0.223 | False |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| Q9Y6R7 | AD | 0.175 | 0.756 | 0.285 | False | 0.175 | 0.756 | 0.315 | False |
| Q9Y6X5 | AD | 0.121 | 0.916 | 0.214 | False | 0.050 | 1.305 | 0.121 | False |
| Q9Y6Y8;Q9Y6Y8-2 | AD | 0.083 | 1.079 | 0.159 | False | 0.083 | 1.079 | 0.181 | False |
| Q9Y6Y9 | AD | 0.847 | 0.072 | 0.901 | False | 0.302 | 0.520 | 0.464 | False |
| S4R3U6 | AD | 0.046 | 1.336 | 0.098 | False | 0.533 | 0.273 | 0.680 | False |
1421 rows × 8 columns
And the descriptive statistics of the numeric values:
| model | CF | PI | ||||
|---|---|---|---|---|---|---|
| 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.242 | 1.588 | 0.303 | 0.254 | 1.405 | 0.336 |
| std | 0.294 | 1.871 | 0.316 | 0.292 | 1.623 | 0.319 |
| min | 0.000 | 0.000 | 0.000 | 0.000 | 0.001 | 0.000 |
| 25% | 0.007 | 0.385 | 0.020 | 0.011 | 0.352 | 0.036 |
| 50% | 0.089 | 1.049 | 0.168 | 0.125 | 0.904 | 0.247 |
| 75% | 0.412 | 2.151 | 0.543 | 0.444 | 1.960 | 0.605 |
| max | 1.000 | 23.338 | 1.000 | 0.997 | 23.616 | 0.998 |
and the boolean decision values
| model | CF | PI |
|---|---|---|
| var | rejected | rejected |
| count | 1421 | 1421 |
| unique | 2 | 2 |
| top | False | False |
| freq | 950 | 1027 |
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)
| CF | PI | frequency | Differential Analysis Comparison | |
|---|---|---|---|---|
| protein groups | ||||
| A0A024QZX5;A0A087X1N8;P35237 | 0.023 | 0.728 | 186 | CF (yes) - PI (no) |
| A0A024R0T9;K7ER74;P02655 | 0.080 | 0.139 | 195 | CF (no) - PI (no) |
| A0A024R3W6;A0A024R412;O60462;O60462-2;O60462-3;O60462-4;O60462-5;Q7LBX6;X5D2Q8 | 0.874 | 0.230 | 174 | CF (no) - PI (no) |
| A0A024R644;A0A0A0MRU5;A0A1B0GWI2;O75503 | 0.391 | 0.672 | 196 | CF (no) - PI (no) |
| A0A075B6H7 | 0.001 | 0.223 | 91 | CF (yes) - PI (no) |
| ... | ... | ... | ... | ... |
| Q9Y6R7 | 0.285 | 0.315 | 197 | CF (no) - PI (no) |
| Q9Y6X5 | 0.214 | 0.121 | 173 | CF (no) - PI (no) |
| Q9Y6Y8;Q9Y6Y8-2 | 0.159 | 0.181 | 197 | CF (no) - PI (no) |
| Q9Y6Y9 | 0.901 | 0.464 | 119 | CF (no) - PI (no) |
| S4R3U6 | 0.098 | 0.680 | 126 | CF (no) - PI (no) |
1421 rows × 4 columns
List of features with the highest difference in qvalues
| CF | PI | frequency | Differential Analysis Comparison | diff_qvalue | |
|---|---|---|---|---|---|
| protein groups | |||||
| A0A087WU43;A0A087WX17;A0A087WXI5;P12830;P12830-2 | 0.000 | 0.989 | 134 | CF (yes) - PI (no) | 0.989 |
| P22748 | 0.011 | 0.994 | 159 | CF (yes) - PI (no) | 0.983 |
| O15204;O15204-2 | 0.001 | 0.982 | 156 | CF (yes) - PI (no) | 0.981 |
| P37802;P37802-2;X6RJP6 | 0.975 | 0.022 | 110 | CF (no) - PI (yes) | 0.954 |
| Q9GZT8;Q9GZT8-2 | 0.002 | 0.948 | 86 | CF (yes) - PI (no) | 0.945 |
| ... | ... | ... | ... | ... | ... |
| F5GY80;F5H7G1;P07358 | 0.047 | 0.057 | 197 | CF (yes) - PI (no) | 0.010 |
| Q9NX62 | 0.046 | 0.055 | 197 | CF (yes) - PI (no) | 0.010 |
| Q16706 | 0.043 | 0.052 | 195 | CF (yes) - PI (no) | 0.009 |
| P00740;P00740-2 | 0.044 | 0.053 | 197 | CF (yes) - PI (no) | 0.009 |
| K7ERG9;P00746 | 0.043 | 0.052 | 197 | CF (yes) - PI (no) | 0.009 |
191 rows × 5 columns
Differences plotted with created annotations#
pimmslearn.plotting - INFO Saved Figures to runs/alzheimer_study/diff_analysis/AD/PI_vs_CF/diff_analysis_comparision_1_CF
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_CF/diff_analysis_comparision_2_CF
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 | ||
| APOE | ENSP00000252486 | 5.000 |
| PSEN1 | ENSP00000326366 | 5.000 |
| PSEN2 | ENSP00000355747 | 5.000 |
| APP | ENSP00000284981 | 5.000 |
| TREM2 | ENSP00000362205 | 4.825 |
| ... | ... | ... |
| CARMIL1 | ENSP00000331983 | 0.681 |
| CENPJ | ENSP00000371308 | 0.681 |
| ERP27 | ENSP00000266397 | 0.681 |
| ZNF585B | ENSP00000433773 | 0.681 |
| KIR3DL2 | ENSP00000325525 | 0.681 |
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()