Compare commits
16 Commits
9f0cda73eb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0887ab933a | |||
| a3eaf3e7a9 | |||
| 1237794f62 | |||
| bbf19befaf | |||
| 3a9907c480 | |||
| cda5d7f881 | |||
| 8539caa993 | |||
| 7783dc6c4b | |||
| fe865f55e4 | |||
| b01f7bb11d | |||
| 459a8001fe | |||
| 455901a1db | |||
| 43776f80cb | |||
| d9a5689c99 | |||
| 092a788125 | |||
| 80362a28db |
+75
-56
@@ -121,12 +121,22 @@ server <- function(input, output) {
|
||||
}
|
||||
table$Date<-format(table$Date, format="%d/%m/%Y")
|
||||
if ("sex" %in% colnames(table)){table<-select(table, -sex)}
|
||||
for (i in 1:nrow(table)){
|
||||
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]]))
|
||||
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
||||
if ("Abs" %in% colnames(table)){
|
||||
table<-rename(table, "Volume"="Abs")
|
||||
}else{
|
||||
for (i in 1:nrow(table)){
|
||||
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]]))
|
||||
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)){
|
||||
table$Animal<-paste0(table$Cage, table$Animal)
|
||||
table<-table[,-which(colnames(table) == "Cage")]
|
||||
}
|
||||
|
||||
dades$taula<-table
|
||||
dades$groups<-read.xlsx(input$file_sizes$datapath, sheet = "Groups", colNames=F)[,1]
|
||||
if (readxl::excel_sheets(input$file_sizes$datapath) %>% length > 2){
|
||||
@@ -188,8 +198,8 @@ server <- function(input, output) {
|
||||
|
||||
grafic<-eventReactive(input$goButton,{
|
||||
df<-dades$taula %>% filter(DayPostInoc == input$day_vol)
|
||||
print(df)
|
||||
df<-df[!is.na(df$Volume),]
|
||||
print(df)
|
||||
up_cuttof<-input$upcut
|
||||
low_cuttof<-input$lowcut
|
||||
|
||||
@@ -218,7 +228,6 @@ server <- function(input, output) {
|
||||
while(interr == T){
|
||||
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))
|
||||
print(df_sex)
|
||||
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))
|
||||
}else{
|
||||
@@ -239,20 +248,21 @@ 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]
|
||||
# print(df_sex)
|
||||
df_def[[sex.var]]<-merge(df_sex %>% select(-group), ind.list[[index]])
|
||||
}
|
||||
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)){
|
||||
df_def<-df_def %>% select(-"Group")
|
||||
}
|
||||
|
||||
df_def<-merge(
|
||||
if(!is.null(dades$sex)){merge(dades$taula %>% filter(DayPostInoc == input$day_vol), dades$sex)}else{
|
||||
if(!is.null(dades$sex)){merge(dades$taula %>% filter(DayPostInoc == input$day_vol), dades$sex)%>% select(-Group)}else{
|
||||
dades$taula %>% filter(DayPostInoc == input$day_vol) %>% add_column(sex="undefined")} %>% select(-Group),
|
||||
df_def[,c("Animal", "group")] %>% unique, all=T, by="Animal") %>% rename(Group=group)
|
||||
df_def<-select(df_def, Cage, Animal, Date, DayPostInoc, Group, Side, Weight, Long, Wide, Volume, Observations)
|
||||
df_def[,c("Animal", "group")] %>% unique, all=T, by="Animal")
|
||||
df_def<-df_def %>% rename(Group=group)
|
||||
|
||||
df_def<-select(df_def, Animal, sex, Date, DayPostInoc, Group, Side, Weight, Long, Wide, Volume, Observations)
|
||||
# if("DPV" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, Major, Minor, group))}
|
||||
# if("TS-Deep" %in% colnames(df_def)){df_def<-select(df_def, c(`ID animal`, `sex`,`ID tumor`, Volume, Cage, `TS-Deep`,`TS-Length`,`TS-Width`, group))}
|
||||
|
||||
@@ -322,12 +332,15 @@ server <- function(input, output) {
|
||||
# timepoint<-c(7,10,13,16,19,22,25)
|
||||
|
||||
if (!is.null(input$file_sizes)){
|
||||
template<-dades$db %>% filter(!is.na(Group)) %>%
|
||||
template<-dades$db %>%
|
||||
select(Animal, Group) %>% unique()
|
||||
dtemplate<-merge(dades$taula %>% select(-Group), template) %>%
|
||||
arrange(DayPostInoc, Animal, Side) %>%
|
||||
select(Cage, Animal, Date, DayPostInoc, Group, Side,
|
||||
select(Animal, Date, DayPostInoc, Group, Side,
|
||||
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{
|
||||
|
||||
template<-data.frame(
|
||||
@@ -343,6 +356,7 @@ server <- function(input, output) {
|
||||
Volume="",
|
||||
Observations=""
|
||||
)
|
||||
template<-template %>% mutate(Animal=paste0(Cage,Animal)) %>% select(-Cage)
|
||||
dtemplate<-template
|
||||
}
|
||||
write.xlsx(list("Measures"=dtemplate, "Groups"=NULL,"Sex"=NULL), file)
|
||||
@@ -379,6 +393,10 @@ server <- function(input, output) {
|
||||
table[i,"Volume"]<-sum(sapply(1:length(long), function(x) (long[x]*wide[x]*wide[x])*(pi/6)))
|
||||
}
|
||||
table$Volume<-as.numeric(table$Volume)
|
||||
if ("Cage" %in% colnames(table)){
|
||||
table$Animal<-paste0(table$Cage, table$Animal)
|
||||
table<-table[,-which(colnames(table) == "Cage")]
|
||||
}
|
||||
|
||||
## Autocompletado de grupo
|
||||
table_group<-merge(
|
||||
@@ -390,16 +408,28 @@ server <- function(input, output) {
|
||||
table %>% select(-Group),
|
||||
table_group
|
||||
) %>% relocate(Group, .after = DayPostInoc) %>%
|
||||
relocate(Cage, .before = Animal) %>%
|
||||
arrange(DayPostInoc, Animal, Side)
|
||||
|
||||
if("Groups" %in% readxl::excel_sheets(input$file_analy$datapath)){
|
||||
levels<-read.xlsx(input$file_analy$datapath, sheet = "Groups", colNames=F)[,1]
|
||||
print(levels)
|
||||
table$Group<-factor(table$Group, levels=levels)
|
||||
table<-filter(table, !is.na(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
|
||||
}
|
||||
})
|
||||
@@ -407,7 +437,6 @@ server <- function(input, output) {
|
||||
if (!is.null(analysis$taula)){
|
||||
observeEvent(analysis$taula, {})
|
||||
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)
|
||||
}
|
||||
})
|
||||
@@ -419,17 +448,10 @@ server <- function(input, output) {
|
||||
|
||||
table<-analysis$taula
|
||||
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, -Cage, -`ID animal`, -`ID tumor`, -Group) %>%
|
||||
mutate(Volume=case_when(Volume < 0 ~ 0, T~Volume))
|
||||
}
|
||||
table %>% group_by(Group, DayPostInoc, Side) %>% count() %>% spread(DayPostInoc, n)
|
||||
}
|
||||
})
|
||||
|
||||
output$cin_group<-renderPlot({
|
||||
if (!is.null(input$file_analy) & !is.null(analysis$taula)){
|
||||
observeEvent(analysis$taula, {})
|
||||
@@ -439,7 +461,6 @@ server <- function(input, output) {
|
||||
sides<-unique(table$Side)
|
||||
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||
basal<-data.frame(
|
||||
Cage="",
|
||||
Animal=rep(animals, each=length(sides)),
|
||||
Date="",
|
||||
DayPostInoc=0,
|
||||
@@ -451,7 +472,9 @@ server <- function(input, output) {
|
||||
Volume=0,
|
||||
Observations=""
|
||||
)
|
||||
table<-rbind(table, basal)
|
||||
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||
table<-rbind(table, basal)
|
||||
}
|
||||
|
||||
if (input$vacc == "Sí"){
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
@@ -459,8 +482,8 @@ server <- function(input, output) {
|
||||
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||
pull(Animal)
|
||||
print(deadmice)
|
||||
if (input$operated == TRUE){
|
||||
|
||||
if (input$operated == TRUE & nrow(firstoper) > 0){
|
||||
for (i in 1:nrow(firstoper)){
|
||||
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||
}
|
||||
@@ -483,9 +506,9 @@ server <- function(input, output) {
|
||||
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
if (firstoper == Inf){firstoper<-c()}
|
||||
|
||||
if (input$operated == TRUE){
|
||||
if (input$operated == TRUE & length(firstoper) > 0){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
}else{
|
||||
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||
@@ -516,7 +539,6 @@ server <- function(input, output) {
|
||||
sides<-unique(table$Side)
|
||||
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||
basal<-data.frame(
|
||||
Cage="",
|
||||
Animal=rep(animals, each=length(sides)),
|
||||
Date="",
|
||||
DayPostInoc=0,
|
||||
@@ -528,13 +550,15 @@ server <- function(input, output) {
|
||||
Volume=0,
|
||||
Observations=""
|
||||
)
|
||||
table<-rbind(table, basal)
|
||||
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||
table<-rbind(table, basal)
|
||||
}
|
||||
|
||||
if (input$vacc == "Sí"){
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
select(DayPostInoc, Side) %>% unique() %>%
|
||||
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||
if (input$operated == TRUE){
|
||||
if (input$operated == TRUE & nrow(firstoper) > 0){
|
||||
for (i in 1:nrow(firstoper)){
|
||||
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||
}
|
||||
@@ -557,9 +581,9 @@ server <- function(input, output) {
|
||||
}else{
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
if (firstoper == Inf){firstoper<-c()}
|
||||
|
||||
if (input$operated == TRUE){
|
||||
if (input$operated == TRUE & length(firstoper) > 0){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
}else{
|
||||
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||
@@ -589,8 +613,9 @@ server <- function(input, output) {
|
||||
if (input$vacc == "Sí"){
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
select(DayPostInoc, Side) %>% unique() %>%
|
||||
group_by(Side) %>% summarise(FirstOper=min(DayPostInoc))
|
||||
if (input$operated == TRUE){
|
||||
if (firstoper == Inf){firstoper<-c()}
|
||||
|
||||
if (input$operated == TRUE & length(firstoper) > 0){
|
||||
for (i in 1:nrow(firstoper)){
|
||||
table<-table %>% filter(DayPostInoc < firstoper$FirstOper[i] | Side != firstoper$Side[i])
|
||||
}
|
||||
@@ -604,8 +629,8 @@ server <- function(input, output) {
|
||||
g<-list()
|
||||
for (side in c("L","R")){
|
||||
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
|
||||
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), Cage+Animal+Side+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
|
||||
endtime["Dead"]<-dcast(tableR, Cage+Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
|
||||
endtime<-dcast(tableR %>% filter(Volume < input$cutoff), Animal+Side+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
|
||||
endtime["Dead"]<-dcast(tableR, Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > input$cutoff
|
||||
table_tumor<<-endtime
|
||||
|
||||
g[side]<-ggsurvplot(survfit(Surv(end, Dead) ~ Group, data=table_tumor),
|
||||
@@ -629,9 +654,9 @@ server <- function(input, output) {
|
||||
}else{
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
if (firstoper == Inf){firstoper<-c()}
|
||||
|
||||
if (input$operated == TRUE){
|
||||
if (input$operated == TRUE & length(firstoper) > 0){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
}else{
|
||||
deadmice<-filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "+") %>%
|
||||
@@ -671,9 +696,6 @@ server <- function(input, output) {
|
||||
for (side in c("L","R")){
|
||||
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
|
||||
if (length(unique(tableR$Volume)) > 1 & length(unique(tableR$DayPostInoc)) > 1){
|
||||
print(paste0("Side: ",side))
|
||||
# print(summary(aov(Volume~Group+DayPostInoc+Error(paste0(Animal,Cage)), data=tableR)))
|
||||
print(summary(aov(Volume~Group+DayPostInoc+Error(Animal), data=tableR)))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,7 +755,6 @@ server <- function(input, output) {
|
||||
},
|
||||
content = function(file){
|
||||
dtemplate<-analysis$taula
|
||||
# print(str(dtemplate))
|
||||
write.xlsx(dtemplate,file, )
|
||||
}
|
||||
)
|
||||
@@ -757,7 +778,6 @@ server <- function(input, output) {
|
||||
sides<-unique(table$Side)
|
||||
groups<-table %>% select(Animal, Group) %>% unique() %>% pull(Group)
|
||||
basal<-data.frame(
|
||||
Cage="",
|
||||
Animal=rep(animals, each=length(sides)),
|
||||
Date="",
|
||||
DayPostInoc=0,
|
||||
@@ -769,7 +789,9 @@ server <- function(input, output) {
|
||||
Volume=0,
|
||||
Observations=""
|
||||
)
|
||||
table<-rbind(table, basal)
|
||||
if (!(0 %in% table$DayPostInoc) | sum(table[table$DayPostInoc == 0,"Volume"],na.rm = T) == 0){
|
||||
table<-rbind(table, basal)
|
||||
}
|
||||
if (input$fig_id %in% c("Cinética Grupo", "Cinética Individual")){
|
||||
if (input$fig_id == "Cinética Grupo"){
|
||||
if (input$vacc == "Sí"){
|
||||
@@ -809,7 +831,6 @@ server <- function(input, output) {
|
||||
}else{
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
|
||||
if (input$operated == TRUE){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
@@ -867,7 +888,6 @@ server <- function(input, output) {
|
||||
}else{
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
|
||||
if (input$operated == TRUE){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
@@ -879,7 +899,7 @@ server <- function(input, output) {
|
||||
}
|
||||
}
|
||||
|
||||
g<-ggplot(table, aes(as.numeric(as.character(DayPostInoc)), Volume, color=Group, group=Animal))+
|
||||
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)),
|
||||
breaks=sort(unique(as.numeric(as.character(table$DayPostInoc)))),
|
||||
limits = c(0,max(as.numeric(as.character(table$DayPostInoc)))*1.1))+
|
||||
@@ -947,8 +967,8 @@ server <- function(input, output) {
|
||||
count<-1
|
||||
for (side in c("L","R")){
|
||||
tableR<-filter(table, Side == side) %>% filter(!is.na(Volume))
|
||||
endtime<-dcast(tableR %>% filter(Volume < (input$cutoff*as.numeric(input$unit_fact))), Cage+Animal+Side+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
|
||||
endtime["Dead"]<-dcast(tableR, Cage+Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > (input$cutoff*as.numeric(input$unit_fact))
|
||||
endtime<-dcast(tableR %>% filter(Volume < (input$cutoff*as.numeric(input$unit_fact))), Animal+Side+Group~., value.var = "DayPostInoc", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% rename("end"=".")
|
||||
endtime["Dead"]<-dcast(tableR, Animal+Side+Group~., value.var = "Volume", fun.aggregate = function(x){max(as.numeric(as.character(x)))}) %>% pull(".") > (input$cutoff*as.numeric(input$unit_fact))
|
||||
table_tumor<-endtime
|
||||
if (input$colors != ""){
|
||||
col<-strsplit(input$colors, ",")[[1]]
|
||||
@@ -969,7 +989,6 @@ server <- function(input, output) {
|
||||
}else{
|
||||
firstoper<- filter(table, !is.na(substr(Observations,1,1)) & substr(Observations,1,1) == "*") %>%
|
||||
pull(DayPostInoc) %>% min(na.rm = T)
|
||||
print(firstoper)
|
||||
|
||||
if (input$operated == TRUE){
|
||||
table<-table %>% filter(DayPostInoc < firstoper)
|
||||
|
||||
Reference in New Issue
Block a user