Compare commits

..

8 Commits

2 changed files with 26 additions and 23 deletions
+24 -21
View File
@@ -144,37 +144,31 @@ server <- function(input, output) {
print(CCfile) print(CCfile)
if (input$dbtype == "UM"){ if (input$dbtype == "UM"){
dta<<-odbcConnectAccess2007(access.file = UMfile, dta<<-odbcConnectAccess2007(access.file = UMfile,
pwd = .rs.askForPassword("Enter password:")) pwd = getPass::getPass("Enter password:"))
} }
if (input$dbtype == "OV"){ if (input$dbtype == "OV"){
dta<<-odbcConnectAccess2007(access.file = OVfile, dta<<-odbcConnectAccess2007(access.file = OVfile,
pwd = .rs.askForPassword("Enter password:")) pwd = getPass::getPass("Enter password:"))
} }
if (input$dbtype == "CC"){ if (input$dbtype == "CC"){
dta<<-odbcConnectAccess2007(access.file = CCfile, dta<<-odbcConnectAccess2007(access.file = CCfile,
pwd = .rs.askForPassword("Enter password:")) pwd = getPass::getPass("Enter password:"))
} }
print(dta) print(dta)
if (input$backup == T){ if (input$backup == T){
if (! input$dbtype %in% c("UM","OV")){ if (! input$dbtype %in% c("UM","OV")){
sqlBackUp(bu.dir="CC_BU") sqlBackUp(dbfile = CCfile, bu.dir="CC_BU")
}else{
sqlBackUp()
} }
if (input$dbtype == "UM"){
sqlBackUp(dbfile = UMfile)
}
if (input$dbtype == "OV"){
sqlBackUp(dbfile = OVfile)
}
print("Back up realizado.")
} }
}) })
# observe({
# if (!is.null(input$file_access)){
# # Inicializar conexión
# dta<<-odbcConnectAccess2007(access.file = file,
# pwd = .rs.askForPassword("Enter password:"))
# print(dta)
# sqlBackUp()
# }
# })
observe({ observe({
if (!is.null(input$file_query)){ if (!is.null(input$file_query)){
## Importamos los NHC de las muestras nuevas ## Importamos los NHC de las muestras nuevas
@@ -380,7 +374,7 @@ server <- function(input, output) {
new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID", as.is=T), all.x=T) %>% arrange(samples) new.samp.df<-data.frame("NHC"=values[["DF"]]$NHC, "samples"=new.samp) %>% merge(sqlFetch(dta,"OVID", as.is=T), all.x=T) %>% arrange(samples)
samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(samples) samples.exp<-merge(samples %>% slice(0), new.samp.df %>% select(-NHC), all=T) %>% select(colnames(samples)) %>% arrange(samples)
if (today==TRUE){ if (today==TRUE){
samples.exp$IQ_date<-format(Sys.Date(), "%d/%m/%y") samples.exp$Date_extraction<-format(Sys.Date(), "%d/%m/%y")
} }
nhc.table<-values[["DF"]] nhc.table<-values[["DF"]]
@@ -754,6 +748,7 @@ server <- function(input, output) {
sqlFetch(dta, "NITROGEN"), sqlFetch(dta, "NITROGEN"),
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","UM-Nitrogen.xlsx") file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","UM-Nitrogen.xlsx")
) )
print("Backup Creado.")
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx")) table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
@@ -784,6 +779,7 @@ server <- function(input, output) {
sqlDrop(dta, "NITROGEN") sqlDrop(dta, "NITROGEN")
sqlSave(dta, table.um %>% select(-FECHA) %>% filter(!is.na(CODIGO)), tablename="NITROGEN", rownames=F) sqlSave(dta, table.um %>% select(-FECHA) %>% filter(!is.na(CODIGO)), tablename="NITROGEN", rownames=F)
print("Tabla Actualizada.")
} }
if (input$dbtype == "OV"){ if (input$dbtype == "OV"){
## Copia de backup ## Copia de backup
@@ -797,6 +793,7 @@ server <- function(input, output) {
sqlFetch(dta, "NITROGEN"), sqlFetch(dta, "NITROGEN"),
file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","OV-Nitrogen.xlsx") file=paste0(NitroRoute, format(Sys.time(), format="%Y%m%d"),"-","OV-Nitrogen.xlsx")
) )
print("Backup Creado.")
## Lectura del excel ## Lectura del excel
table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx")) table<-read.xlsx(paste0(gsub("/BU_NITRO/", "", NitroRoute),"/Nitrogen_ICO.xlsx"))
@@ -822,6 +819,7 @@ server <- function(input, output) {
sqlDrop(dta, "NITROGEN") sqlDrop(dta, "NITROGEN")
sqlSave(dta, table.ov, tablename="NITROGEN", rownames=F) sqlSave(dta, table.ov, tablename="NITROGEN", rownames=F)
print("Tabla Actualizada.")
} }
}) })
@@ -924,9 +922,14 @@ server <- function(input, output) {
pops<-sqlFetch(dta, "POPULATIONS") pops<-sqlFetch(dta, "POPULATIONS")
g_pop<-pops %>% dplyr::filter(samples == input$id) %>% gather(pop,value,-samples) %>% g_pop<-pops %>%
mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells", dplyr::filter(sample == input$id) %>%
"CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>% gather(pop,value,-sample, -code, -fc_time) %>%
# mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells",
# "CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>%
# mutate(pop=factor(pop, levels=c("CD45pos_Alive","T_cells","CD8","CD4","DN","NK", "B_cells",
# "CD45neg_LDneg","EpCAMneg_HLAIneg","EpCAMneg_HLAIpos","EpCAMpos_HLAIpos"))) %>%
mutate(value=as.numeric(gsub(",",".",value))) %>%
ggplot(aes(pop, value))+ ggplot(aes(pop, value))+
geom_bar(stat="identity", color="black", fill="grey70")+ geom_bar(stat="identity", color="black", fill="grey70")+
labs(title = input$id, y="% parent", x="")+ labs(title = input$id, y="% parent", x="")+
+1 -1
View File
@@ -82,7 +82,7 @@ sqlGenOVID<-function(conn=dta, nhcs=nhc.test, verb=T, sinc=F, dbtype=NULL){
if(length(new.nhc) > 0){ if(length(new.nhc) > 0){
if (nrow(dbid) == 0){next.num<-1}else{ if (nrow(dbid) == 0){next.num<-1}else{
next.num<-gsub(db["dbcode"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1 next.num<-gsub(db["dbpref"],"",dbid[,db["dbcode"]]) %>% as.numeric %>% max(na.rm=T)+1
} }
print(next.num) print(next.num)
last.num<-next.num+(length(new.nhc)-1) last.num<-next.num+(length(new.nhc)-1)