|
|
@ -0,0 +1,107 @@ |
|
|
|
library(shiny) |
|
|
|
library(rhandsontable) |
|
|
|
|
|
|
|
DF<-as.data.frame(matrix(nrow=1, ncol=5)) |
|
|
|
colnames(DF)<-c("name","conc.vector","bp.vector","conc.insert","bp.insert") |
|
|
|
DF[1,]<-rep("",5) |
|
|
|
|
|
|
|
ui <- fluidPage( |
|
|
|
|
|
|
|
# Application title |
|
|
|
titlePanel("Lligacions"), |
|
|
|
|
|
|
|
# Sidebar with a slider input for number of bins |
|
|
|
sidebarLayout( |
|
|
|
sidebarPanel( |
|
|
|
sliderInput("ratio", |
|
|
|
"Ratio Insert:Vector :", |
|
|
|
min = 1, |
|
|
|
max = 20, |
|
|
|
value = 10), |
|
|
|
sliderInput("minim", |
|
|
|
"Volum mínim:", |
|
|
|
min = 0.2, |
|
|
|
max = 1.25, |
|
|
|
value = 0.5, step = 0.1), |
|
|
|
sliderInput("voltotal", |
|
|
|
"Volum Total:", |
|
|
|
min = 1.5, |
|
|
|
max = 2.5, |
|
|
|
value = 2, step = 0.5), |
|
|
|
width = 3), |
|
|
|
|
|
|
|
# Show a plot of the generated distribution |
|
|
|
mainPanel( |
|
|
|
rHandsontableOutput("hot"), |
|
|
|
tableOutput("results") |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
# Define server logic required to draw a histogram |
|
|
|
server <- function(input, output) { |
|
|
|
|
|
|
|
values <- reactiveValues() |
|
|
|
|
|
|
|
## Handsontable |
|
|
|
observe({ |
|
|
|
if (!is.null(input$hot)) { |
|
|
|
DF = hot_to_r(input$hot) |
|
|
|
} else { |
|
|
|
if (is.null(values[["DF"]])){ |
|
|
|
DF <- DF |
|
|
|
} |
|
|
|
else{ |
|
|
|
DF <- values[["DF"]] |
|
|
|
} |
|
|
|
} |
|
|
|
values[["DF"]] <- DF |
|
|
|
}) |
|
|
|
|
|
|
|
output$hot <- renderRHandsontable({ |
|
|
|
print(DF) |
|
|
|
if (!is.null(DF)){ |
|
|
|
rhandsontable(DF, stretchH = "all", readOnly = F, useTypes = T) |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
output$results <- renderTable({ |
|
|
|
observe({values}) |
|
|
|
t<-values[["DF"]] |
|
|
|
print(t) |
|
|
|
if (nrow(t) > 1){ |
|
|
|
t[2:5]<-as.data.frame(apply(t[2:5],2,as.numeric)) |
|
|
|
}else{ |
|
|
|
t[2:5]<-as.data.frame(t(apply(t[2:5],2,as.numeric))) |
|
|
|
} |
|
|
|
|
|
|
|
Vv<-( (input$voltotal*t$conc.insert*t$bp.vector)/(t$conc.vector*t$bp.insert*input$ratio) ) / (1+(t$conc.insert*t$bp.vector)/(t$conc.vector*t$bp.insert*input$ratio)) |
|
|
|
Vi<-input$voltotal-Vv |
|
|
|
|
|
|
|
t[,"vol.v"]<-Vv |
|
|
|
t[,"vol.i"]<-Vi |
|
|
|
t[,"dil.v"]<-1 |
|
|
|
t[,"dil.i"]<-1 |
|
|
|
|
|
|
|
Vv.log<-Vv < input$minim |
|
|
|
if (TRUE %in% Vv.log){ |
|
|
|
alt.conc.vector<-( (input$voltotal-input$minim)*t$conc.insert*t$bp.vector)/ (input$minim*t$bp.insert*input$ratio) |
|
|
|
t$dil.v[Vv.log]<-(t$conc.vector/alt.conc.vector)[Vv.log] |
|
|
|
t$vol.v[Vv.log]<-input$minim |
|
|
|
t$vol.i[Vv.log]<-(input$voltotal-input$minim) |
|
|
|
} |
|
|
|
|
|
|
|
Vi.log<-Vi < input$minim |
|
|
|
if (TRUE %in% Vi.log){ |
|
|
|
alt.conc.insert<-( (input$voltotal-input$minim)*t$conc.vector*t$bp.insert*input$ratio)/ (input$minim*t$bp.vector) |
|
|
|
t$dil.i[Vi.log]<-(t$conc.insert/alt.conc.insert)[Vi.log] |
|
|
|
t$vol.i[Vi.log]<-input$minim |
|
|
|
t$vol.v[Vi.log]<-(input$voltotal-input$minim) |
|
|
|
} |
|
|
|
t |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
# Run the application |
|
|
|
shinyApp(ui = ui, server = server) |