flexynesis 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. flexynesis-0.2.6/PKG-INFO +127 -0
  2. flexynesis-0.2.6/README.md +91 -0
  3. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/__main__.py +9 -31
  4. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/utils.py +92 -0
  5. flexynesis-0.2.6/flexynesis.egg-info/PKG-INFO +127 -0
  6. {flexynesis-0.2.4 → flexynesis-0.2.6}/pyproject.toml +1 -1
  7. flexynesis-0.2.4/PKG-INFO +0 -273
  8. flexynesis-0.2.4/README.md +0 -237
  9. flexynesis-0.2.4/flexynesis.egg-info/PKG-INFO +0 -273
  10. {flexynesis-0.2.4 → flexynesis-0.2.6}/LICENCE.md +0 -0
  11. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/__init__.py +0 -0
  12. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/cli.py +0 -0
  13. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/config.py +0 -0
  14. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/data.py +0 -0
  15. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/feature_selection.py +0 -0
  16. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/main.py +0 -0
  17. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/__init__.py +0 -0
  18. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/crossmodal_pred.py +0 -0
  19. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/direct_pred.py +0 -0
  20. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/gnn_early.py +0 -0
  21. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/on_ice/direct_pred_cnn.py +0 -0
  22. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/on_ice/direct_pred_gcnn.py +0 -0
  23. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/on_ice/modules_on_ice.py +0 -0
  24. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/supervised_vae.py +0 -0
  25. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/models/triplet_encoder.py +0 -0
  26. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis/modules.py +0 -0
  27. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis.egg-info/SOURCES.txt +0 -0
  28. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis.egg-info/dependency_links.txt +0 -0
  29. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis.egg-info/entry_points.txt +0 -0
  30. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis.egg-info/requires.txt +0 -0
  31. {flexynesis-0.2.4 → flexynesis-0.2.6}/flexynesis.egg-info/top_level.txt +0 -0
  32. {flexynesis-0.2.4 → flexynesis-0.2.6}/setup.cfg +0 -0
  33. {flexynesis-0.2.4 → flexynesis-0.2.6}/tests/__init__.py +0 -0
  34. {flexynesis-0.2.4 → flexynesis-0.2.6}/tests/unit/__init__.py +0 -0
  35. {flexynesis-0.2.4 → flexynesis-0.2.6}/tests/unit/test_smoke.py +0 -0
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.1
2
+ Name: flexynesis
3
+ Version: 0.2.6
4
+ Summary: A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical endpoint prediction.
5
+ Author-email: Bora Uyar <bora.uyar@mdc-berlin.de>, Taras Savchyn <Taras.Savchyn@mdc-berlin.de>, Ricardo Wurmus <Ricardo.Wurmus@mdc-berlin.de>, Ahmet Sarigun <Ahmet.Sariguen@mdc-berlin.de>
6
+ Project-URL: homepage, https://github.com/BIMSBbioinfo/flexynesis
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Requires-Python: <3.12,>=3.11
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENCE.md
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Requires-Dist: lightning
17
+ Requires-Dist: pyyaml
18
+ Requires-Dist: scikit-optimize
19
+ Requires-Dist: scipy
20
+ Requires-Dist: seaborn
21
+ Requires-Dist: torch
22
+ Requires-Dist: torchvision
23
+ Requires-Dist: tqdm
24
+ Requires-Dist: umap-learn
25
+ Requires-Dist: rich
26
+ Requires-Dist: captum
27
+ Requires-Dist: ipywidgets
28
+ Requires-Dist: torch_geometric
29
+ Requires-Dist: ipykernel
30
+ Requires-Dist: lifelines
31
+ Requires-Dist: papermill
32
+ Requires-Dist: scikit-survival
33
+ Requires-Dist: python-louvain
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest; extra == "test"
36
+
37
+
38
+ <p align="center">
39
+ <img alt="logo" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/logo.png" width="50%" height="50%">
40
+ </p>
41
+
42
+ [![Downloads](https://static.pepy.tech/badge/flexynesis)](https://pepy.tech/project/flexynesis)
43
+ ![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC_BY--NC--ND_4.0-lightgrey.svg)
44
+ ![benchmarks](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/benchmarks.yml/badge.svg)
45
+ ![tutorials](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/tutorials.yml/badge.svg)
46
+
47
+ # flexynesis
48
+
49
+ A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical
50
+ endpoint prediction. The package includes multiple types of deep learning architectures such as simple
51
+ fully connected networks, supervised variational autoencoders, graph convolutional networks, multi-triplet networks
52
+ different options of data layer fusion, and automates feature selection and hyperparameter optimisation. The tools are continuosly benchmarked on publicly available datasets mostly related to the study of cancer. Some of the applications of the methods
53
+ we develop are drug response modeling in cancer patients or preclinical models (such as cell lines and
54
+ patient-derived xenografts), cancer subtype prediction, or any other clinically relevant outcome prediction
55
+ that can be formulated as a regression, classification, survival, or cross-modality prediction problem.
56
+
57
+ <p align="center">
58
+ <img alt="workflow" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/graphical_abstract.jpg">
59
+ </p>
60
+
61
+ # Citing our work
62
+
63
+ In order to refer to our work, please cite our manuscript currently available at [BioRxiv](https://biorxiv.org/cgi/content/short/2024.07.16.603606v1).
64
+
65
+ # Getting started with Flexynesis
66
+
67
+ ## Command-line tutorial
68
+
69
+ - [Getting Started with Flexynesis](https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis/site/getting_started/)
70
+
71
+ ## Jupyter notebooks for interactive usage
72
+
73
+ - [Modeling Breast Cancer Subtypes](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/brca_subtypes.ipynb)
74
+ - [Survival Markers of Lower Grade Gliomas](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/survival_subtypes_LGG_GBM.ipynb)
75
+ - [Unsupervised Analysis of Bone Marrow Cells](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/unsupervised_analysis_single_cell.ipynb)
76
+
77
+
78
+ # Benchmarks
79
+
80
+ For the latest benchmark results see:
81
+ https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis-benchmark-datasets/dashboard.html
82
+
83
+ The code for the benchmarking pipeline is at: https://github.com/BIMSBbioinfo/flexynesis-benchmarks
84
+
85
+
86
+ # Defining Kernel for the Jupyter Notebook
87
+
88
+ For interactively using flexynesis on Jupyter notebooks, one can define the kernel to make
89
+ flexynesis and its dependencies available on the jupyter session.
90
+
91
+ Assuming you have already defined an environment and installed the package:
92
+ ```
93
+ conda activate flexynesisenv
94
+ python -m ipykernel install --user --name "flexynesisenv" --display-name "flexynesisenv"
95
+ ```
96
+
97
+ # Compiling Notebooks
98
+
99
+ `papermill` can be used to compile the tutorials under `examples/tutorials`.
100
+
101
+ If the purpose is to quickly check if the notebook can be run; set HPO_ITER to 1.
102
+ This sets hyperparameter optimisation steps to 1.
103
+ For longer training runs to see more meaningful results from the notebook, increase this number to e.g. 50.
104
+
105
+ Example:
106
+
107
+ ```
108
+ papermill examples/tutorials/brca_subtypes.ipynb brca_subtypes.ipynb -p HPO_ITER 1
109
+ ```
110
+
111
+ The output from papermill can be converted to an html file as follows:
112
+
113
+ ```
114
+ jupyter nbconvert --to html brca_subtypes.ipynb
115
+ ```
116
+
117
+ # Documentation
118
+
119
+ Documentation generated using [mkdocs](https://mkdocstrings.github.io/)
120
+
121
+ ```
122
+ pip install mkdocstrings[python]
123
+ mkdocs build --clean
124
+ ```
125
+
126
+
127
+
@@ -0,0 +1,91 @@
1
+
2
+ <p align="center">
3
+ <img alt="logo" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/logo.png" width="50%" height="50%">
4
+ </p>
5
+
6
+ [![Downloads](https://static.pepy.tech/badge/flexynesis)](https://pepy.tech/project/flexynesis)
7
+ ![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC_BY--NC--ND_4.0-lightgrey.svg)
8
+ ![benchmarks](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/benchmarks.yml/badge.svg)
9
+ ![tutorials](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/tutorials.yml/badge.svg)
10
+
11
+ # flexynesis
12
+
13
+ A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical
14
+ endpoint prediction. The package includes multiple types of deep learning architectures such as simple
15
+ fully connected networks, supervised variational autoencoders, graph convolutional networks, multi-triplet networks
16
+ different options of data layer fusion, and automates feature selection and hyperparameter optimisation. The tools are continuosly benchmarked on publicly available datasets mostly related to the study of cancer. Some of the applications of the methods
17
+ we develop are drug response modeling in cancer patients or preclinical models (such as cell lines and
18
+ patient-derived xenografts), cancer subtype prediction, or any other clinically relevant outcome prediction
19
+ that can be formulated as a regression, classification, survival, or cross-modality prediction problem.
20
+
21
+ <p align="center">
22
+ <img alt="workflow" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/graphical_abstract.jpg">
23
+ </p>
24
+
25
+ # Citing our work
26
+
27
+ In order to refer to our work, please cite our manuscript currently available at [BioRxiv](https://biorxiv.org/cgi/content/short/2024.07.16.603606v1).
28
+
29
+ # Getting started with Flexynesis
30
+
31
+ ## Command-line tutorial
32
+
33
+ - [Getting Started with Flexynesis](https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis/site/getting_started/)
34
+
35
+ ## Jupyter notebooks for interactive usage
36
+
37
+ - [Modeling Breast Cancer Subtypes](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/brca_subtypes.ipynb)
38
+ - [Survival Markers of Lower Grade Gliomas](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/survival_subtypes_LGG_GBM.ipynb)
39
+ - [Unsupervised Analysis of Bone Marrow Cells](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/unsupervised_analysis_single_cell.ipynb)
40
+
41
+
42
+ # Benchmarks
43
+
44
+ For the latest benchmark results see:
45
+ https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis-benchmark-datasets/dashboard.html
46
+
47
+ The code for the benchmarking pipeline is at: https://github.com/BIMSBbioinfo/flexynesis-benchmarks
48
+
49
+
50
+ # Defining Kernel for the Jupyter Notebook
51
+
52
+ For interactively using flexynesis on Jupyter notebooks, one can define the kernel to make
53
+ flexynesis and its dependencies available on the jupyter session.
54
+
55
+ Assuming you have already defined an environment and installed the package:
56
+ ```
57
+ conda activate flexynesisenv
58
+ python -m ipykernel install --user --name "flexynesisenv" --display-name "flexynesisenv"
59
+ ```
60
+
61
+ # Compiling Notebooks
62
+
63
+ `papermill` can be used to compile the tutorials under `examples/tutorials`.
64
+
65
+ If the purpose is to quickly check if the notebook can be run; set HPO_ITER to 1.
66
+ This sets hyperparameter optimisation steps to 1.
67
+ For longer training runs to see more meaningful results from the notebook, increase this number to e.g. 50.
68
+
69
+ Example:
70
+
71
+ ```
72
+ papermill examples/tutorials/brca_subtypes.ipynb brca_subtypes.ipynb -p HPO_ITER 1
73
+ ```
74
+
75
+ The output from papermill can be converted to an html file as follows:
76
+
77
+ ```
78
+ jupyter nbconvert --to html brca_subtypes.ipynb
79
+ ```
80
+
81
+ # Documentation
82
+
83
+ Documentation generated using [mkdocs](https://mkdocstrings.github.io/)
84
+
85
+ ```
86
+ pip install mkdocstrings[python]
87
+ mkdocs build --clean
88
+ ```
89
+
90
+
91
+
@@ -18,16 +18,14 @@ def main():
18
18
 
19
19
  Args:
20
20
  --data_path (str): Path to the folder with train/test data files. (Required)
21
- --model_class (str): The kind of model class to instantiate. Choices are ["DirectPred", "GNN", "supervised_vae",
22
- "MultiTripletNetwork", "CrossModalPred", "RandomForest", "SVM", "RandomSurvivalForest"]. (Required)
21
+ --model_class (str): The kind of model class to instantiate. Choices are ["DirectPred", "GNN", "supervised_vae", "MultiTripletNetwork", "CrossModalPred", "RandomForest", "SVM", "RandomSurvivalForest"]. (Required)
23
22
  --gnn_conv_type (str): If model_class is set to GNN, choose which graph convolution type to use. Choices are ["GC", "GCN", "SAGE"].
24
23
  --target_variables (str): Which variables in 'clin.csv' to use for predictions, comma-separated if multiple. Optional if survival variables are not set to None.
25
- --batch_variables (str): Which variables in 'clin.csv' to use for data integration/batch correction, comma-separated if multiple. Optional.
26
24
  --surv_event_var (str): Which column in 'clin.csv' to use as event/status indicator for survival modeling.
27
25
  --surv_time_var (str): Which column in 'clin.csv' to use as time/duration indicator for survival modeling.
28
26
  --config_path (str): Optional path to an external hyperparameter configuration file in YAML format.
29
27
  --fusion_type (str): How to fuse the omics layers. Choices are ["early", "intermediate"]. Default is 'intermediate'.
30
- --hpo_iter (int): Number of iterations for hyperparameter optimisation. Default is 5.
28
+ --hpo_iter (int): Number of iterations for hyperparameter optimisation. Default is 100.
31
29
  --finetuning_samples (int): Number of samples from the test dataset to use for fine-tuning the model. Set to 0 to disable fine-tuning. Default is 0.
32
30
  --variance_threshold (float): Variance threshold (as percentile) to drop low variance features. Default is 1; set to 0 for no variance filtering.
33
31
  --correlation_threshold (float): Correlation threshold to drop highly redundant features. Default is 0.8; set to 1 for no redundancy filtering.
@@ -65,14 +63,11 @@ def main():
65
63
  help="(Optional if survival variables are not set to None)."
66
64
  "Which variables in 'clin.csv' to use for predictions, comma-separated if multiple",
67
65
  type = str, default = None)
68
- parser.add_argument("--batch_variables",
69
- help="(Optional) Which variables in 'clin.csv' to use for data integration / batch correction, comma-separated if multiple",
70
- type = str, default = None)
71
66
  parser.add_argument("--surv_event_var", help="Which column in 'clin.csv' to use as event/status indicator for survival modeling", type = str, default = None)
72
67
  parser.add_argument("--surv_time_var", help="Which column in 'clin.csv' to use as time/duration indicator for survival modeling", type = str, default = None)
73
68
  parser.add_argument('--config_path', type=str, default=None, help='Optional path to an external hyperparameter configuration file in YAML format.')
74
69
  parser.add_argument("--fusion_type", help="How to fuse the omics layers", type=str, choices=["early", "intermediate"], default = 'intermediate')
75
- parser.add_argument("--hpo_iter", help="Number of iterations for hyperparameter optimisation", type=int, default = 5)
70
+ parser.add_argument("--hpo_iter", help="Number of iterations for hyperparameter optimisation", type=int, default = 100)
76
71
  parser.add_argument("--finetuning_samples", help="Number of samples from the test dataset to use for fine-tuning the model. Set to 0 to disable fine-tuning", type=int, default = 0)
77
72
  parser.add_argument("--variance_threshold", help="Variance threshold (as percentile) to drop low variance features (default is 1; set to 0 for no variance filtering)", type=float, default = 1)
78
73
  parser.add_argument("--correlation_threshold", help="Correlation threshold to drop highly redundant features (default is 0.8; set to 1 for no redundancy filtering)", type=float, default = 0.8)
@@ -95,7 +90,7 @@ def main():
95
90
  parser.add_argument("--prefix", help="Job prefix to use for output files", type=str, default = 'job')
96
91
  parser.add_argument("--log_transform", help="whether to apply log-transformation to input data matrices", type=str, choices=['True', 'False'], default = 'False')
97
92
  parser.add_argument("--early_stop_patience", help="How many epochs to wait when no improvements in validation loss is observed (default 10; set to -1 to disable early stopping)", type=int, default = 10)
98
- parser.add_argument("--hpo_patience", help="How many hyperparamater optimisation iterations to wait for when no improvements are observed (default is 10; set to 0 to disable early stopping)", type=int, default = 10)
93
+ parser.add_argument("--hpo_patience", help="How many hyperparamater optimisation iterations to wait for when no improvements are observed (default is 10; set to 0 to disable early stopping)", type=int, default = 20)
99
94
  parser.add_argument("--use_cv", action="store_true",
100
95
  help="(Optional) If set, the a 5-fold cross-validation training will be done. Otherwise, a single trainig on 80 percent of the dataset is done.")
101
96
  parser.add_argument("--use_loss_weighting", help="whether to apply loss-balancing using uncertainty weights method", type=str, choices=['True', 'False'], default = 'True')
@@ -120,11 +115,10 @@ def main():
120
115
 
121
116
  # 2. Check for required variables for model classes
122
117
  if args.model_class != "supervised_vae" and args.model_class != 'CrossModalPred':
123
- if not any([args.target_variables, args.surv_event_var, args.batch_variables]):
118
+ if not any([args.target_variables, args.surv_event_var]):
124
119
  parser.error(''.join(["When selecting a model other than 'supervised_vae' or 'CrossModalPred',",
125
120
  "you must provide at least one of --target_variables, ",
126
- "survival variables (--surv_event_var and --surv_time_var)",
127
- "or --batch_variables."]))
121
+ "or survival variables (--surv_event_var and --surv_time_var)"]))
128
122
 
129
123
  # 3. Check for compatibility of fusion_type with GNN
130
124
  if args.fusion_type == "early":
@@ -142,12 +136,10 @@ def main():
142
136
  "`srun --gpus=1 --pty flexynesis <rest of your_command>` !!!\n\n"]))
143
137
  time.sleep(3) #wait a bit to capture user's attention to the warning
144
138
  device_type = 'cpu'
145
- torch.set_num_threads(args.threads)
146
139
  else:
147
140
  device_type = 'gpu'
148
141
  else:
149
142
  device_type = 'cpu'
150
- torch.set_num_threads(args.threads)
151
143
 
152
144
  # 5. check GNN arguments
153
145
  if args.model_class == 'GNN':
@@ -277,7 +269,7 @@ def main():
277
269
  tuner = flexynesis.HyperparameterTuning(dataset = train_dataset,
278
270
  model_class = model_class,
279
271
  target_variables = args.target_variables.strip().split(',') if args.target_variables is not None else [],
280
- batch_variables = args.batch_variables.strip().split(',') if args.batch_variables is not None else None,
272
+ batch_variables = None,
281
273
  surv_event_var = args.surv_event_var,
282
274
  surv_time_var = args.surv_time_var,
283
275
  config_name = config_name,
@@ -325,7 +317,7 @@ def main():
325
317
  embeddings_test.to_csv(os.path.join(args.outdir, '.'.join([args.prefix, 'embeddings_test.csv'])), header=True)
326
318
 
327
319
  # evaluate predictions; (if any supervised learning happened)
328
- if any([args.target_variables, args.surv_event_var, args.batch_variables]):
320
+ if any([args.target_variables, args.surv_event_var]):
329
321
  if not args.disable_marker_finding: # unless marker discovery is disabled
330
322
  # compute feature importance values
331
323
  print("[INFO] Computing variable importance scores")
@@ -348,20 +340,6 @@ def main():
348
340
  metrics_df.to_csv(os.path.join(args.outdir, '.'.join([args.prefix, 'stats.csv'])), header=True, index=False)
349
341
 
350
342
 
351
- # also filter embeddings to remove batch-associated dims and only keep target-variable associated dims
352
- if args.batch_variables is not None:
353
- print("[INFO] Printing filtered embeddings")
354
- embeddings_train_filtered = flexynesis.remove_batch_associated_variables(data = embeddings_train,
355
- batch_dict={x: train_dataset.ann[x] for x in model.batch_variables} if model.batch_variables is not None else None,
356
- target_dict={x: train_dataset.ann[x] for x in model.target_variables},
357
- variable_types=train_dataset.variable_types)
358
- # filter test embeddings to keep the same dims as the filtered training embeddings
359
- embeddings_test_filtered = embeddings_test[embeddings_train_filtered.columns]
360
-
361
- # save
362
- embeddings_train_filtered.to_csv(os.path.join(args.outdir, '.'.join([args.prefix, 'embeddings_train.filtered.csv'])), header=True)
363
- embeddings_test_filtered.to_csv(os.path.join(args.outdir, '.'.join([args.prefix, 'embeddings_test.filtered.csv'])), header=True)
364
-
365
343
  # for architectures with decoders; print decoded output layers
366
344
  if args.model_class == 'CrossModalPred':
367
345
  print("[INFO] Printing decoded output layers")
@@ -408,4 +386,4 @@ def main():
408
386
 
409
387
  if __name__ == "__main__":
410
388
  main()
411
- print("[INFO] Finished the analysis!")
389
+ print("[INFO] Finished the analysis!")
@@ -199,6 +199,23 @@ def evaluate_survival(outputs, durations, events):
199
199
  return {'cindex': c_index}
200
200
 
201
201
  def evaluate_classifier(y_true, y_pred, print_report = False):
202
+ """
203
+ Evaluate the performance of a classifier using multiple metrics and optionally print a detailed classification report.
204
+
205
+ This function computes balanced accuracy, F1 score (macro), and Cohen's Kappa score for the given true and predicted labels.
206
+ If `print_report` is set to True, it prints a detailed classification report.
207
+
208
+ Args:
209
+ y_true (array-like): True labels of the data, must be 1D list or array of labels.
210
+ y_pred (array-like): Predicted labels as returned by a classifier, must match the dimensions of y_true.
211
+ print_report (bool, optional): If True, prints a detailed classification report. Defaults to False.
212
+
213
+ Returns:
214
+ dict: A dictionary containing:
215
+ - 'balanced_acc': The balanced accuracy of the predictions.
216
+ - 'f1_score': The macro-average F1 score of the predictions.
217
+ - 'kappa': Cohen's Kappa score indicating the level of agreement between the true and predicted labels.
218
+ """
202
219
  # Balanced accuracy
203
220
  balanced_acc = balanced_accuracy_score(y_true, y_pred)
204
221
  # F1 score (macro)
@@ -213,12 +230,48 @@ def evaluate_classifier(y_true, y_pred, print_report = False):
213
230
  return {"balanced_acc": balanced_acc, "f1_score": f1, "kappa": kappa}
214
231
 
215
232
  def evaluate_regressor(y_true, y_pred):
233
+ """
234
+ Evaluate the performance of a regression model using mean squared error, R-squared, and Pearson correlation coefficient.
235
+
236
+ This function computes the mean squared error (MSE) between true and predicted values as a measure of prediction accuracy.
237
+ It also performs a linear regression analysis between the true and predicted values to obtain the R-squared value, which
238
+ explains the variance ratio, and the Pearson correlation coefficient, providing insight into the linear relationship strength.
239
+
240
+ Args:
241
+ y_true (array-like): True values of the dependent variable, must be a 1D list or array.
242
+ y_pred (array-like): Predicted values as returned by a regressor, must match the dimensions of y_true.
243
+
244
+ Returns:
245
+ dict: A dictionary containing:
246
+ - 'mse': The mean squared error between the true and predicted values.
247
+ - 'r2': The R-squared value indicating the proportion of variance in the dependent variable predictable from the independent variable.
248
+ - 'pearson_corr': The Pearson correlation coefficient indicating the linear relationship strength between the true and predicted values.
249
+ """
216
250
  mse = mean_squared_error(y_true, y_pred)
217
251
  slope, intercept, r_value, p_value, std_err = linregress(y_true,y_pred)
218
252
  r2 = r_value**2
219
253
  return {"mse": mse, "r2": r2, "pearson_corr": r_value}
220
254
 
221
255
  def evaluate_wrapper(method, y_pred_dict, dataset, surv_event_var = None, surv_time_var = None):
256
+ """
257
+ Evaluates predictions for different variables within a dataset using appropriate metrics based on the variable type.
258
+ Supports evaluation for numerical, categorical, and survival data.
259
+
260
+ This function loops through each variable in the predictions dictionary, determines the type of the variable,
261
+ and evaluates the predictions using the appropriate method: regression, classification, or survival analysis.
262
+ It compiles the metrics into a list of dictionaries, which is then converted into a pandas DataFrame.
263
+
264
+ Args:
265
+ method (str): Identifier for the prediction method or model used.
266
+ y_pred_dict (dict): A dictionary where keys are variable names and values are arrays of predicted values.
267
+ dataset (Dataset): A dataset object containing actual values and metadata such as variable types.
268
+ surv_event_var (str, optional): The name of the survival event variable. Required if survival analysis is performed.
269
+ surv_time_var (str, optional): The name of the survival time variable. Required if survival analysis is performed.
270
+
271
+ Returns:
272
+ pd.DataFrame: A DataFrame where each row contains the method, variable name, variable type, metric name, and metric value.
273
+
274
+ """
222
275
  metrics_list = []
223
276
  for var in y_pred_dict.keys():
224
277
  if dataset.variable_types[var] == 'numerical':
@@ -265,6 +318,25 @@ def get_predicted_labels(y_pred_dict, dataset, split):
265
318
  return pd.concat(dfs, ignore_index=True)
266
319
 
267
320
  def evaluate_baseline_performance(train_dataset, test_dataset, variable_name, methods, n_folds=5, n_jobs=4):
321
+ """
322
+ Evaluates the performance of RandomForest and/or Support Vector Machine models on a given variable from the provided datasets using cross-validation.
323
+
324
+ This function preprocesses the training and testing data, performs grid search with cross-validation to find the best
325
+ hyperparameters for the specified methods, and then evaluates the performance of these models on the testing set.
326
+ It supports evaluation for both categorical and numerical variables using appropriate machine learning models.
327
+
328
+ Args:
329
+ train_dataset (Dataset): A MultiOmicDataset object containing training data and metadata such as variable types.
330
+ test_dataset (Dataset): A MultiOmicDataset object containing testing data.
331
+ variable_name (str): The name of the target variable for prediction.
332
+ methods (list of str): List of machine learning methods to evaluate, e.g., ['RandomForest', 'SVM'].
333
+ n_folds (int, optional): Number of folds to use in K-fold cross-validation. Defaults to 5.
334
+ n_jobs (int, optional): Number of jobs to run in parallel during grid search. Defaults to 4.
335
+
336
+ Returns:
337
+ pd.DataFrame: A DataFrame containing the method, variable name, variable type, metric name, and metric value for each tested method.
338
+
339
+ """
268
340
  def prepare_data(data_object):
269
341
  # Concatenate Data Matrices
270
342
  X = np.concatenate([tensor for tensor in data_object.dat.values()], axis=1)
@@ -332,6 +404,26 @@ def evaluate_baseline_performance(train_dataset, test_dataset, variable_name, me
332
404
  return pd.DataFrame(metrics_list)
333
405
 
334
406
  def evaluate_baseline_survival_performance(train_dataset, test_dataset, duration_col, event_col, n_folds=5, n_jobs=4):
407
+ """
408
+ Evaluates the baseline performance of a Random Survival Forest model on survival data using the Concordance Index.
409
+
410
+ The function preprocesses both training and testing datasets to prepare appropriate survival data (comprising durations
411
+ and event occurrences), performs cross-validation to assess model robustness, and then calculates the Concordance Index on
412
+ the test data. It uses a Random Survival Forest (RSF) as the predictive model.
413
+
414
+ Args:
415
+ train_dataset (Dataset): The training dataset (a MultiOmicDataset object) containing features and survival data.
416
+ test_dataset (Dataset): The testing dataset (a MultiOmicDataset object) containing features and survival data.
417
+ duration_col (str): Column name in the dataset for survival time.
418
+ event_col (str): Column name in the dataset for the event occurrence (1 if event occurred, 0 otherwise).
419
+ n_folds (int, optional): Number of folds for K-fold cross-validation. Defaults to 5.
420
+ n_jobs (int, optional): Number of parallel jobs to run for Random Survival Forest training. Defaults to 4.
421
+
422
+ Returns:
423
+ pd.DataFrame: A DataFrame containing the performance metrics of the RSF model, specifically the Concordance Index,
424
+ listed along with the method name and variable details.
425
+
426
+ """
335
427
  print(f"[INFO] Evaluating baseline survival prediction performance")
336
428
  def prepare_data(data_object, duration_col, event_col):
337
429
  # Concatenate Data Matrices
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.1
2
+ Name: flexynesis
3
+ Version: 0.2.6
4
+ Summary: A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical endpoint prediction.
5
+ Author-email: Bora Uyar <bora.uyar@mdc-berlin.de>, Taras Savchyn <Taras.Savchyn@mdc-berlin.de>, Ricardo Wurmus <Ricardo.Wurmus@mdc-berlin.de>, Ahmet Sarigun <Ahmet.Sariguen@mdc-berlin.de>
6
+ Project-URL: homepage, https://github.com/BIMSBbioinfo/flexynesis
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Requires-Python: <3.12,>=3.11
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENCE.md
13
+ Requires-Dist: matplotlib
14
+ Requires-Dist: numpy
15
+ Requires-Dist: pandas
16
+ Requires-Dist: lightning
17
+ Requires-Dist: pyyaml
18
+ Requires-Dist: scikit-optimize
19
+ Requires-Dist: scipy
20
+ Requires-Dist: seaborn
21
+ Requires-Dist: torch
22
+ Requires-Dist: torchvision
23
+ Requires-Dist: tqdm
24
+ Requires-Dist: umap-learn
25
+ Requires-Dist: rich
26
+ Requires-Dist: captum
27
+ Requires-Dist: ipywidgets
28
+ Requires-Dist: torch_geometric
29
+ Requires-Dist: ipykernel
30
+ Requires-Dist: lifelines
31
+ Requires-Dist: papermill
32
+ Requires-Dist: scikit-survival
33
+ Requires-Dist: python-louvain
34
+ Provides-Extra: test
35
+ Requires-Dist: pytest; extra == "test"
36
+
37
+
38
+ <p align="center">
39
+ <img alt="logo" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/logo.png" width="50%" height="50%">
40
+ </p>
41
+
42
+ [![Downloads](https://static.pepy.tech/badge/flexynesis)](https://pepy.tech/project/flexynesis)
43
+ ![License: CC BY-NC-ND 4.0](https://img.shields.io/badge/License-CC_BY--NC--ND_4.0-lightgrey.svg)
44
+ ![benchmarks](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/benchmarks.yml/badge.svg)
45
+ ![tutorials](https://github.com/BIMSBbioinfo/flexynesis/actions/workflows/tutorials.yml/badge.svg)
46
+
47
+ # flexynesis
48
+
49
+ A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical
50
+ endpoint prediction. The package includes multiple types of deep learning architectures such as simple
51
+ fully connected networks, supervised variational autoencoders, graph convolutional networks, multi-triplet networks
52
+ different options of data layer fusion, and automates feature selection and hyperparameter optimisation. The tools are continuosly benchmarked on publicly available datasets mostly related to the study of cancer. Some of the applications of the methods
53
+ we develop are drug response modeling in cancer patients or preclinical models (such as cell lines and
54
+ patient-derived xenografts), cancer subtype prediction, or any other clinically relevant outcome prediction
55
+ that can be formulated as a regression, classification, survival, or cross-modality prediction problem.
56
+
57
+ <p align="center">
58
+ <img alt="workflow" src="https://github.com/BIMSBbioinfo/flexynesis/raw/main/img/graphical_abstract.jpg">
59
+ </p>
60
+
61
+ # Citing our work
62
+
63
+ In order to refer to our work, please cite our manuscript currently available at [BioRxiv](https://biorxiv.org/cgi/content/short/2024.07.16.603606v1).
64
+
65
+ # Getting started with Flexynesis
66
+
67
+ ## Command-line tutorial
68
+
69
+ - [Getting Started with Flexynesis](https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis/site/getting_started/)
70
+
71
+ ## Jupyter notebooks for interactive usage
72
+
73
+ - [Modeling Breast Cancer Subtypes](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/brca_subtypes.ipynb)
74
+ - [Survival Markers of Lower Grade Gliomas](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/survival_subtypes_LGG_GBM.ipynb)
75
+ - [Unsupervised Analysis of Bone Marrow Cells](https://github.com/BIMSBbioinfo/flexynesis/blob/main/examples/tutorials/unsupervised_analysis_single_cell.ipynb)
76
+
77
+
78
+ # Benchmarks
79
+
80
+ For the latest benchmark results see:
81
+ https://bimsbstatic.mdc-berlin.de/akalin/buyar/flexynesis-benchmark-datasets/dashboard.html
82
+
83
+ The code for the benchmarking pipeline is at: https://github.com/BIMSBbioinfo/flexynesis-benchmarks
84
+
85
+
86
+ # Defining Kernel for the Jupyter Notebook
87
+
88
+ For interactively using flexynesis on Jupyter notebooks, one can define the kernel to make
89
+ flexynesis and its dependencies available on the jupyter session.
90
+
91
+ Assuming you have already defined an environment and installed the package:
92
+ ```
93
+ conda activate flexynesisenv
94
+ python -m ipykernel install --user --name "flexynesisenv" --display-name "flexynesisenv"
95
+ ```
96
+
97
+ # Compiling Notebooks
98
+
99
+ `papermill` can be used to compile the tutorials under `examples/tutorials`.
100
+
101
+ If the purpose is to quickly check if the notebook can be run; set HPO_ITER to 1.
102
+ This sets hyperparameter optimisation steps to 1.
103
+ For longer training runs to see more meaningful results from the notebook, increase this number to e.g. 50.
104
+
105
+ Example:
106
+
107
+ ```
108
+ papermill examples/tutorials/brca_subtypes.ipynb brca_subtypes.ipynb -p HPO_ITER 1
109
+ ```
110
+
111
+ The output from papermill can be converted to an html file as follows:
112
+
113
+ ```
114
+ jupyter nbconvert --to html brca_subtypes.ipynb
115
+ ```
116
+
117
+ # Documentation
118
+
119
+ Documentation generated using [mkdocs](https://mkdocstrings.github.io/)
120
+
121
+ ```
122
+ pip install mkdocstrings[python]
123
+ mkdocs build --clean
124
+ ```
125
+
126
+
127
+
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "flexynesis"
7
- version = "0.2.4"
7
+ version = "0.2.6"
8
8
  authors = [
9
9
  {name = "Bora Uyar", email = "bora.uyar@mdc-berlin.de"},
10
10
  {name = "Taras Savchyn", email = "Taras.Savchyn@mdc-berlin.de"},