Browse Source

Nuevo template.

master
marcelcosta 1 year ago
parent
commit
7ca800a3e8
1 changed files with 26 additions and 27 deletions
  1. +26
    -27
      invivos/app.R

+ 26
- 27
invivos/app.R

@ -23,8 +23,9 @@ ui <- fluidPage(
tabPanel("Diseño",
sidebarPanel(
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('ntumors'),
# selectInput(inputId = "measure_sys", "Sistema de medida", selected = "L-W-D", choices = c("L-W-D","Min-Max","Absorbance")),
uiOutput('lowcut'),
uiOutput('upcut'),
uiOutput('goButton'),
@ -153,6 +154,12 @@ server <- function(input, output) {
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,{
df<-dades$taula
df<-df[!is.na(df$Volume),]
@ -284,12 +291,12 @@ server <- function(input, output) {
ncages<-input$ncages
nrat_cage<-5
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)){
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<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] %>% arrange(`ID animal`, `ID tumor`)
# 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<-dtemplate[,c("Cage", "ID animal", "ID tumor", "Group", "DPV", "0")] %>% arrange(`ID animal`, `ID tumor`)
# template<-expand.grid(dades$db$MouseID, timepoint)
# colnames(template)<-c("MouseID", "Timepoint")
# template<-template[order(template$Timepoint, template$MouseID),]
@ -313,28 +320,20 @@ server <- function(input, output) {
# dtemplate["ID animal"]<-gsub("[LR]","",dtemplate$`ID animal`)
# dtemplate[,5:ncol(dtemplate)]<-""
}else{
template<-expand.grid(LETTERS[1:ncages], 1:5, id_tumors, timepoint)[,-2]
colnames(template)<-c("Cage", "ID tumor", "Timepoint")
nids<-length(id_tumors)*length(timepoint)
template[order(template$Cage),"ID animal"]<-rep(1:(nrow(template)/(nids)), each=nids)
template<-template[order(template$Timepoint, template$Cage, template$`ID animal`),]
template["Group"]<-""
if (input$measure_sys == "L-W-D"){
template<-rbind(template, template, template)
template<-template[order(template$Timepoint, template$Cage, template$`ID animal`, template$`ID tumor`),]
template["TS"]<-rep(c("TS-Length", "TS-Width", "TS-Deep"), nrow(template)/3)
dtemplate<-dcast(template, Cage+`ID animal`+`ID tumor`+Group+TS~Timepoint)
dtemplate<-dtemplate[order(match(dtemplate$TS, c("TS-Length", "TS-Width", "TS-Deep"))),]
dtemplate<-dtemplate[mixedorder(dtemplate$`ID tumor`),]
dtemplate<-dtemplate[mixedorder(dtemplate$`ID animal`),]
}
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)]<-""
template<-data.frame(
Cage=rep(LETTERS[1:ncages], each=nrat_cage*input$ntumors),
Date="",
DayPostInoc="",
Animal=rep(1:(nrat_cage*ncages), each=input$ntumors),
Group="",
Side=rep(id_tumors, nrat_cage*ncages),
Weight="",
Long="",
Wide="",
Volume="",
Observations=""
)
dtemplate<-template
}
write.xlsx(dtemplate,file)
}

Loading…
Cancel
Save