Skip to content

Commit ba9fb42

Browse files
committed
Add code for paper
1 parent 3e31b0f commit ba9fb42

69 files changed

Lines changed: 54483 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

paper/AD/GO.R

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# install.packages("BiocManager")
2+
# BiocManager::install("clusterProfiler")
3+
# BiocManager::install("org.Hs.eg.db")
4+
# BiocManager::install("AnnotationDbi")
5+
# BiocManager::install("rrvgo")
6+
7+
8+
library(clusterProfiler)
9+
library(org.Hs.eg.db)
10+
library(AnnotationDbi)
11+
library(rrvgo)
12+
13+
library(purrr)
14+
library(stringr)
15+
library(ggplot2)
16+
library(patchwork)
17+
library(dplyr)
18+
19+
20+
celltype <- 'exneu'
21+
args = commandArgs(trailingOnly=TRUE)
22+
cat(args)
23+
ps_model <- as.character(args[1])
24+
ps_model <- 'random_forest_cv'
25+
26+
path_rs_GO <- sprintf('~/../jinandmaya/AD/results/')
27+
dir.create(path_rs_GO, recursive=TRUE, showWarnings = FALSE)
28+
29+
########################################################################################
30+
#
31+
# Cnetplot
32+
#
33+
########################################################################################
34+
GO_results <- list()
35+
methods <- c('causarray', 'ruv')
36+
for (method in methods) {
37+
df_list <- list()
38+
for (dataset in c('ROSMAP-AD/results', 'SEA-AD/results-MTG', 'SEA-AD/results-PFC')){
39+
path_rs <- sprintf('~/../jinandmaya/%s/%s/DE/', dataset, ps_model)
40+
df <- read.csv(sprintf('%sres.%s.%s.csv', path_rs, celltype, method), row.names=1)
41+
if('tau' %in% colnames(df)){df$log2FoldChange <- df$tau / log(2)}
42+
df_list <- append(df_list, list(df))
43+
}
44+
# Get average log fold change for each gene
45+
foldChange <- sapply(df$gene_names, function(gene) {
46+
logfoldchanges <- sapply(df_list, function(df) {return(df$log2FoldChange[df$gene_names == gene])})
47+
median(logfoldchanges, na.rm = TRUE)
48+
})
49+
50+
# Get overlap of discoveries
51+
significant_genes <- unique(unlist(lapply(df_list, function(df) df$gene_names[df$padj <= 0.1])))
52+
significant_genes_logfoldchange <- foldChange[significant_genes]
53+
54+
# Select top 50 genes based on absolute log fold change
55+
genes_to_test <- c(names(sort(significant_genes_logfoldchange, decreasing = TRUE))[1:25],
56+
names(sort(significant_genes_logfoldchange, decreasing = FALSE))[1:25])
57+
# genes_to_test <- names(significant_genes_logfoldchange)
58+
length(genes_to_test)
59+
60+
61+
#Run groupGO using the names of the vector
62+
GO_results[[method]] <- groupGO(
63+
gene = genes_to_test,
64+
OrgDb = org.Hs.eg.db, keyType = "SYMBOL",
65+
ont = 'BP',
66+
level = 3,
67+
readable = TRUE)
68+
69+
GO_results[[method]]@result <- GO_results[[method]]@result[GO_results[[method]]@result$Count>0,]
70+
GO_results[[method]]@result <- GO_results[[method]]@result[order(-GO_results[[method]]@result$Count),]
71+
write.csv(GO_results[[method]]@result, sprintf("%sGO_%s.csv", path_rs_GO, method))
72+
73+
#Plot your results
74+
p <- cnetplot(GO_results[[method]], showCategory=GO_results[[method]]@result$Description[1:5],
75+
categorySize="GeneNum",
76+
circular = TRUE, colorEdge = TRUE, cex_label_gene = 1,
77+
color.params = list(foldChange = foldChange), color_category = "#309630",
78+
order=TRUE) + theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
79+
80+
ggsave(sprintf("%scnetplot_%s.pdf", path_rs_GO, method), plot = p, width = 10, height = 8, units = "in")
81+
}

