Skip to content

Commit

Permalink
celloracle ns fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
janursa committed Sep 27, 2024
1 parent 4e4a976 commit 73ab6fb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 65 deletions.
30 changes: 1 addition & 29 deletions src/exp_analysis/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,7 @@ def plot_centrality(self, df, title='',ax=None, xlabel='Degree', ylabel='Gene',
if colors is not None:
for label, color in zip(ax.get_yticklabels(), colors):
label.set_color(color)
def role_analysis(self, top_q=None) -> pd.DataFrame:
'''
Vester's sensitivity analysis.
- active_sum: active sum. Sum along rows of the influence matrix and it indicates how much does a variable influence all the others.
- passive_sum: passive sum. Its is the sum along columns of the influence matrix and it indicates how sensitive a variable is, how does it react to the influence of others
- Active: +AS, -PS
- Passive: -AS, -PS
- Critical: +AS, +PS
- neutral: -AS, -PS
------------------------------------------------------
inputs: net (DataFrame)
top_q: top quantile
output: VSA (DataFrame) -> genename: active_sum, passive_sum, Role
'''
# active sum and passive sum
net = self.net.copy()
net = net[net.weight>net.weight.quantile(top_q)]
gene_names = np.union1d(net.source.unique(), net.target.unique())
active_sum = np.asarray([sum(net.query(f"source == '{gene}'")['weight']) for gene in gene_names])
passive_sum = np.asarray([sum(net.query(f"target == '{gene}'")['weight']) for gene in gene_names])

# define the roles ['Buffering', 'Passive', 'Active', 'Critical'] -> [0, 1, 2, 3]
active_sum_threhsold = np.quantile(active_sum, 0.9)
passive_sum_threhsold = np.quantile(passive_sum, 0.9)
# active_sum, passive_sum = standardize_array(active_sum), standardize_array(passive_sum)
roles = [2*as_flag+ps_flag for as_flag, ps_flag in zip(active_sum>active_sum_threhsold, passive_sum>passive_sum_threhsold)]
self.roles = pd.DataFrame(data={'gene_name': gene_names, 'active_sum': active_sum, 'passive_sum': passive_sum, 'role':roles })
self.roles.set_index('gene_name',inplace=True)
return self.roles


def top_edges(self, quantile=0.95):
grn = self.net
Expand Down
1 change: 1 addition & 0 deletions src/methods/multi_omics/celloracle_ns/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ workflow run_wf {
| celloracle.run(
fromState: [multiomics_rna: "multiomics_rna",
multiomics_atac: "multiomics_atac",
tf_all: "tf_all",
temp_dir: "temp_dir",
num_workers: "num_workers",
max_n_links: "max_n_links"
Expand Down
53 changes: 17 additions & 36 deletions src/methods/multi_omics/celloracle_ns/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,26 @@ param_list:
- id: ${RUN_ID}
multiomics_rna: ${resources_dir}/grn-benchmark/multiomics_rna.h5ad
multiomics_atac: ${resources_dir}/grn-benchmark/multiomics_atac.h5ad
tf_all: ${resources_dir}/prior/tf_all.csv
num_workers: $num_workers
temp_dir: ./tmp/grn
output_state: "state.yaml"
publish_dir: "$publish_dir"
HERE

if [ "$submit" = true ]; then
nextflow run . \
-main-script target/nextflow/workflows/grn_inference_celloracle/main.nf \
-profile docker \
-with-trace \
-c src/common/nextflow_helpers/labels_ci.config \
-params-file params/${RUN_ID}.yaml


./tw-windows-x86_64.exe launch `
https://github.com/openproblems-bio/task_grn_inference.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
fi



if [ "$read_results" = true ]; then
aws s3 sync s3://openproblems-data/resources/grn/results/${RUN_ID} ./resources/results/${RUN_ID}
fi


./tw-windows-x86_64.exe launch `
https://github.com/openproblems-bio/task_grn_inference.git `
--revision build/main `
--pull-latest `
--main-script target/nextflow/workflows/grn_inference_celloracle/main.nf `
--workspace 53907369739130 `
--compute-env 6TeIFgV5OY4pJCk8I0bfOh `
--params-file ./params/celloracle.yaml `
--config src/common/nextflow_helpers/labels_tw.config
# nextflow run . \
# -main-script target/nextflow/workflows/grn_inference_celloracle/main.nf \
# -profile docker \
# -with-trace \
# -c src/common/nextflow_helpers/labels_ci.config \
# -params-file params/${RUN_ID}.yaml


./tw launch https://github.com/openproblems-bio/task_grn_inference \
--revision build/main \
--pull-latest \
--main-script target/nextflow/workflows/grn_inference_celloracle/main.nf \
--workspace 53907369739130 \
--compute-env 6TeIFgV5OY4pJCk8I0bfOh \
--params-file ${param_file} \
--config src/common/nextflow_helpers/labels_tw.config

0 comments on commit 73ab6fb

Please sign in to comment.