-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomparisonAverages.Rmd
200 lines (138 loc) · 4.81 KB
/
comparisonAverages.Rmd
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
---
title: "diseasy.aves"
output: html_document
date: "2024-05-19"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Load
```{r, include=FALSE}
library(tidyverse)
library(ggplot2)
library(tibble)
library(ggpubr)
```
```{r, include=FALSE}
h2h <- read_tsv("h2h.aves", col_names = c("gene", "semLines", "semWords", "textLines", "textWords"))
z2z <- read_tsv("z2z.aves", col_names = c("gene", "semLines", "semWords", "textLines", "textWords"))
h2z <- read_tsv("h2z.aves", col_names = c("gene", "semLines", "semWords", "textLines", "textWords"))
h2h <- h2h[,1:5]
z2z <- z2z[,1:5]
h2z <- h2z[,1:5]
```
# Add averages
```{r, results='hide'}
h2h %>%
add_row(gene = 'Mean', !!! colMeans(.[-1]))
z2z %>%
add_row(gene = 'Mean', !!! colMeans(.[-1]))
h2z %>%
add_row(gene = 'Mean', !!! colMeans(.[-1]))
h2hMean <- colMeans(h2h[-1])
z2zMean <-colMeans(z2z[-1])
h2zMean <-colMeans(h2z[-1])
Mean4 = as.data.frame(list(h2hMean,z2zMean,h2zMean), col.names = c("H2H","Z2Z","H2Z"))
```
```{r}
human = as.data.frame(t(h2hMean))
human = pivot_longer(human, c(semLines, semWords, textLines,textWords), names_to = "Comparison", values_to = "Value")
ggplot(human, aes(y= Value, x=Comparison))+
geom_col()+
labs(title="Human to Human")+
ylim(0,1)
fish = as.data.frame(t(z2zMean))
fish = pivot_longer(fish, c(semLines, semWords, textLines,textWords), names_to = "Comparison", values_to = "Value")
ggplot(fish, aes(y= Value, x=Comparison))+
geom_col()+
labs(title="fish to fish")+
ylim(0,1)
both = as.data.frame(t(h2zMean))
both = pivot_longer(both, c(semLines, semWords, textLines,textWords), names_to = "Comparison", values_to = "Value")
ggplot(both, aes(y= Value, x=Comparison))+
geom_col()+
labs(title="Human to fish")+
ylim(0,1)
```
```{r, results='hide'}
h2hMean <- colMeans(h2h[-1])
h <- as.data.frame(h2hMean,row.names = c("semanticLines", "semanticWords", "textLines","textWords"))
colnames(h)<- "mean"
h <- add_column(h, comp =c("semanticLines", "semanticWords", "textLines","textWords"), species = "h2h")
h
z <- as.data.frame(z2zMean,row.names = c("semanticLines", "semanticWords", "textLines","textWords"))
colnames(z)<- "mean"
z<- add_column(z, comp =c("semanticLines", "semanticWords", "textLines","textWords"), species = "z2z")
z
b <- as.data.frame(h2zMean,row.names = c("semanticLines", "semanticWords", "textLines","textWords"))
colnames(b)<- "mean"
b<- add_column(b, comp =c("semanticLines", "semanticWords", "textLines","textWords"), species = "h2z")
b
a = h %>%
add_row(z) %>%
add_row(b)
a
```
```{r}
p1 <- ggplot(a)+
geom_col(aes(x=comp, y=mean,group = species, fill = species), position = "dodge")
p2<- ggplot(a)+
geom_col(aes(x=species, y=mean,group = comp, fill = comp), position = "dodge")
ggarrange(p1, p2, ncol=2)
```
```{r}
library(shiny)
library(tidyverse)
# other libraries here
# data loading and one-time processing here
a
# Define UI for application
ui <- fluidPage( #create the overall page
#UI code here
titlePanel("Average Comparison Scores"),
helpText("Mean scores for human to human disease descriptions, zebrafish to zebrafish phenotype, and human to zebrafish comparison for text and semantic, words or lines."),
sidebarLayout(
sidebarPanel(
radioButtons("species", #the input variable that the value will go into
"Choose a species to display:",
choices =list("Human to Human" = "h2h",
"Zebrafish to Zebrafish" = 'z2z',
"Human to Zebrafish"= "h2z")),
checkboxGroupInput("Comparison", "Choose a comparison method to display:",
choices =list("Semantic + Lines" = "semLines",
"Semantic + Words" = "semWords",
"Text + Lines"= "textLines",
"Text + Words" = "textWords"),
selected = c("semLines",
"semWords",
"textLines",
"textWords"))
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("barPlot"),
textOutput("text")
)))
# Define server logic
server <- function(input, output) {
# server code here
inputData <- reactive({
#plotTrait <- as.name(input$species)
#plotTrait2 <- as.name(input$Comparison)
pure = filter(a, species == input$species)
pured = filter(pure, comp == input$Comparison)
return(pured)
})
output$barPlot <- renderPlot({
p1<- ggplot(data=inputData,
aes(
x = comp, y= mean
)
)
p1 + geom_col()
})
output$text <- renderText({paste("You have selected", as.name(input$Comparison), input$Comparison)})
}
# Run the application
shinyApp(ui = ui, server = server)
```