-
Notifications
You must be signed in to change notification settings - Fork 0
/
ACE2-v2.R
59 lines (46 loc) · 1.88 KB
/
ACE2-v2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
library(tidyverse)
source("pipeline.R")
drugs <- c("Carbetocin", "Losartan", "Candesartan")
genes <- c("MAS1", "TNF", "AGT")
mapping <- read_csv("signature_data/id-name-cellline_mapping.csv") %>%
filter(Perturbagen %in% drugs)
return_data <- function(signature_id) {
signature <- get_l1000_signature(signature_id)
filter_up <- generate_filtered_signature(signature, direction = "up")
filter_dn <- generate_filtered_signature(signature, direction = "down")
filter_con <- bind_rows(filter_up, filter_dn)
results_kd <- get_concordant_signatures(signature_df = filter_con, library = "LIB_6") %>%
filter(treatment %in% genes) %>%
mutate(Source_Signature = signature_id)
results_oe <- get_concordant_signatures(signature_df = filter_con, library = "LIB_11") %>%
filter(treatment %in% genes) %>%
mutate(Source_Signature = signature_id)
output <- list(
knockdown = results_kd,
overexpress = results_oe
)
return(output)
}
sigs <- lapply(mapping$SignatureId, return_data)
saveRDS(sigs, "ACE2Data.Rds")
comp <- reduce(sigs, bind_rows)
complete <- inner_join(comp, mapping, by = c("Source_Signature" = "SignatureId")) %>%
mutate(Class = if_else(str_detect(signatureid, "LINCSKD"), "Knockdown", "Overexpress")) %>%
select(treatment, Perturbagen, Class, similarity)
summary_data <- complete %>%
group_by(Perturbagen, treatment, Class) %>%
filter(abs(similarity) == max(abs(similarity))) %>%
rename()
oex <- summary_data %>%
filter(Class == "Overexpress")
p <- ggplot(oex, aes(Perturbagen, similarity, fill = treatment, width = 0.5))
p + geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
scale_x_discrete(limits = drugs) +
scale_y_continuous(limits = c(-1,1)) +
theme_minimal() +
labs(
title = "Comparison of Concordance for MAS1 gene",
x = "Drug",
y = "Concordance"
) +
guides(fill = guide_legend(title = "Gene"))