-
Notifications
You must be signed in to change notification settings - Fork 0
Signature reversion and drug analyses #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df2f956
5a0ece6
b85bfe0
18f480b
e780823
c9a37e8
389dc59
0afe1bb
4df6dd2
501f07c
c94a02c
4f6f76e
6302176
3e14ca9
a8f769b
6575b4b
7f4dd47
120ea0f
ce68020
ae2f1d7
3d69c35
d590240
cac9cf4
5342112
83b2d47
c3d77b2
a165b18
83a22eb
31d5efb
5aee535
f3464ee
9a44c49
963c399
077cb83
df9995c
597ab3b
9b1c5e4
4d01a2e
6518a38
1b03795
6faebea
7d7e48d
92ead6e
c7f51f3
5eb7e2f
47e3ac9
9277258
cd174e4
079e5e7
6e91420
e574714
688cdd0
779d1ab
4aadfe6
e79fa11
e75b3d3
b0415a4
a6bc336
a36fc28
a6668d4
fa6a8e5
6d1bd41
dcb7881
ebcb038
4f1602e
00c6f10
6306dd8
f04da86
852fd78
b07adf7
83992d3
bb67ca9
e2e55f6
cb27acf
18263b0
0049091
294bc49
2488cd8
bc406d4
85181c8
815db67
e82b22f
a83d5ee
0322579
b1e68d2
eac325c
60e5443
3f3203c
bf0af42
4beaa9a
bb7085b
13c71c5
948ffb6
decdfff
a5f9e71
7a54de0
dc98760
0a89573
c0158ca
e52cf66
6717b01
11eaf85
0b19d56
efc2b77
042693e
892a2d0
ba5e2fa
65a6549
25528d2
89095c9
9c7e2d7
7fc171e
ead0273
82aacf5
8b1f1db
d75c74e
0c2631e
c659a52
270ce6d
9a5a8ae
c46695b
9ed148e
fbcf719
4677b6c
2903d97
5820134
e5c1ae4
af2c6a5
f860818
3221e7b
a15bc46
db322ad
7b6a932
bd6688e
f16d497
01c39ba
a202fe3
1709b77
a88b7f2
e84d9bf
4711b09
6301d4f
a96f76c
112dc83
5efcd3e
efa4fc1
1696ef1
a1b67e1
67e91a1
fd40b8c
3dbba03
77321e0
168a1aa
c626e27
7cf761c
6fc8a7a
fa9de22
be6da26
828efb7
9cbe0f8
9e7a72a
b2e07f4
512d733
bdb1269
70eef9b
ebd05c0
f6334aa
9145e90
304eb28
fe2b421
9b39e6c
9aae5b3
35b18f2
6b4ccbd
e15d9aa
0956053
389a583
5368f69
6635091
7b79f92
15337d9
0f7b963
a096250
66215a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/bash | ||
|
|
||
| #SBATCH --ntasks=1 | ||
| #SBATCH --mem-per-cpu=32G | ||
| #SBATCH --partition=express | ||
|
|
||
| cap_container -c singularity "lizzyr/sigsearch:1.0.0" | ||
|
|
||
| singularity exec --cleanenv \ | ||
| --containall \ | ||
| -B "${CAP_PROJECT_PATH}" \ | ||
| -B "${LASSEIGNE_LAB_PATH}" \ | ||
| "${CAP_CONTAINER_PATH}"/sigsearch_1.0.0.sif \ | ||
| Rscript --vanilla "${CAP_PROJECT_PATH}"/src/11_signature_reversion.R \ | ||
| -i "${CAP_DATA_PATH}"/ \ | ||
| -o "${CAP_RESULTS_PATH}"/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,202 @@ | ||
| suppressPackageStartupMessages({ | ||
| library(argparse) | ||
| library(tidyverse) | ||
| library(recount3) | ||
| library(signatureSearch) | ||
| library(ExperimentHub) | ||
| library(rhdf5) | ||
| }) | ||
|
|
||
| # create parser object | ||
| parser <- ArgumentParser() | ||
|
|
||
| parser$add_argument("-i", "--input_dir", | ||
| type = "character", | ||
| metavar = "PATH", | ||
| help = "Path to data directory" | ||
| ) | ||
| parser$add_argument("-o", "--output_dir", | ||
| type = "character", | ||
| metavar = "PATH", | ||
| help = "Path to the results directory to read consensus signature and write signatureSearch results" # nolint | ||
| ) | ||
|
|
||
| # get command line options, if help option encountered print help and exit | ||
| args <- parser$parse_args() | ||
|
|
||
| # source functions file if supplied | ||
| if (!is.null(args$functions)) source(args$functions) | ||
|
|
||
| # start timer | ||
| ptm <- proc.time() | ||
|
|
||
| #### Set variables for dataset #### | ||
|
|
||
| datapath <- args$input_dir | ||
| resdir <- args$output_dir | ||
| filepath <- paste0(resdir, "signature_reversion/") | ||
| querypath <- paste0(resdir, "consensus_signature/") | ||
| cachedir <- paste0(datapath, "ExperimentHubCache") | ||
| message("Location of cache directory: ", cachedir) | ||
|
|
||
| # create dirs if needed | ||
| if (!dir.exists(filepath)) dir.create(filepath, recursive = TRUE) | ||
| if (!dir.exists(cachedir)) dir.create(cachedir, recursive = TRUE) | ||
|
|
||
| ###### EXPERIMENT HUB SET UP ###### | ||
|
|
||
| setExperimentHubOption("ASK", FALSE) | ||
| setExperimentHubOption("CACHE", cachedir) | ||
|
|
||
| # Force a clean load of the hub | ||
| Sys.setenv(EXPERIMENT_HUB_CACHE = cachedir) | ||
| eh <- ExperimentHub(localHub = FALSE) | ||
|
|
||
| # lincs 2020 filepath and db exploration | ||
| message("Loading in lincs2 EH db...") | ||
| lincs2 <- eh[["EH7297"]] | ||
|
|
||
| # load LINCS perturbation annotations | ||
| data(lincs_pert_info2) | ||
| message("Loading in lincs2 annotation EH db...") | ||
|
|
||
| ###### READ IN DATA ###### | ||
|
|
||
| # RRA signature | ||
| rra_degs <- read_csv( | ||
| paste0(querypath, "rankaggregate_consensus_signature.csv") | ||
| ) | ||
| # SETBP1 regulatory targets | ||
| # Curated targets by Sasha Taluri | ||
| setbp1_targets_all <- read_csv(paste0( | ||
| datapath, "260403_setbp1_targets.csv" | ||
| )) | ||
| # Prioritized targets from coexpression & pathway analysis | ||
| setbp1_targets_top <- read_csv(paste0( | ||
| resdir, "permutation_analysis/prioritized_setbp1_targets.csv" | ||
| )) | ||
|
|
||
| ###### PREPARE QUERY SIGNATURE ###### | ||
|
|
||
| # genes available in LINCS DB | ||
| db_genes <- h5read(lincs2, "rownames", drop = TRUE) | ||
|
|
||
| # up vs down DEGs in signature | ||
| degs_up <- rra_degs %>% | ||
| mutate(entrez = as.character(entrez)) %>% | ||
| filter(meta_logFC > 0.1) %>% | ||
| filter(entrez %in% db_genes) %>% | ||
| slice_min(Score, n = 100) | ||
| cat("Up genes summary... ", summary(degs_up), "\n", sep = " ") | ||
|
|
||
| degs_down <- rra_degs %>% | ||
| mutate(entrez = as.character(entrez)) %>% | ||
| filter(meta_logFC < -0.1) %>% | ||
| filter(entrez %in% db_genes) %>% | ||
| slice_min(Score, n = 100) | ||
| cat("Down genes summary... ", summary(degs_down), "\n", sep = " ") | ||
|
|
||
| ###### SIGNATURE REVERSION ###### | ||
|
|
||
| # query LINCS signatures | ||
| qsig_lincs <- qSig( | ||
| query = list(upset = degs_up$entrez, downset = degs_down$entrez), | ||
| gess_method = "LINCS", | ||
| refdb = lincs2 | ||
| ) | ||
|
|
||
| # calculate signature reversion metrics of query vs LINCS DB | ||
| lincs <- gess_lincs(qsig_lincs, sortby = "WTCS", tau = FALSE, workers = 1) | ||
| str(lincs) | ||
| write_rds(lincs, paste0(filepath, "lincs_results.rds")) | ||
|
|
||
| # filter for brain/CNS-derived/relevant cells (HEK cells often used in neuro) | ||
| brain_cells <- c("NEU", "SHSY5Y", "NPC", "HEK293", "HEK293T") | ||
| lincs_brain <- lincs@result %>% | ||
| filter(cell %in% brain_cells) %>% | ||
| filter(WTCS < 0) %>% | ||
| arrange(WTCS) | ||
| head(lincs_brain) | ||
| write_csv(lincs_brain, paste0(filepath, "lincs_braincells_results.csv")) | ||
|
|
||
| # annotate drugs | ||
| brain_drugs_anno <- lincs_brain %>% | ||
| left_join(lincs_pert_info2, by = c("pert" = "pert_id")) | ||
| cat( | ||
| "Number of unique reversion drugs in brain-relevant cells: ", | ||
| length(unique(brain_drugs_anno$pert)), "\n", | ||
| sep = " " | ||
| ) | ||
|
|
||
| write_rds( | ||
| brain_drugs_anno, paste0(filepath, "lincs_anno_braincell_results.rds") | ||
| ) | ||
|
|
||
| ###### TARGET ANALYSIS ###### | ||
| # separate targets by rows to compare drug targets | ||
| brain_drug_targets <- brain_drugs_anno %>% | ||
| dplyr::select( | ||
| pert, pref_name, max_phase, cell, WTCS, | ||
| WTCS_Pval, mergeTargets, Target_pathway | ||
| ) %>% | ||
| separate_longer_delim(mergeTargets, delim = "; ") %>% | ||
| filter(!is.na(mergeTargets)) %>% | ||
| add_count(mergeTargets) %>% | ||
| # annotate targets that are prioritized SETBP1 regulatory targets | ||
| mutate( | ||
| SETBP1_target = ifelse( | ||
| mergeTargets %in% setbp1_targets_all$Target, TRUE, FALSE | ||
| ), | ||
| SETBP1_top_target = ifelse( | ||
| mergeTargets %in% setbp1_targets_top$Target_Gene, TRUE, FALSE | ||
| ) | ||
| ) | ||
|
|
||
| # filter for drugs that target any SETBP1 regulatory targets | ||
| drug_targets_setbp1 <- brain_drug_targets %>% | ||
| filter(SETBP1_target == TRUE) %>% | ||
| distinct() | ||
| str(drug_targets_setbp1) | ||
| print(n = 21, arrange(drug_targets_setbp1, pref_name)) | ||
|
|
||
| cat( | ||
| "Drugs that target SETBP1 targets: ", | ||
| unique(drug_targets_setbp1$pref_name), | ||
| "\n", | ||
| sep = " " | ||
| ) | ||
| cat( | ||
| "Drug target SETBP1 targets: ", | ||
| unique(drug_targets_setbp1$mergeTargets), | ||
| "\n", | ||
| sep = " " | ||
| ) | ||
| write_csv( | ||
| drug_targets_setbp1, paste0(filepath, "setbp1_drug_targets.csv") | ||
| ) | ||
|
|
||
| # full drug annotations for setbp1-target-targeting drugs | ||
|
|
||
| setbp1_drugs <- brain_drugs_anno %>% | ||
| filter(pert %in% drug_targets_setbp1$pert) | ||
|
|
||
|
|
||
| #### APPROVED/POST-MARKET DRUGS #### | ||
| approved_drugs <- brain_drugs_anno %>% | ||
| # max WTCS to help with plot ordering | ||
| group_by(pref_name) %>% | ||
| mutate(drug_top_WTCS = min(WTCS)) %>% | ||
| ungroup() %>% | ||
| add_count(pert) %>% | ||
| # filter for approved drugs | ||
| filter(max_phase == 4) | ||
|
|
||
| write_csv(approved_drugs, paste0(filepath, "approved_drugs_res.csv")) | ||
|
|
||
|
|
||
| # end timer | ||
| fptm <- proc.time() | ||
| (fptm[3] / 60) | ||
|
|
||
| # session info | ||
| print(sessionInfo()) | ||
Uh oh!
There was an error while loading. Please reload this page.