2 Commits

1 changed files with 5 additions and 20 deletions
Unified View
  1. +5
    -20
      invivos/app.R

+ 5
- 20
invivos/app.R

@ -193,7 +193,6 @@ server <- function(input, output) {
grafic<-eventReactive(input$goButton,{ grafic<-eventReactive(input$goButton,{
df<-dades$taula %>% filter(DayPostInoc == input$day_vol) df<-dades$taula %>% filter(DayPostInoc == input$day_vol)
# print(df)
df<-df[!is.na(df$Volume),] df<-df[!is.na(df$Volume),]
up_cuttof<-input$upcut up_cuttof<-input$upcut
low_cuttof<-input$lowcut low_cuttof<-input$lowcut
@ -223,7 +222,6 @@ server <- function(input, output) {
while(interr == T){ while(interr == T){
ind<-sample(rep(dades$groups, each=ceiling(length(unique(df_sex$Animal))/ngroup)), length(unique(df_sex$Animal))) ind<-sample(rep(dades$groups, each=ceiling(length(unique(df_sex$Animal))/ngroup)), length(unique(df_sex$Animal)))
df_sex<-merge(df_sex[,c("Animal", "Side","Volume")], data.frame("Animal"=unique(df_sex$Animal), "group"=as.factor(ind),check.names=F)) df_sex<-merge(df_sex[,c("Animal", "Side","Volume")], data.frame("Animal"=unique(df_sex$Animal), "group"=as.factor(ind),check.names=F))
# print(df_sex)
if ((nrow(df_sex)/ngroup) %% 2 == 0){ if ((nrow(df_sex)/ngroup) %% 2 == 0){
interr<-any(table(df_sex$group) < floor(nrow(df_sex)/ngroup) | table(df_sex$group) > ceiling(nrow(df_sex)/ngroup)) interr<-any(table(df_sex$group) < floor(nrow(df_sex)/ngroup) | table(df_sex$group) > ceiling(nrow(df_sex)/ngroup))
}else{ }else{
@ -244,12 +242,10 @@ server <- function(input, output) {
} }
} }
index<-which(unlist(lvn.list) == min(unlist(lvn.list)[which(unlist(pval.list) %in% sort(unlist(pval.list), decreasing = T)[1:20])]))[1] index<-which(unlist(lvn.list) == min(unlist(lvn.list)[which(unlist(pval.list) %in% sort(unlist(pval.list), decreasing = T)[1:20])]))[1]
# print(df_sex)
df_def[[sex.var]]<-merge(df_sex %>% select(-group), ind.list[[index]]) df_def[[sex.var]]<-merge(df_sex %>% select(-group), ind.list[[index]])
} }
df_def<-do.call(rbind, c(df_def, make.row.names=F)) df_def<-do.call(rbind, c(df_def, make.row.names=F))
# lapply(df_def, function(x) x %>% as_tibble %>% print(n=Inf))
# df_def<-rbind(df_def[[1]], df_def[[2]], make.row.names=F)
if ("Group" %in% colnames(df_def)){ if ("Group" %in% colnames(df_def)){
df_def<-df_def %>% select(-"Group") df_def<-df_def %>% select(-"Group")
} }
@ -407,7 +403,6 @@ server <- function(input, output) {
if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){ if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){
levels<-read.xlsx(input$file_analy$datapath, sheet = "Groups", colNames=F)[,1] levels<-read.xlsx(input$file_analy$datapath, sheet = "Groups", colNames=F)[,1]
print(levels)
table$Group<-factor(table$Group, levels=levels) table$Group<-factor(table$Group, levels=levels)
table<-filter(table, !is.na(Group)) table<-filter(table, !is.na(Group))
}else(table$Group<-factor(table$Group)) }else(table$Group<-factor(table$Group))
@ -433,7 +428,6 @@ server <- function(input, output) {
if (!is.null(analysis$taula)){ if (!is.null(analysis$taula)){
observeEvent(analysis$taula, {}) observeEvent(analysis$taula, {})
max_val<-max(analysis$taula$Volume, na.rm = T) max_val<-max(analysis$taula$Volume, na.rm = T)
# print(max_val)
sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val, digits=2), step=round(max_val, digits=2)/200, value=max_val) sliderInput("cutoff", "Cutoff para Survival", min=0, max=round(max_val, digits=2), step=round(max_val, digits=2)/200, value=max_val)
} }
}) })
@ -454,7 +448,6 @@ server <- function(input, output) {
observeEvent(analysis$taula, {}) observeEvent(analysis$taula, {})
table<-analysis$taula table<-analysis$taula
print(table)
animals<-unique(table$Animal) animals<-unique(table$Animal)
sides<-unique(table$Side) sides<-unique(table$Side)
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group) groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
@ -480,7 +473,7 @@ server <- function(input, output) {
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc)) group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
pull(Animal) pull(Animal)
print(deadmice)
if (input$operated == TRUE & nrow(firstoper) > 0){ if (input$operated == TRUE & nrow(firstoper) > 0){
for (i in 1:nrow(firstoper)){ for (i in 1:nrow(firstoper)){
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i]) table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
@ -652,9 +645,9 @@ server <- function(input, output) {
}else{ }else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T) pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (firstoper == Inf){firstoper<-c()}
if (input$operated == TRUE & nrow(firstoper) > 0){
if (input$operated == TRUE & length(firstoper) > 0){
table<-table %>% filter(DayPostInoc < firstoper) table<-table %>% filter(DayPostInoc < firstoper)
}else{ }else{
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>% deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
@ -694,8 +687,6 @@ server <- function(input, output) {
for (side in c("L","R")){ for (side in c("L","R")){
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume)) tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){ if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){
print(paste0("Side: ",side))
print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR)))
} }
} }
} }
@ -755,7 +746,6 @@ server <- function(input, output) {
}, },
content = function(file){ content = function(file){
dtemplate<-analysis$taula dtemplate<-analysis$taula
# print(str(dtemplate))
write.xlsx(dtemplate,file, ) write.xlsx(dtemplate,file, )
} }
) )
@ -832,7 +822,6 @@ server <- function(input, output) {
}else{ }else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T) pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (input$operated == TRUE){ if (input$operated == TRUE){
table<-table %>% filter(DayPostInoc < firstoper) table<-table %>% filter(DayPostInoc < firstoper)
@ -890,7 +879,6 @@ server <- function(input, output) {
}else{ }else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T) pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (input$operated == TRUE){ if (input$operated == TRUE){
table<-table %>% filter(DayPostInoc < firstoper) table<-table %>% filter(DayPostInoc < firstoper)
@ -901,9 +889,7 @@ server <- function(input, output) {
table<-table %>% filter(!Animal %in% deadmice) table<-table %>% filter(!Animal %in% deadmice)
} }
} }
print("Table")
print(head(table))
g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=paste0(Animal,Side)))+ g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=paste0(Animal,Side)))+
scale_x_continuous(expand = expansion(mult = c(0,0.0)), scale_x_continuous(expand = expansion(mult = c(0,0.0)),
breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))), breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))),
@ -994,7 +980,6 @@ server <- function(input, output) {
}else{ }else{
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>% firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
pull(DayPostInoc) %>% min(na.rm = T) pull(DayPostInoc) %>% min(na.rm = T)
print(firstoper)
if (input$operated == TRUE){ if (input$operated == TRUE){
table<-table %>% filter(DayPostInoc < firstoper) table<-table %>% filter(DayPostInoc < firstoper)

Loading…
Cancel
Save