Skip to content

Commit

Permalink
single omics methods receive arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
janursa committed Sep 27, 2024
1 parent 87e46d5 commit 4e4a976
Show file tree
Hide file tree
Showing 20 changed files with 483 additions and 126 deletions.
18 changes: 0 additions & 18 deletions batch_run.sh

This file was deleted.

67 changes: 66 additions & 1 deletion runs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -182,6 +182,71 @@
"# subprocess.run(command, shell=True, check=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Run grn inference "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Submitted batch job 7748321\n"
]
}
],
"source": [
"par = {\n",
" # 'methods': ['pearson_corr', 'portia', 'grnboost2', 'ppcor', 'scenic', 'scglue', 'celloracle'],\n",
" 'methods': ['ppcor'],\n",
" 'write_dir': 'resources/grn_models/',\n",
" 'multiomics_rna': 'resources/grn-benchmark/multiomics_rna.h5ad',\n",
" 'num_workers': 20,\n",
" 'mem': \"100G\",\n",
" 'time': \"24:00:00\"\n",
"}\n",
"for method in par['methods']:\n",
" par['prediction'] = f\"{par['write_dir']}/{method}.csv\"\n",
" # method arguments \n",
" method_args=f\"--multiomics_rna {par['multiomics_rna']} --prediction {par['prediction']} --num_workers {par['num_workers']}\"\n",
" # run command\n",
" if method == \"pearson_corr\":\n",
" command = f\"python src/control_methods/pearson/script.py {method_args}\"\n",
" elif method == \"celloracle\":\n",
" command = f\"/home/jnourisa/miniconda3/envs/celloracle/bin/python src/methods/multi_omics/celloracle/script.py {method_args}\"\n",
" elif method in [\"grnboost2\", \"scenic\", \"genie3\"]:\n",
" command = f\"singularity exec ../../images/scenic python src/methods/single_omics/{method}/script.py {method_args}\" \n",
" elif method == 'scglue':\n",
" command = f\"singularity exec ../../images/scglue python src/methods/multi_omics/{method}/script.py {method_args}\"\n",
" elif method == 'ppcor':\n",
" command = f\"singularity exec ../../images/ppcor Rscript src/methods/single_omics/{method}/script.R {method_args}\"\n",
" else:\n",
" command = f\"singularity exec ../../images/{method} python src/methods/single_omics/{method}/script.py {method_args}\"\n",
" # sbatch tags\n",
" tag = f\"--job-name {method} \"\n",
" resources = f\" --cpus-per-task {par['num_workers']} --mem {par['mem']} --time {par['time']}\" #resources\n",
" tag+=resources\n",
" if method=='scglue':\n",
" tag += f\" --partition=gpu --gres=gpu:1\"\n",
" \n",
" !sbatch {tag} scripts/sbatch/grn_inference.sh \"{command}\" \n",
" # !bash scripts/sbatch/grn_inference.sh \"{command}\" "
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
26 changes: 26 additions & 0 deletions scripts/sbatch/grn_inference.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

#SBATCH --output=logs/%j.out
#SBATCH --error=logs/%j.err
#SBATCH --mail-type=END
#SBATCH [email protected]

${1}
# if [ "${1}" = "pearson_corr" ]; then
# echo "Method: ${1}"
# python src/control_methods/pearson/script.py ${args}
# elif [ "${1}" = "celloracle" ]; then
# /home/jnourisa/miniconda3/envs/celloracle/bin/python src/methods/multi_omics/celloracle/script.py ${args}
# elif [ "$1" == "scenic" ] || [ "$1" == "genie3" ] || [ "$1" == "grnboost2" ]; then
# singularity exec ../../images/scenic python src/methods/single_omics/${1}/script.py ${args}
# elif [ "$1" == "scglue" ]; then
# singularity exec ../../images/${1} python src/methods/multi_omics/${1}/script.py ${args}
# elif [ "$1" == "ppcor" ]; then #R
# singularity exec ../../images/${1} Rscript src/methods/single_omics/${1}/script.R ${args}
# else
# singularity exec ../../images/${1} python src/methods/single_omics/${1}/script.py ${args}
# fi




12 changes: 0 additions & 12 deletions scripts/sbatch/scglue.sh

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/sbatch/single_omics.sh

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/sbatch/single_omics_R.sh

This file was deleted.

27 changes: 26 additions & 1 deletion src/control_methods/pearson/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,38 @@
par = {
'multiomics_rna': 'resources/grn-benchmark/multiomics_rna_0.h5ad',
'tf_all': 'resources/prior/tf_all.csv',
'cell_type_specific': True,
'cell_type_specific': False,
'max_n_links': 50000,
'prediction': 'resources/grn_models/donor_0_default/pearson.csv',
"seed": 32,
'normalize': False
}
## VIASH END
meta = {
'resources_dir': 'src/utils'
}

import argparse
parser = argparse.ArgumentParser(description="Process multiomics RNA data.")
parser.add_argument('--multiomics_rna', type=str, help='Path to the multiomics RNA file')
parser.add_argument('--prediction', type=str, help='Path to the prediction file')
parser.add_argument('--resources_dir', type=str, help='Path to the prediction file')
parser.add_argument('--tf_all', type=str, help='Path to the tf_all')
parser.add_argument('--num_workers', type=str, help='Number of cores')
args = parser.parse_args()

if args.multiomics_rna:
par['multiomics_rna'] = args.multiomics_rna
if args.prediction:
par['prediction'] = args.prediction
if args.tf_all:
par['tf_all'] = args.tf_all
if args.num_workers:
par['num_workers'] = args.num_workers

if args.resources_dir:
meta['resources_dir'] = args.resources_dir

import sys
sys.path.append(meta["resources_dir"])
from util import create_corr_net
Expand Down
Loading

0 comments on commit 4e4a976

Please sign in to comment.