paper/AD/Plot.ipynb

Lines changed: 835 additions & 0 deletions
Large diffs are not rendered by default.
97.6 KB
Binary file not shown.
11.4 KB
Binary file not shown.
11.7 KB
Binary file not shown.
11.7 KB
Binary file not shown.
11.3 KB
Binary file not shown.

paper/AD/results/CATE.pdf

68.6 KB
Binary file not shown.

paper/AD/results/GO_causarray.csv

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
"","ID","Description","Count","GeneRatio","geneID"
2+
"GO:0050794","GO:0050794","regulation of cellular process",18,"18/50","SCGN/PDYN/GABRQ/COL6A2/MGARP/NGF/FAM83B/FKBP1C/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RAG2/RFPL1/PDC"
3+
"GO:0050789","GO:0050789","regulation of biological process",18,"18/50","SCGN/PDYN/GABRQ/COL6A2/MGARP/NGF/FAM83B/FKBP1C/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RAG2/RFPL1/PDC"
4+
"GO:0007154","GO:0007154","cell communication",15,"15/50","SCGN/PDYN/GABRQ/COL6A2/NGF/FAM83B/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RFPL1/PDC"
5+
"GO:0051716","GO:0051716","cellular response to stimulus",15,"15/50","PDYN/GABRQ/COL6A2/MGARP/NGF/FAM83B/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RFPL1/PDC"
6+
"GO:0023052","GO:0023052","signaling",15,"15/50","SCGN/PDYN/GABRQ/COL6A2/NGF/FAM83B/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RFPL1/PDC"
7+
"GO:0007165","GO:0007165","signal transduction",14,"14/50","PDYN/GABRQ/COL6A2/NGF/FAM83B/OR7D2/PSG1/SELP/PSG6/VAX2/CARTPT/TRPA1/RFPL1/PDC"
8+
"GO:0006807","GO:0006807","nitrogen compound metabolic process",10,"10/50","HGFAC/LDHC/NGF/FKBP1C/OR7D2/VAX2/CARTPT/RAG2/RFPL1/ADAM21"
9+
"GO:0044238","GO:0044238","primary metabolic process",10,"10/50","HGFAC/LDHC/NGF/FKBP1C/OR7D2/VAX2/CARTPT/RAG2/RFPL1/ADAM21"
10+
"GO:0071704","GO:0071704","organic substance metabolic process",10,"10/50","HGFAC/LDHC/NGF/FKBP1C/OR7D2/VAX2/CARTPT/RAG2/RFPL1/ADAM21"
11+
"GO:0044237","GO:0044237","cellular metabolic process",9,"9/50","HGFAC/LDHC/CA12/NGF/OR7D2/VAX2/CARTPT/RAG2/RFPL1"
12+
"GO:0009058","GO:0009058","biosynthetic process",8,"8/50","HGFAC/LDHC/NGF/OR7D2/VAX2/CARTPT/RAG2/RFPL1"
13+
"GO:0003008","GO:0003008","system process",8,"8/50","PDYN/GABRQ/NGF/OR7D2/VAX2/CARTPT/TRPA1/PDC"
14+
"GO:0048518","GO:0048518","positive regulation of biological process",8,"8/50","SCGN/MGARP/NGF/FAM83B/SELP/CARTPT/RAG2/RFPL1"
15+
"GO:0006950","GO:0006950","response to stress",8,"8/50","CLEC2A/HGFAC/MGARP/SELP/CARTPT/TRPA1/RAG2/RFPL1"
16+
"GO:0048522","GO:0048522","positive regulation of cellular process",7,"7/50","SCGN/MGARP/NGF/FAM83B/SELP/CARTPT/RFPL1"
17+
"GO:0048523","GO:0048523","negative regulation of cellular process",7,"7/50","MGARP/NGF/FKBP1C/VAX2/CARTPT/RAG2/RFPL1"
18+
"GO:0023051","GO:0023051","regulation of signaling",7,"7/50","SCGN/NGF/FAM83B/SELP/CARTPT/RFPL1/PDC"
19+
"GO:0048519","GO:0048519","negative regulation of biological process",7,"7/50","MGARP/NGF/FKBP1C/VAX2/CARTPT/RAG2/RFPL1"
20+
"GO:0009605","GO:0009605","response to external stimulus",7,"7/50","CLEC2A/SELP/CARTPT/TRPA1/RAG2/RFPL1/PDC"
21+
"GO:0022414","GO:0022414","reproductive process",6,"6/50","LDHC/CA12/PSG1/PSG6/ADAM21/PSG11"
22+
"GO:0019222","GO:0019222","regulation of metabolic process",6,"6/50","NGF/OR7D2/VAX2/CARTPT/RAG2/RFPL1"
23+
"GO:0071840","GO:0071840","cellular component organization or biogenesis",6,"6/50","MGARP/NGF/SELP/VAX2/TRPA1/RAG2"
24+
"GO:0007275","GO:0007275","multicellular organism development",6,"6/50","MGARP/NGF/VAX2/CARTPT/RAG2/ADAM21"
25+
"GO:0048856","GO:0048856","anatomical structure development",6,"6/50","MGARP/NGF/VAX2/CARTPT/RAG2/ADAM21"
26+
"GO:0023056","GO:0023056","positive regulation of signaling",6,"6/50","SCGN/NGF/FAM83B/SELP/CARTPT/RFPL1"
27+
"GO:0048583","GO:0048583","regulation of response to stimulus",6,"6/50","NGF/FAM83B/SELP/CARTPT/RFPL1/PDC"
28+
"GO:0042221","GO:0042221","response to chemical",6,"6/50","COL6A2/MGARP/OR7D2/SELP/CARTPT/TRPA1"
29+
"GO:0051234","GO:0051234","establishment of localization",6,"6/50","GABRQ/MGARP/FKBP1C/CLEC4F/CARTPT/TRPA1"
30+
"GO:0065008","GO:0065008","regulation of biological quality",6,"6/50","SCGN/HGFAC/GABRQ/NGF/SELP/CARTPT"
31+
"GO:0002682","GO:0002682","regulation of immune system process",5,"5/50","PSG1/SELP/PSG6/CARTPT/RAG2"
32+
"GO:0048869","GO:0048869","cellular developmental process",5,"5/50","MGARP/NGF/VAX2/CARTPT/RAG2"
33+
"GO:0048878","GO:0048878","chemical homeostasis",5,"5/50","SCGN/CA12/FKBP1C/CARTPT/TRPA1"
34+
"GO:0048584","GO:0048584","positive regulation of response to stimulus",5,"5/50","NGF/FAM83B/SELP/CARTPT/RFPL1"
35+
"GO:0007155","GO:0007155","cell adhesion",4,"4/50","COL6A2/SELP/RAG2/PSG11"
36+
"GO:0008283","GO:0008283","cell population proliferation",4,"4/50","NGF/FAM83B/RAG2/RFPL1"
37+
"GO:0051641","GO:0051641","cellular localization",4,"4/50","MGARP/FKBP1C/CARTPT/RFPL1"
38+
"GO:0051239","GO:0051239","regulation of multicellular organismal process",4,"4/50","NGF/SELP/CARTPT/RAG2"
39+
"GO:0051240","GO:0051240","positive regulation of multicellular organismal process",4,"4/50","NGF/SELP/CARTPT/RAG2"
40+
"GO:0050793","GO:0050793","regulation of developmental process",4,"4/50","MGARP/NGF/CARTPT/RAG2"
41+
"GO:0019725","GO:0019725","cellular homeostasis",4,"4/50","SCGN/FKBP1C/CARTPT/TRPA1"
42+
"GO:0051707","GO:0051707","response to other organism",4,"4/50","CLEC2A/SELP/RAG2/RFPL1"
43+
"GO:0009607","GO:0009607","response to biotic stimulus",4,"4/50","CLEC2A/SELP/RAG2/RFPL1"
44+
"GO:0009628","GO:0009628","response to abiotic stimulus",4,"4/50","COL6A2/MGARP/TRPA1/PDC"
45+
"GO:0065009","GO:0065009","regulation of molecular function",4,"4/50","NGF/FKBP1C/CARTPT/RFPL1"
46+
"GO:0006955","GO:0006955","immune response",3,"3/50","CLEC2A/RAG2/RFPL1"
47+
"GO:0009893","GO:0009893","positive regulation of metabolic process",3,"3/50","NGF/CARTPT/RFPL1"
48+
"GO:0008219","GO:0008219","cell death",3,"3/50","COL6A2/NGF/RFPL1"
49+
"GO:0055085","GO:0055085","transmembrane transport",3,"3/50","GABRQ/FKBP1C/TRPA1"
50+
"GO:0044703","GO:0044703","multi-organism reproductive process",3,"3/50","PSG1/PSG6/PSG11"
51+
"GO:0044706","GO:0044706","multi-multicellular organism process",3,"3/50","PSG1/PSG6/PSG11"
52+
"GO:0051093","GO:0051093","negative regulation of developmental process",3,"3/50","MGARP/CARTPT/RAG2"
53+
"GO:0032879","GO:0032879","regulation of localization",3,"3/50","FKBP1C/CARTPT/RFPL1"
54+
"GO:0051606","GO:0051606","detection of stimulus",3,"3/50","OR7D2/TRPA1/PDC"
55+
"GO:0033036","GO:0033036","macromolecule localization",3,"3/50","MGARP/CARTPT/RFPL1"
56+
"GO:0002252","GO:0002252","immune effector process",2,"2/50","CLEC2A/RAG2"
57+
"GO:0002683","GO:0002683","negative regulation of immune system process",2,"2/50","CARTPT/RAG2"
58+
"GO:0009056","GO:0009056","catabolic process",2,"2/50","LDHC/RFPL1"
59+
"GO:0044281","GO:0044281","small molecule metabolic process",2,"2/50","LDHC/CA12"
60+
"GO:0001775","GO:0001775","cell activation",2,"2/50","SELP/RAG2"
61+
"GO:0007017","GO:0007017","microtubule-based process",2,"2/50","LDHC/MGARP"
62+
"GO:0048870","GO:0048870","cell motility",2,"2/50","LDHC/SELP"
63+
"GO:0007610","GO:0007610","behavior",2,"2/50","NGF/CARTPT"
64+
"GO:0050817","GO:0050817","coagulation",2,"2/50","HGFAC/SELP"
65+
"GO:0051241","GO:0051241","negative regulation of multicellular organismal process",2,"2/50","CARTPT/RAG2"
66+
"GO:0009653","GO:0009653","anatomical structure morphogenesis",2,"2/50","NGF/VAX2"
67+
"GO:0048589","GO:0048589","developmental growth",2,"2/50","NGF/RAG2"
68+
"GO:0051094","GO:0051094","positive regulation of developmental process",2,"2/50","NGF/RAG2"
69+
"GO:0040008","GO:0040008","regulation of growth",2,"2/50","NGF/RAG2"
70+
"GO:0045927","GO:0045927","positive regulation of growth",2,"2/50","NGF/RAG2"
71+
"GO:0009719","GO:0009719","response to endogenous stimulus",2,"2/50","MGARP/NGF"
72+
"GO:0019953","GO:0019953","sexual reproduction",1,"1/50","ADAM21"
73+
"GO:0032504","GO:0032504","multicellular organism reproduction",1,"1/50","CA12"
74+
"GO:0002200","GO:0002200","somatic diversification of immune receptors",1,"1/50","RAG2"
75+
"GO:0002520","GO:0002520","immune system development",1,"1/50","RAG2"
76+
"GO:0002684","GO:0002684","positive regulation of immune system process",1,"1/50","SELP"
77+
"GO:0045321","GO:0045321","leukocyte activation",1,"1/50","RAG2"
78+
"GO:0050900","GO:0050900","leukocyte migration",1,"1/50","SELP"
79+
"GO:0009892","GO:0009892","negative regulation of metabolic process",1,"1/50","VAX2"
80+
"GO:0001906","GO:0001906","cell killing",1,"1/50","CLEC2A"
81+
"GO:0007049","GO:0007049","cell cycle",1,"1/50","RFPL1"
82+
"GO:0016049","GO:0016049","cell growth",1,"1/50","NGF"
83+
"GO:0016192","GO:0016192","vesicle-mediated transport",1,"1/50","CLEC4F"
84+
"GO:0022402","GO:0022402","cell cycle process",1,"1/50","RFPL1"
85+
"GO:0051301","GO:0051301","cell division",1,"1/50","RFPL1"
86+
"GO:0051651","GO:0051651","maintenance of location in cell",1,"1/50","FKBP1C"
87+
"GO:0061919","GO:0061919","process utilizing autophagic mechanism",1,"1/50","RFPL1"
88+
"GO:0140352","GO:0140352","export from cell",1,"1/50","CARTPT"
89+
"GO:0019058","GO:0019058","viral life cycle",1,"1/50","RFPL1"
90+
"GO:0050792","GO:0050792","regulation of viral process",1,"1/50","RFPL1"
91+
"GO:0003006","GO:0003006","developmental process involved in reproduction",1,"1/50","ADAM21"
92+
"GO:0009566","GO:0009566","fertilization",1,"1/50","ADAM21"
93+
"GO:0048609","GO:0048609","multicellular organismal reproductive process",1,"1/50","CA12"
94+
"GO:0097722","GO:0097722","sperm motility",1,"1/50","LDHC"
95+
"GO:0007389","GO:0007389","pattern specification process",1,"1/50","VAX2"
96+
"GO:0033555","GO:0033555","multicellular organismal response to stress",1,"1/50","TRPA1"
97+
"GO:0035265","GO:0035265","organ growth",1,"1/50","RAG2"
98+
"GO:0048771","GO:0048771","tissue remodeling",1,"1/50","CARTPT"
99+
"GO:0048871","GO:0048871","multicellular organismal-level homeostasis",1,"1/50","CARTPT"
100+
"GO:0040012","GO:0040012","regulation of locomotion",1,"1/50","SELP"
101+
"GO:0040017","GO:0040017","positive regulation of locomotion",1,"1/50","SELP"
102+
"GO:0002358","GO:0002358","B cell homeostatic proliferation",1,"1/50","RAG2"
103+
"GO:0044403","GO:0044403","biological process involved in symbiotic interaction",1,"1/50","RFPL1"
104+
"GO:0007623","GO:0007623","circadian rhythm",1,"1/50","CARTPT"
105+
"GO:0042698","GO:0042698","ovulation cycle",1,"1/50","CA12"
106+
"GO:0051050","GO:0051050","positive regulation of transport",1,"1/50","CARTPT"
107+
"GO:0023057","GO:0023057","negative regulation of signaling",1,"1/50","CARTPT"
108+
"GO:0048585","GO:0048585","negative regulation of response to stimulus",1,"1/50","CARTPT"
109+
"GO:0051051","GO:0051051","negative regulation of transport",1,"1/50","CARTPT"
110+
"GO:0043903","GO:0043903","regulation of biological process involved in symbiotic interaction",1,"1/50","RFPL1"
111+
"GO:0051235","GO:0051235","maintenance of location",1,"1/50","FKBP1C"
112+
"GO:0051640","GO:0051640","organelle localization",1,"1/50","MGARP"

0 commit comments

Comments
 (0)