-
Notifications
You must be signed in to change notification settings - Fork 0
/
GOSemSim_down_regulated.R
63 lines (55 loc) · 2.35 KB
/
GOSemSim_down_regulated.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
60
61
62
63
library(GOSemSim)
library(org.Dm.eg.db)
library(vegan)
#Reference for Fly
d = godata('org.Dm.eg.db', ont = "BP", computeIC = FALSE)
contrast = read.csv("contrasts_mite_life_stages.csv", header = F)
#MITE
GOSEMSIM_matrix_mite = matrix(0, 12, nrow=12)
#DOWN-REGULATED
for(i in 1:(length(contrast$V1)-1))
{
first_contrast = toString(contrast$V1[i])
second_contrast = toString(contrast$V2[i])
filename = paste("./GO_enrichment_output/contrast_", first_contrast, "_", second_contrast, "_downregulated", ".csv", sep = "")
GO1 = read.csv(filename, header = T)
GO1ID = as.character(GO1[,1])
for(j in (i+1):length(contrast$V1))
{
print(paste(i, j))
first_contrast = toString(contrast$V1[j])
second_contrast = toString(contrast$V2[j])
filename = paste("./GO_enrichment_output/contrast_", first_contrast, "_", second_contrast, "_downregulated", ".csv", sep = "")
GO2 = read.csv(filename, header = T)
GO2ID = as.character(GO2[,1])
GOSEMSIM_matrix_mite[i,j] <- mgoSim(GO1ID, GO2ID, semData = d, measure = "Wang", combine = "BMA")
}
name = paste(first_contrast, "_", second_contrast,sep = "")
}
#MICROBIOME
GOSEMSIM_matrix_microbiome = matrix(0, 12, nrow=12)
#DOWN-REGULATED
for(i in 1:(length(contrast$V1)-1))
{
first_contrast = toString(contrast$V1[i])
second_contrast = toString(contrast$V2[i])
filename = paste("./GO_enrichment_microbiome_output/contrast_", first_contrast, "_", second_contrast, "_downregulated", ".csv", sep = "")
GO1 = read.csv(filename, header = T)
GO1ID = as.character(GO1[,1])
for(j in (i+1):(length(contrast$V1)))
{
print(paste(i, j))
first_contrast = toString(contrast$V1[j])
second_contrast = toString(contrast$V2[j])
filename = paste("./GO_enrichment_microbiome_output/contrast_", first_contrast, "_", second_contrast, "_downregulated", ".csv", sep = "")
GO2 = read.csv(filename, header = T)
GO2ID = as.character(GO2[,1])
GOSEMSIM_matrix_microbiome[i,j] <- mgoSim(GO1ID, GO2ID, semData = d, measure = "Wang", combine = "BMA")
}
name = paste(first_contrast, "_", second_contrast,sep = "")
}
microb_dist = as.dist(t(GOSEMSIM_matrix_microbiome))
mite_dist = as.dist(t(GOSEMSIM_matrix_mite))
mantel(mite_dist, microb_dist)
write.csv(as.data.frame(GOSEMSIM_matrix_microbiome), "GOSEMSIM_matrix_microbiome_down.csv")
write.csv(as.data.frame(GOSEMSIM_matrix_mite), "GOSEMSIM_matrix_mite_down.csv")