-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick-start.R
127 lines (106 loc) · 2.77 KB
/
quick-start.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# Install and load
## Showing install and load this package
devtools::install_github('herdiantrisufriyana/alignontology')
library(alignontology)
## Load packages
library(tidyverse)
library(igraph)
# Load simulated data
## Create input example, echo=TRUE}
input=input_example()
## Computed ontology
set.seed(33)
input$computed %>%
graph_from_data_frame(directed=TRUE) %>%
plot.igraph(layout=layout_as_tree(.,mode='in'))
## Reference ontology
set.seed(33)
input$reference %>%
graph_from_data_frame(directed=TRUE) %>%
plot.igraph(layout=layout_as_tree(.,mode='in'))
# Ontology alignment
## Ontology alignment
ao=alignontology(input$computed,input$reference)
## Prepare ontology alignment for visualization
set.seed(33)
ao_tab=
input$computed %>%
left_join(
ao %>%
select(computed,reference) %>%
rename(source=computed)
,by='source'
) %>%
mutate(source=ifelse(is.na(reference),source,reference)) %>%
select(-reference) %>%
left_join(
ao %>%
select(computed,reference) %>%
rename(target=computed)
,by='target'
) %>%
mutate(target=ifelse(is.na(reference),target,reference)) %>%
select(-reference)
g=ao_tab %>%
graph_from_data_frame(directed=TRUE)
V(g)$color=
input$computed %>%
graph_from_data_frame(directed=TRUE) %>%
V() %>%
.$name %>%
data.frame(computed=.) %>%
left_join(ao,by='computed') %>%
select(computed,reference) %>%
mutate(reference=ifelse(is.na(reference),'orange','green')) %>%
pull(reference)
ao_tab2=
input$reference %>%
left_join(
ao %>%
select(computed,reference) %>%
rename(source=reference)
,by='source'
) %>%
mutate(source=ifelse(is.na(computed),source,computed)) %>%
select(-computed) %>%
left_join(
ao %>%
select(computed,reference) %>%
rename(target=reference)
,by='target'
) %>%
mutate(target=ifelse(is.na(computed),target,computed)) %>%
select(-computed)
g2=ao_tab2 %>%
graph_from_data_frame(directed=TRUE)
V(g2)$color=
input$reference %>%
graph_from_data_frame(directed=TRUE) %>%
V() %>%
.$name %>%
data.frame(reference=.) %>%
left_join(ao,by='reference') %>%
select(reference,computed) %>%
mutate(computed=ifelse(is.na(computed),'orange','green')) %>%
pull(computed)
## Ontology alignment
par(mfrow=c(2,2))
set.seed(33)
input$computed %>%
graph_from_data_frame(directed=TRUE) %>%
plot.igraph(layout=layout_as_tree(.,mode='in'),main='Computed ontology')
g %>%
plot.igraph(
layout=layout_as_tree(.,mode='in')
,main='Aligned computed ontology'
)
set.seed(33)
g2 %>%
plot.igraph(
layout=layout_as_tree(.,mode='in')
,main='Aligned reference ontology'
)
set.seed(33)
input$reference %>%
graph_from_data_frame(directed=TRUE) %>%
plot.igraph(layout=layout_as_tree(.,mode='in'),main='Reference ontoloy')