Compare commits
6 Commits
8539caa993
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0887ab933a | |||
| a3eaf3e7a9 | |||
| 1237794f62 | |||
| bbf19befaf | |||
| 3a9907c480 | |||
| cda5d7f881 |
+29
-29
@@ -121,12 +121,17 @@ server <- function(input, output) {
|
|||||||
}
|
}
|
||||||
table$Date<-format(table$Date, format="%d/%m/%Y")
|
table$Date<-format(table$Date, format="%d/%m/%Y")
|
||||||
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
||||||
|
if ("Abs" %in% colnames(table)){
|
||||||
|
table<-rename(table, "Volume"="Abs")
|
||||||
|
}else{
|
||||||
for (i in 1:nrow(table)){
|
for (i in 1:nrow(table)){
|
||||||
long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]]))
|
long<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Long"]),"+", fixed = T)[[1]]))
|
||||||
wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]]))
|
wide<-as.numeric(gsub(",",".",strsplit(as.character(table[i,"Wide"]),"+", fixed = T)[[1]]))
|
||||||
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
||||||
}
|
}
|
||||||
table$Volume<-as.numeric(table$Volume)
|
table$Volume<-as.numeric(table$Volume)
|
||||||
|
}
|
||||||
|
|
||||||
if ("Cage" %in% colnames(table)){
|
if ("Cage" %in% colnames(table)){
|
||||||
table$Animal<-paste0(table$Cage, table$Animal)
|
table$Animal<-paste0(table$Cage, table$Animal)
|
||||||
table<-table[,-which(colnames(table) == "Cage")]
|
table<-table[,-which(colnames(table) == "Cage")]
|
||||||
@@ -193,8 +198,8 @@ 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),]
|
||||||
|
print(df)
|
||||||
up_cuttof<-input$upcut
|
up_cuttof<-input$upcut
|
||||||
low_cuttof<-input$lowcut
|
low_cuttof<-input$lowcut
|
||||||
|
|
||||||
@@ -223,7 +228,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 +248,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")
|
||||||
}
|
}
|
||||||
@@ -330,12 +332,15 @@ server <- function(input, output) {
|
|||||||
# 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)){
|
||||||
template<-dades$db %>% filter(!is.na(Group)) %>%
|
template<-dades$db %>%
|
||||||
select(Animal, Group) %>% unique()
|
select(Animal, Group) %>% unique()
|
||||||
dtemplate<-merge(dades$taula %>% select(-Group), template) %>%
|
dtemplate<-merge(dades$taula %>% select(-Group), template) %>%
|
||||||
arrange(DayPostInoc, Animal, Side) %>%
|
arrange(DayPostInoc, Animal, Side) %>%
|
||||||
select(Animal, Date, DayPostInoc, Group, Side,
|
select(Animal, Date, DayPostInoc, Group, Side,
|
||||||
Weight, Long, Wide, Volume, Observations)
|
Weight, Long, Wide, Volume, Observations)
|
||||||
|
if ("Abs" %in% colnames(read.xlsx(input$file_sizes$datapath, sheet = 1, check.names = F, sep.names = " ", detectDates = T,cols=1:11))){
|
||||||
|
dtemplate<-rename(dtemplate, "Abs"="Volume")
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
template<-data.frame(
|
template<-data.frame(
|
||||||
@@ -407,11 +412,24 @@ 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))
|
||||||
print(str(table))
|
|
||||||
|
|
||||||
|
if (input$increase_volume){
|
||||||
|
cols<-colnames(table)
|
||||||
|
timepoints<-unique(table$DayPostInoc)
|
||||||
|
table_old<-select(table, -Volume)
|
||||||
|
table_vols<-table %>%
|
||||||
|
select(-Weight, -Date, -Long, -Wide,-Observations) %>%
|
||||||
|
spread(DayPostInoc, Volume) %>%
|
||||||
|
mutate(across(all_of(as.character(timepoints)), function(x){(x*100/`0`)-100})) %>%
|
||||||
|
gather(DayPostInoc, Volume, all_of(as.character(timepoints))) %>%
|
||||||
|
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume))
|
||||||
|
table<-merge(table_old, table_vols)[,cols]
|
||||||
|
}
|
||||||
|
|
||||||
analysis$taula<-table
|
analysis$taula<-table
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -419,7 +437,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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -431,14 +448,6 @@ server <- function(input, output) {
|
|||||||
|
|
||||||
table<-analysis$taula
|
table<-analysis$taula
|
||||||
table<-table %>% filter(!is.na(Group))
|
table<-table %>% filter(!is.na(Group))
|
||||||
if (input$increase_volume){
|
|
||||||
timepoints<-unique(table$Timepoint)
|
|
||||||
table<-table %>% select(-Major, -Minor) %>%
|
|
||||||
spread(Timepoint, Volume) %>%
|
|
||||||
mutate(across(all_of(timepoints), function(x){(x*100/`0`)-100})) %>%
|
|
||||||
gather(Timepoint, Volume, -`ID animal`, -`ID tumor`, -Group) %>%
|
|
||||||
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume))
|
|
||||||
}
|
|
||||||
table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n)
|
table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -448,7 +457,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)
|
||||||
@@ -474,7 +482,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])
|
||||||
@@ -646,9 +654,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) == "+") %>%
|
||||||
@@ -688,8 +696,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)))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -749,7 +755,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, )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -826,7 +831,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)
|
||||||
@@ -884,7 +888,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)
|
||||||
@@ -895,8 +898,6 @@ 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)),
|
||||||
@@ -988,7 +989,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)
|
||||||
|
|||||||
Reference in New Issue
Block a user