-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
371 additions
and
268 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
#SBATCH --job-name=robustness | ||
#SBATCH --time=48:00:00 | ||
#SBATCH --output=logs/%j.out | ||
#SBATCH --error=logs/%j.err | ||
#SBATCH --mail-type=END | ||
#SBATCH [email protected] | ||
#SBATCH --mem=64G | ||
#SBATCH --cpus-per-task=20 | ||
|
||
python src/robustness_analysis/script_all.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
import pandas as pd | ||
import anndata as ad | ||
import sys | ||
import numpy as np | ||
|
||
def process_links(net, par): | ||
net = net[net.source!=net.target] | ||
net = net.sample(par['max_n_links']) | ||
return net | ||
def main(par): | ||
print('Reading input data') | ||
perturbation_data = ad.read_h5ad(par["perturbation_data"]) | ||
gene_names = perturbation_data.var_names.to_numpy() | ||
tf_all = np.loadtxt(par['tf_all'], dtype=str) | ||
|
||
n_tf = 500 | ||
tfs = tf_all[:n_tf] | ||
|
||
def create_negative_control(gene_names) -> np.ndarray: | ||
ratio = [.98, .01, 0.01] | ||
|
||
net = np.random.choice([0, -1, 1], size=((len(gene_names), n_tf)),p=ratio) | ||
net = pd.DataFrame(net, index=gene_names, columns=tfs) | ||
return net | ||
print('Inferring GRN') | ||
net = create_negative_control(gene_names) | ||
|
||
pivoted_net = net.reset_index().melt(id_vars='index', var_name='source', value_name='weight') | ||
|
||
pivoted_net = pivoted_net.rename(columns={'index': 'target'}) | ||
pivoted_net = pivoted_net[pivoted_net['weight'] != 0] | ||
|
||
pivoted_net = process_links(pivoted_net, par) | ||
return pivoted_net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pandas as pd | ||
import anndata as ad | ||
import sys | ||
import numpy as np | ||
import os | ||
import random | ||
|
||
par = { | ||
'write_dir': "resources/grn_models/d0_hvgs", | ||
"multiomics_rna": "resources/grn-benchmark/multiomics_rna_d0_hvg.h5ad", | ||
|
||
"perturbation_data": "resources/grn-benchmark/perturbation_data.h5ad", | ||
"tf_all": "resources/prior/tf_all.csv", | ||
"max_n_links": 50000, | ||
'layer': 'scgen_pearson', | ||
'cell_type_specific': False, | ||
'normalize': False, | ||
'causal': True | ||
} | ||
|
||
meta = { | ||
"resources_dir": 'src/control_methods', | ||
"util": 'src/utils' | ||
} | ||
sys.path.append(meta["resources_dir"]) | ||
sys.path.append(meta["util"]) | ||
|
||
os.makedirs(par['write_dir'], exist_ok=True) | ||
|
||
from util import create_corr_net | ||
|
||
|
||
#---- run for pearson_corr | ||
par['prediction'] = f"{par['write_dir']}/pearson_corr.csv" | ||
par['causal'] = True | ||
net = create_corr_net(par) | ||
net.to_csv(par['prediction']) | ||
#---- run for negative control | ||
from negative_control.main import main | ||
par['prediction'] = f"{par['write_dir']}/negative_control.csv" | ||
net = main(par) | ||
net.to_csv(par['prediction']) | ||
#---- run for positive_control | ||
par['multiomics_rna'] = par['perturbation_data'] | ||
par['prediction'] = f"{par['write_dir']}/positive_control.csv" | ||
net = create_corr_net(par) | ||
net.to_csv(par['prediction']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters