-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
174 lines (139 loc) · 7.31 KB
/
Copy pathapp.R
File metadata and controls
174 lines (139 loc) · 7.31 KB
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
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
library(shiny)
library(ggplot2)
#--------------------------------------------------------
ui <- pageWithSidebar(
# Application title
headerPanel("Modelisation du cycle de mue de la femelle Gammarus fossarum"),
# Sidebar with a slider input for number of observations
sidebarPanel(
sliderInput("t", "Temps (jours) :", min = 0, max = 70, value = 1, step = 1),
sliderInput("kappa", "Proportion kappa de la nourriture dediee au soma :", min = 0.5, max = 1, value = 0.9, step = 0.01),
sliderInput("JV.YVA", "Flux net de synthese des structures de mue en mg/jour:", min = 0.01, max = 0.1, value = 0.05, step=0.005),
sliderInput("JF", "Feeding rate en mg/jour/individu :", min=0.1, max=2.5, value=1, step=0.1),
sliderInput("WSS", "biomasse assimilee contenue dans le buffer de stockage lors du passage en stade D1 : ", min=0.1, max=20, value=5, step=0.5),
),
# Show a plot of the generated distribution
mainPanel(
tableOutput("table"),
plotOutput("hist", height = 500),
imageOutput("diapo", height = 300)
)
)
#--------------------------------------------------------
server <- function(input, output) {
WB0 <- 0.045
yBA <- 0.95
yAF <- 0.3
#----------------
output$table <- renderTable({
jM = 0.135 * input$JF*yAF
data.frame("Duree de la phase I"=input$WSS / (input$kappa*input$JF*yAF - jM),
"Duree de la phase II"= input$WSS / (input$JV.YVA + jM),
"Nombre d'oeufs pondus" = trunc((yBA*(1-input$kappa)*input$JF*yAF*input$WSS)/(WB0*(input$kappa*input$JF*yAF - jM)))
)
})
#----------------
output$hist <- renderPlot({
jM = 0.135 * input$JF*yAF
if(input$t<= (input$WSS / (input$kappa*input$JF*yAF - jM))){
print("phaseI")
data <- data.frame(c("Structure","Stockage","Ponte"),
c(0,(input$kappa*input$JF*yAF - jM)*input$t,(1-input$kappa)*input$JF*yAF*input$t))
colnames(data) = c("category","amount")
#---
ggplot(data, aes(x="", y=amount, fill=category)) +
theme_classic() +
ggtitle("Porportion de la masse totale associee aux differents compartiments en PHASE I") +
geom_bar(stat="identity", width=1) +
coord_polar("y", start=0) +
geom_text(aes(label = paste0(round(amount/sum(amount)*100, digits = 1), "%")),
position = position_stack(vjust=0.5), size = 5, color=c("#55007e", "#00687e", "#329d00")) +
labs(x = NULL, y = NULL, fill = "Compartiment") +
theme(plot.title = element_text(size=13, face="bold"),
legend.title = element_text(size = 15, face="bold"),
legend.text = element_text(size = 15),
axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()) +
scale_fill_manual(values=c("#75FF33", "#33DBFF", "#BD33FF"))
}else{ if(input$t<= (input$WSS / (input$JV.YVA + jM))){
print("phaseII")
data <- data.frame(c("Structure","Stockage","Ponte"),
c(0 + input$JV.YVA*(input$t - (input$WSS / (input$kappa*input$JF*yAF - jM))),
input$WSS - (input$JV.YVA + jM)*(input$t - (input$WSS / (input$kappa*input$JF*yAF - jM))),
(1-input$kappa)*input$JF*yAF*(input$WSS / (input$kappa*input$JF*yAF - jM))))
colnames(data) = c("category","amount")
#---
ggplot(data, aes(x="", y=amount, fill=category)) +
theme_classic() +
ggtitle("Porportion de la masse totale associee aux differents compartiments en PHASE II") +
geom_bar(stat="identity", width=1) +
coord_polar("y", start=0) +
geom_text(aes(label = paste0(round(amount/sum(amount)*100, digits = 1), "%")),
position = position_stack(vjust=0.5), size = 5, color=c("#55007e", "#00687e", "#329d00")) +
labs(x = NULL, y = NULL, fill = "Compartiment") +
theme(plot.title = element_text(size=13, face="bold"),
legend.title = element_text(size = 15, face="bold"),
legend.text = element_text(size = 15),
axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()) +
scale_fill_manual(values=c("#75FF33", "#33DBFF", "#BD33FF"))
}else{
print("t=end of phaseII= mue")
data <- data.frame(c("Structure","Stockage","Ponte"),
c(0 + input$JV.YVA*((input$WSS / (input$JV.YVA + jM)) - (input$WSS / (input$kappa*input$JF*yAF - jM))),
input$WSS - (input$JV.YVA + jM)*((input$WSS / (input$JV.YVA + jM)) - (input$WSS / (input$kappa*input$JF*yAF - jM))),
(1-input$kappa)*input$JF*yAF*(input$WSS / (input$kappa*input$JF*yAF - jM))))
colnames(data) = c("category","amount")
#---
ggplot(data, aes(x="", y=amount, fill=category)) +
theme_classic() +
ggtitle("Porportion de la masse totale associee aux differents compartiments a la FIN DE LA PHASE II (mue)") +
geom_bar(stat="identity", width=1) +
coord_polar("y", start=0) +
geom_text(aes(label = paste0(round(amount/sum(amount)*100, digits = 1), "%")),
position = position_stack(vjust=0.5), size = 5, color=c("#55007e", "#00687e", "#329d00")) +
labs(x = NULL, y = NULL, fill = "Compartiment") +
theme(plot.title = element_text(size=13, face="bold"),
legend.title = element_text(size = 15, face="bold"),
legend.text = element_text(size = 15),
axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank()) +
scale_fill_manual(values=c("#75FF33", "#33DBFF", "#BD33FF"))
}}
})
#----------------
output$diapo <- renderImage({
jM = 0.135 * input$JF*yAF
if (input$t<= (input$WSS / (input$kappa*input$JF*yAF - jM))) {
return(list(
src = "Diapositive10.jpg",
contentType = "image/jpg",
width = 600,
heigh = 600,
alt = "Phase I"
))
} else {
return(list(
src = "Diapositive11.jpg",
filetype = "image/jpeg",
width = 600,
heigh = 600,
alt = "Phase II"
))
}
}, deleteFile = FALSE)
}
#----------------------------------------
# Run the application
shinyApp(ui = ui, server = server)