Nuevo template.
This commit is contained in:
+26
-27
@@ -23,8 +23,9 @@ ui <- fluidPage(
|
|||||||
tabPanel("Diseño",
|
tabPanel("Diseño",
|
||||||
sidebarPanel(
|
sidebarPanel(
|
||||||
fileInput(inputId = "file_sizes", label = "Hoja de tamaños", multiple = F),
|
fileInput(inputId = "file_sizes", label = "Hoja de tamaños", multiple = F),
|
||||||
selectInput(inputId = "measure_sys", "Sistema de medida", selected = "L-W-D", choices = c("L-W-D","Min-Max","Absorbance")),
|
|
||||||
uiOutput('ncages'),
|
uiOutput('ncages'),
|
||||||
|
uiOutput('ntumors'),
|
||||||
|
# selectInput(inputId = "measure_sys", "Sistema de medida", selected = "L-W-D", choices = c("L-W-D","Min-Max","Absorbance")),
|
||||||
uiOutput('lowcut'),
|
uiOutput('lowcut'),
|
||||||
uiOutput('upcut'),
|
uiOutput('upcut'),
|
||||||
uiOutput('goButton'),
|
uiOutput('goButton'),
|
||||||
@@ -153,6 +154,12 @@ server <- function(input, output) {
|
|||||||
sliderInput("ncages", "Cajas", min=1, max=10, value=1)
|
sliderInput("ncages", "Cajas", min=1, max=10, value=1)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
output$ntumors<-renderUI({
|
||||||
|
if (is.null(dades$taula)){
|
||||||
|
selectInput("ntumors", "Tumores por ratón", choices = c(1,2), selected = 2)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
grafic<-eventReactive(input$goButton,{
|
grafic<-eventReactive(input$goButton,{
|
||||||
df<-dades$taula
|
df<-dades$taula
|
||||||
df<-df[!is.na(df$Volume),]
|
df<-df[!is.na(df$Volume),]
|
||||||
@@ -284,12 +291,12 @@ server <- function(input, output) {
|
|||||||
ncages<-input$ncages
|
ncages<-input$ncages
|
||||||
nrat_cage<-5
|
nrat_cage<-5
|
||||||
id_tumors<-c("L","R")
|
id_tumors<-c("L","R")
|
||||||
timepoint<-c(7,10,13,16,19,22,25)
|
# timepoint<-c(7,10,13,16,19,22,25)
|
||||||
|
|
||||||
if (!is.null(input$file_sizes)){
|
if (!is.null(input$file_sizes)){
|
||||||
dtemplate<-dades$db %>% select(-Volume,-sex)
|
# dtemplate<-dades$db %>% select(-Volume,-sex)
|
||||||
dtemplate<-melt(dtemplate, id=c("Cage", "ID animal", "ID tumor", "group"), variable.name = "DPV", value.name = "0") %>% rename("Group"="group")
|
# dtemplate<-melt(dtemplate, id=c("Cage", "ID animal", "ID tumor", "group"), variable.name = "DPV", value.name = "0") %>% rename("Group"="group")
|
||||||
dtemplate<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] %>% arrange(`ID animal`, `ID tumor`)
|
# dtemplate<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] %>% arrange(`ID animal`, `ID tumor`)
|
||||||
# template<-expand.grid(dades$db$MouseID, timepoint)
|
# template<-expand.grid(dades$db$MouseID, timepoint)
|
||||||
# colnames(template)<-c("MouseID", "Timepoint")
|
# colnames(template)<-c("MouseID", "Timepoint")
|
||||||
# template<-template[order(template$Timepoint, template$MouseID),]
|
# template<-template[order(template$Timepoint, template$MouseID),]
|
||||||
@@ -313,28 +320,20 @@ server <- function(input, output) {
|
|||||||
# dtemplate["ID animal"]<-gsub("[LR]","",dtemplate$`ID animal`)
|
# dtemplate["ID animal"]<-gsub("[LR]","",dtemplate$`ID animal`)
|
||||||
# dtemplate[,5:ncol(dtemplate)]<-""
|
# dtemplate[,5:ncol(dtemplate)]<-""
|
||||||
}else{
|
}else{
|
||||||
template<-expand.grid(LETTERS[1:ncages], 1:5, id_tumors, timepoint)[,-2]
|
template<-data.frame(
|
||||||
colnames(template)<-c("Cage", "ID tumor", "Timepoint")
|
Cage=rep(LETTERS[1:ncages], each=nrat_cage*input$ntumors),
|
||||||
nids<-length(id_tumors)*length(timepoint)
|
Date="",
|
||||||
template[order(template$Cage),"ID animal"]<-rep(1:(nrow(template)/(nids)), each=nids)
|
DayPostInoc="",
|
||||||
template<-template[order(template$Timepoint, template$Cage, template$`ID animal`),]
|
Animal=rep(1:(nrat_cage*ncages), each=input$ntumors),
|
||||||
template["Group"]<-""
|
Group="",
|
||||||
if (input$measure_sys == "L-W-D"){
|
Side=rep(id_tumors, nrat_cage*ncages),
|
||||||
template<-rbind(template, template, template)
|
Weight="",
|
||||||
template<-template[order(template$Timepoint, template$Cage, template$`ID animal`, template$`ID tumor`),]
|
Long="",
|
||||||
template["TS"]<-rep(c("TS-Length", "TS-Width", "TS-Deep"), nrow(template)/3)
|
Wide="",
|
||||||
dtemplate<-dcast(template, Cage+`ID animal`+`ID tumor`+Group+TS~Timepoint)
|
Volume="",
|
||||||
dtemplate<-dtemplate[order(match(dtemplate$TS, c("TS-Length", "TS-Width", "TS-Deep"))),]
|
Observations=""
|
||||||
dtemplate<-dtemplate[mixedorder(dtemplate$`ID tumor`),]
|
)
|
||||||
dtemplate<-dtemplate[mixedorder(dtemplate$`ID animal`),]
|
dtemplate<-template
|
||||||
}
|
|
||||||
if (input$measure_sys == "Min-Max"){
|
|
||||||
template<-rbind(template, template)
|
|
||||||
template<-template[order(template$Timepoint, template$Cage, template$`ID animal`, template$`ID tumor`),]
|
|
||||||
template["DPV"]<-rep(c("Major", "Minor"), nrow(template)/2)
|
|
||||||
dtemplate<-dcast(template, Cage+`ID animal`+`ID tumor`+Group+DPV~Timepoint)
|
|
||||||
}
|
|
||||||
dtemplate[,6:ncol(dtemplate)]<-""
|
|
||||||
}
|
}
|
||||||
write.xlsx(dtemplate,file)
|
write.xlsx(dtemplate,file)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user