Skip to content

Commit

Permalink
robs analysis updated
Browse files Browse the repository at this point in the history
  • Loading branch information
janursa committed Aug 24, 2024
1 parent a183f16 commit dbe0511
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 22 deletions.
8 changes: 4 additions & 4 deletions scripts/run_robust_analys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# RUN_ID="run_$(date +%Y-%m-%d_%H-%M-%S)"

RUN_ID="robust_analy"
# resources_dir="resources"
# publish_dir="output/${RUN_ID}"
resources_dir="resources"
publish_dir="output/${RUN_ID}"

resources_dir="s3://openproblems-data/resources/grn"
publish_dir="s3://openproblems-data/resources/grn/results/${RUN_ID}"
# resources_dir="s3://openproblems-data/resources/grn"
# publish_dir="s3://openproblems-data/resources/grn/results/${RUN_ID}"

grn_models_folder="${resources_dir}/grn_models"

Expand Down
2 changes: 1 addition & 1 deletion src/api/comp_metric.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ functionality:
default: resources/grn-benchmark/perturbation_data.h5ad
- name: --prediction
__merge__: file_prediction.yaml
required: false
required: true
direction: input
default: resources/grn_models/collectri.csv
- name: --score
Expand Down
5 changes: 2 additions & 3 deletions src/methods/multi_omics/scenicplus/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ functionality:
GRN inference using scenicplus
documentation_url: https://scenicplus.readthedocs.io/en/latest/human_cerebellum.html
arguments:
- name: --cistopic_out
- name: --cistopic_object
type: file
required: false
direction: input
direction: output
resources:
- type: python_script
path: script.py
Expand Down
13 changes: 11 additions & 2 deletions src/methods/multi_omics/scenicplus/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
par = {
'multiomics_rna': 'resources/grn-benchmark/multiomics_rna.h5ad',
'multiomics_atac': 'resources/grn-benchmark/multiomics_atac.h5ad',
'cistopic_out': 'output/pycistopic',
'temp_dir': 'output/scenicplus',
'prediction': 'output/prediction.csv',
}
## VIASH END

work_dir = par['temp_dir']
par['cistopic_out'] = f'{work_dir}/cistopic_out'
par['cistopic_object'] = os.path.join(par['cistopic_out'], f'cistopic_object_with_model.pkl')
os.makedirs(os.path.join(work_dir, 'scRNA'), exist_ok=True)

# Download databases
Expand Down Expand Up @@ -96,6 +97,7 @@ def download_checksum(url: str, filepath: str) -> str:
with open(os.path.join(par['cistopic_out'], f'candidate_enhancers/markers_dict.pkl'), 'rb') as f:
markers_dict = pickle.load(f)


# Convert to dictionary of pyrange objects
region_sets = {}
region_sets['topics_otsu'] = {}
Expand Down Expand Up @@ -126,7 +128,7 @@ def download_checksum(url: str, filepath: str) -> str:
settings = yaml.safe_load(f)

# Update settings: indicate locations of input files
settings['input_data']['cisTopic_obj_fname'] = os.path.join(par['cistopic_out'], f'cistopic_object_with_model.pkl')
settings['input_data']['cisTopic_obj_fname'] = par['cistopic_object']
settings['input_data']['GEX_anndata_fname'] = os.path.join(work_dir, 'rna.h5ad')
settings['input_data']['region_set_folder'] = os.path.join(par['cistopic_out'], 'region_sets')
settings['input_data']['ctx_db_fname'] = rankings_db
Expand All @@ -152,3 +154,10 @@ def download_checksum(url: str, filepath: str) -> str:
# Make sure the file is properly formatted, and re-format it if needed
filepath = os.path.join(work_dir, 'tf_to_gene_adj.tsv')
shutil.copyfile(filepath, par['prediction'])


# cistopic_obj = pickle.load(os.path.join(par['cistopic_out'], f'cistopic_object_with_model.pkl'))
# # get cell topic association
# cell_topic = cistopic_obj.selected_model.cell_topic.T
# cell_names = cistopic_obj.cell_data.obs_id.values
# cell_topic.index = cell_names
4 changes: 4 additions & 0 deletions src/methods/multi_omics/scenicplus_ns/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ functionality:
info:
label: grn_inference_scenicplus
summary: "Infers GRNs from multiomics data using scenicplus."
arguments:
- name: --cistopic_object
type: file
direction: output

resources:
- type: nextflow_script
Expand Down
4 changes: 2 additions & 2 deletions src/methods/multi_omics/scenicplus_ns/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ workflow run_wf {
temp_dir: "temp_dir",
num_workers: "num_workers"
],
toState: [prediction:"prediction"]
toState: [prediction:"prediction", cistopic_object:"cistopic_object"]
)

| setState(["prediction"])
| setState(["prediction", "cistopic_object"])

emit:
output_ch
Expand Down
18 changes: 9 additions & 9 deletions src/methods/multi_omics/scenicplus_ns/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ HERE
# -params-file params/${RUN_ID}.yaml


# ./tw-windows-x86_64.exe launch `
# https://github.com/openproblems-bio/task_grn_benchmark.git `
# --revision build/main `
# --pull-latest `
# --main-script target/nextflow/workflows/run_grn_inference/main.nf `
# --workspace 53907369739130 `
# --compute-env 6TeIFgV5OY4pJCk8I0bfOh `
# --params-file ./params/celloracle_test.yaml `
# --config src/common/nextflow_helpers/labels_tw.config
./tw-windows-x86_64.exe launch `
https://github.com/openproblems-bio/task_grn_benchmark.git `
--revision build/main `
--pull-latest `
--main-script target/nextflow/workflows/grn_inference_scenicplus/main.nf `
--workspace 53907369739130 `
--compute-env 6TeIFgV5OY4pJCk8I0bfOh `
--params-file ./params/scenicplus.yaml `
--config src/common/nextflow_helpers/labels_tw.config


2 changes: 1 addition & 1 deletion src/workflows/run_robustness_analysis/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ workflow run_wf {
// use 'fromState' to fetch the arguments the component requires from the overall state
fromState: [
perturbation_data: "perturbation_data",
prediction_n: "prediction",
prediction: "prediction_n",
layer: "layer",
subsample: "subsample",
reg_type: "reg_type",
Expand Down

0 comments on commit dbe0511

Please sign in to comment.