Skip to content

Commit

Permalink
fixing test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
janursa committed Nov 10, 2024
1 parent 90a70ab commit fd2bfa9
Show file tree
Hide file tree
Showing 9 changed files with 728 additions and 168 deletions.
426 changes: 302 additions & 124 deletions runs.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/file_atac_h5ad.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: file
example: resources/inference_datasets/op_atac.h5ad
example: resources_test/inference_datasets/op_atac.h5ad
info:
label: multiomics atac
summary: "Peak data for multiomics data."
Expand Down
2 changes: 1 addition & 1 deletion src/api/file_evaluation_h5ad.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: file
example: resources/evaluation_datasets/op_perturbation.h5ad
example: resources_test/evaluation_datasets/op_perturbation.h5ad
info:
label: perturbation
summary: "Perturbation dataset for benchmarking."
Expand Down
2 changes: 1 addition & 1 deletion src/api/file_rna_h5ad.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: file
example: resources/inference_datasets/op_rna.h5ad
example: resources_test/inference_datasets/op_rna.h5ad
info:
label: multiomics rna
summary: "RNA expression for multiomics data."
Expand Down
2 changes: 1 addition & 1 deletion src/api/file_score.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: file
example: resources/scores/score.h5ad
example: resources_test/scores/score.h5ad
info:
label: Score
summary: "File indicating the score of a metric."
Expand Down
8 changes: 4 additions & 4 deletions src/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ def run_grn_inference():
if True:
par = {
# 'methods': ["positive_control", "negative_control", "pearson_corr", "portia", "grnboost2", "ppcor", "scenic"],
'methods': ["positive_control", "negative_control", "pearson_corr"],
'methods': ["portia", "grnboost2"],

'models_dir': 'resources/grn_models/replogle2/',
'rna': 'resources/inference_datasets/replogle2.h5ad',
'rna_positive_control': 'resources/datasets_raw/replogle2.h5ad',
'num_workers': 20,
'mem': "64GB",
'time': "48:00:00",
'time': "12:00:00",
'normalize': False,
# 'max_n_links': 10000,
}
Expand Down Expand Up @@ -168,8 +168,8 @@ def run_grn_inference():
full_tag += ["--partition=gpu", "--gres=gpu:1"]

try:
# result = subprocess.run(['sbatch'] + full_tag + ['scripts/sbatch/grn_inference.sh', command], check=True, capture_output=True, text=True)
result = subprocess.run(['bash'] + ['scripts/sbatch/grn_inference.sh', command], check=True, capture_output=True, text=True)
result = subprocess.run(['sbatch'] + full_tag + ['scripts/sbatch/grn_inference.sh', command], check=True, capture_output=True, text=True)
# result = subprocess.run(['bash'] + ['scripts/sbatch/grn_inference.sh', command], check=True, capture_output=True, text=True)

print(f"Job {method} submitted successfully.")
print(result.stdout) # Print the standard output
Expand Down
9 changes: 6 additions & 3 deletions src/metrics/regression_1/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def cross_validation(net, prturb_adata, par:dict):
regr = lightgbm_wrapper(params, max_workers=par['num_workers'])
else:
raise ValueError(f"{reg_type} is not defined.")

reg_models = []
for group in verbose_tqdm(unique_groups, "Processing groups", 2, par['verbose']):
mask_va = groups == group
mask_tr = ~mask_va
Expand All @@ -125,7 +125,9 @@ def cross_validation(net, prturb_adata, par:dict):
continue
regr.fit(X_tr, Y_tr)
y_pred[mask_va & mask_shared_genes, :] = regr.predict(X[mask_va & mask_shared_genes, :])
return y_true, y_pred

reg_models.append(regr)
return y_true, y_pred, reg_models

def regression_1(
net: pd.DataFrame,
Expand Down Expand Up @@ -162,9 +164,10 @@ def regression_1(
prturb_adata_sub = prturb_adata[prturb_adata.obs.donor_id==donor_id,:]
else:
prturb_adata_sub = prturb_adata
y_true_sub, y_pred_sub = cross_validation(net_sub, prturb_adata_sub, par)
y_true_sub, y_pred_sub, _ = cross_validation(net_sub, prturb_adata_sub, par)

score = r2_score(y_true_sub, y_pred_sub, multioutput='variance_weighted')

score_list.append(score)
mean_score_r2 = np.mean(score_list)
output = dict(mean_score_r2=mean_score_r2)
Expand Down
43 changes: 31 additions & 12 deletions src/metrics/script_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
import os

## VIASH START
par = {
'reg_type': 'GB',
'models_dir': "resources/grn_models/replogle2",
'scores_dir': "output/",
if True: #op
par = {
'reg_type': 'ridge',
'models_dir': "resources/grn_models/op",
'scores_dir': "output/temp",

# 'models': [ 'collectri', 'negative_control', 'positive_control', 'pearson_corr', 'portia', 'ppcor', 'grnboost2', 'scenic', 'granie', 'scglue', 'celloracle', 'figr', 'scenicplus'],
'models': [ 'negative_control', 'positive_control', 'pearson_corr', 'portia', 'grnboost2', 'ppcor', 'scenic'],
# 'models': ['negative_control', 'positive_control', 'pearson_corr'],
'models': [ 'collectri', 'negative_control', 'positive_control', 'pearson_corr', 'portia', 'ppcor', 'grnboost2', 'scenic', 'granie', 'scglue', 'celloracle', 'figr', 'scenicplus'],

"evaluation_data": "resources/evaluation_datasets/replogle2.h5ad",
'consensus': 'resources/prior/replogle2_consensus-num-regulators.json',
# "evaluation_data": "resources/evaluation_datasets/frangieh_IFNg_v2.h5ad",
# 'consensus': 'resources/prior/frangieh_IFNg_v2_consensus-num-regulators.json',
"evaluation_data": "resources/evaluation_datasets/op_perturbation.h5ad",
'consensus': 'resources/prior/op_consensus-num-regulators.json',

'layers': ['X'],

Expand All @@ -29,6 +26,29 @@
'num_workers': 20,
'clip_scores': True
}

if False: # replogle2
par = {
'reg_type': 'GB',
'models_dir': "resources/grn_models/replogle2",
'scores_dir': "output/",

'models': [ 'negative_control', 'positive_control', 'pearson_corr', 'portia', 'grnboost2', 'ppcor', 'scenic'],


"evaluation_data": "resources/evaluation_datasets/replogle2.h5ad",
'consensus': 'resources/prior/replogle2_consensus-num-regulators.json',

'layers': ['X'],

"tf_all": "resources/prior/tf_all.csv",
'skeleton': 'resources/prior/skeleton.csv',
"apply_tf": True,
'subsample': -1,
'verbose': 4,
'num_workers': 20,
'clip_scores': True
}
# VIASH END

meta = {
Expand All @@ -39,7 +59,6 @@
sys.path.append(meta["util"])

os.makedirs(par['scores_dir'], exist_ok=True)

# - run consensus
from consensus.script import main
main(par)
Expand Down
Loading

0 comments on commit fd2bfa9

Please sign in to comment.