flexynesis 0.2.4__tar.gz → 0.2.5__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.
- {flexynesis-0.2.4 → flexynesis-0.2.5}/PKG-INFO +2 -2
- {flexynesis-0.2.4 → flexynesis-0.2.5}/README.md +1 -1
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/__main__.py +2 -5
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/utils.py +92 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/PKG-INFO +2 -2
- {flexynesis-0.2.4 → flexynesis-0.2.5}/pyproject.toml +1 -1
- {flexynesis-0.2.4 → flexynesis-0.2.5}/LICENCE.md +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/__init__.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/cli.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/config.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/data.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/feature_selection.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/main.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/__init__.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/crossmodal_pred.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/direct_pred.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/gnn_early.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/on_ice/direct_pred_cnn.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/on_ice/direct_pred_gcnn.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/on_ice/modules_on_ice.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/supervised_vae.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/models/triplet_encoder.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis/modules.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/SOURCES.txt +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/dependency_links.txt +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/entry_points.txt +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/requires.txt +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/flexynesis.egg-info/top_level.txt +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/setup.cfg +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/tests/__init__.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/tests/unit/__init__.py +0 -0
- {flexynesis-0.2.4 → flexynesis-0.2.5}/tests/unit/test_smoke.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flexynesis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical endpoint prediction.
|
|
5
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
6
|
Project-URL: homepage, https://github.com/BIMSBbioinfo/flexynesis
|
|
@@ -113,7 +113,7 @@ flexynesis --data_path dataset1 \
|
|
|
113
113
|
--prefix erlotinib_direct \
|
|
114
114
|
--early_stop_patience 3 \
|
|
115
115
|
--use_loss_weighting False \
|
|
116
|
-
--evaluate_baseline_performance
|
|
116
|
+
--evaluate_baseline_performance
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
## Accelerating with GPUs
|
|
@@ -18,8 +18,7 @@ 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
24
|
--batch_variables (str): Which variables in 'clin.csv' to use for data integration/batch correction, comma-separated if multiple. Optional.
|
|
@@ -142,12 +141,10 @@ def main():
|
|
|
142
141
|
"`srun --gpus=1 --pty flexynesis <rest of your_command>` !!!\n\n"]))
|
|
143
142
|
time.sleep(3) #wait a bit to capture user's attention to the warning
|
|
144
143
|
device_type = 'cpu'
|
|
145
|
-
torch.set_num_threads(args.threads)
|
|
146
144
|
else:
|
|
147
145
|
device_type = 'gpu'
|
|
148
146
|
else:
|
|
149
147
|
device_type = 'cpu'
|
|
150
|
-
torch.set_num_threads(args.threads)
|
|
151
148
|
|
|
152
149
|
# 5. check GNN arguments
|
|
153
150
|
if args.model_class == 'GNN':
|
|
@@ -408,4 +405,4 @@ def main():
|
|
|
408
405
|
|
|
409
406
|
if __name__ == "__main__":
|
|
410
407
|
main()
|
|
411
|
-
print("[INFO] Finished the analysis!")
|
|
408
|
+
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: flexynesis
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: A deep-learning based multi-omics bulk sequencing data integration suite with a focus on (pre-)clinical endpoint prediction.
|
|
5
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
6
|
Project-URL: homepage, https://github.com/BIMSBbioinfo/flexynesis
|
|
@@ -113,7 +113,7 @@ flexynesis --data_path dataset1 \
|
|
|
113
113
|
--prefix erlotinib_direct \
|
|
114
114
|
--early_stop_patience 3 \
|
|
115
115
|
--use_loss_weighting False \
|
|
116
|
-
--evaluate_baseline_performance
|
|
116
|
+
--evaluate_baseline_performance
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
## Accelerating with GPUs
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|