From 4675a21992fd0958b0aaa49e58ad4d803905e799 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Wed, 10 Apr 2019 23:20:17 -0500
Subject: [PATCH] Fix dir calls

---
 vizapp/server.R | 24 ++++++++++++------------
 vizapp/ui.R     |  8 ++++----
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/vizapp/server.R b/vizapp/server.R
index 0221b88..679b1d2 100644
--- a/vizapp/server.R
+++ b/vizapp/server.R
@@ -68,11 +68,11 @@ shinyServer(
               if(!file.exists(paste0(data.dir,"Expression/out_genes/",gene,"/",i,".txt"))){
                 cat("File not present\n")
                 if(!dir.exists(paste0(data.dir,"Expression/out_genes/",gene))){
-                  system(paste0("mkdir ../output/Expression/out_genes/",gene))
+                  system(paste0("mkdir ",data.dir,"Expression/out_genes/",gene))
                   cat("Made directory\n")
                 }
-                system(paste0("ls ../output/Expression/*",i,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ../output/Expression/out_genes/",
-                              gene,"/","$fname; grep -wi ",gene," $line >> ../output/Expression/out_genes/",gene,"/","$fname;done"))
+                system(paste0("ls ",data.dir,"Expression/*",i,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ",data.dir,"Expression/out_genes/",
+                              gene,"/","$fname; grep -wi ",gene," $line >> ",data.dir,"Expression/out_genes/",gene,"/","$fname;done"))
                 cat("creating data\n")
                 
               }
@@ -129,11 +129,11 @@ shinyServer(
             if(!file.exists(paste0(data.dir,"Expression/out_genes/",gene,"/",cancer,".txt"))){
               cat("File not present\n")
               if(!dir.exists(paste0(data.dir,"Expression/out_genes/",gene))){
-                system(paste0("mkdir ../output/Expression/out_genes/",gene))
+                system(paste0("mkdir ",data.dir,"Expression/out_genes/",gene))
                 cat("Made directory\n")
               }
-              system(paste0("ls ../output/Expression/*",cancer,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ../output/Expression/out_genes/",
-                            gene,"/","$fname; grep -wi ",gene," $line >> ../output/Expression/out_genes/",gene,"/","$fname;done"))
+              system(paste0("ls ",data.dir,"Expression/*",cancer,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ",data.dir,"Expression/out_genes/",
+                            gene,"/","$fname; grep -wi ",gene," $line >> ",data.dir,"Expression/out_genes/",gene,"/","$fname;done"))
               cat("creating data\n")
               
             }
@@ -295,11 +295,11 @@ shinyServer(
             if(!file.exists(paste0(data.dir,"Expression/out_genes/",gene,"/",i,".txt"))){
               cat("File not present\n")
               if(!dir.exists(paste0(data.dir,"Expression/out_genes/",gene))){
-                system(paste0("mkdir ../output/Expression/out_genes/",gene))
+                system(paste0("mkdir ",data.dir,"Expression/out_genes/",gene))
                 cat("Made directory\n")
               }
-              system(paste0("ls ../output/Expression/*",i,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ../output/Expression/out_genes/",
-                            gene,"/","$fname; grep -wi ",gene," $line >> ../output/Expression/out_genes/",gene,"/","$fname;done"))
+              system(paste0("ls ",data.dir,"Expression/*",i,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ",data.dir,"Expression/out_genes/",
+                            gene,"/","$fname; grep -wi ",gene," $line >> ",data.dir,"Expression/out_genes/",gene,"/","$fname;done"))
               cat("creating data\n")
               
             }
@@ -356,11 +356,11 @@ shinyServer(
           if(!file.exists(paste0(data.dir,"Expression/out_genes/",gene,"/",cancer,".txt"))){
             cat("File not present\n")
             if(!dir.exists(paste0(data.dir,"Expression/out_genes/",gene))){
-              system(paste0("mkdir ../output/Expression/out_genes/",gene))
+              system(paste0("mkdir ",data.dir,"Expression/out_genes/",gene))
               cat("Made directory\n")
             }
-            system(paste0("ls ../output/Expression/*",cancer,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ../output/Expression/out_genes/",
-                          gene,"/","$fname; grep -wi ",gene," $line >> ../output/Expression/out_genes/",gene,"/","$fname;done"))
+            system(paste0("ls ",data.dir,"Expression/*",cancer,"*txt | while read line ; do fname=$(basename $line); head -1 $line > ",data.dir,"Expression/out_genes/",
+                          gene,"/","$fname; grep -wi ",gene," $line >> ",data.dir,"Expression/out_genes/",gene,"/","$fname;done"))
             cat("creating data\n")
             
           }
diff --git a/vizapp/ui.R b/vizapp/ui.R
index 93fb612..0c0bc78 100644
--- a/vizapp/ui.R
+++ b/vizapp/ui.R
@@ -6,15 +6,15 @@ shinyUI(
         selectInput("operation","Select Plot Type",choices = c("Boxplot","Survival")),
         conditionalPanel(condition = "input.operation=='Boxplot'",
                          selectInput("cancerType","Select one or more cancer types",
-                                     choices = substr(list.files(data.dir,"Expression/",pattern=".txt"),1,
-                                                      nchar(list.files(data.dir,"Expression/",pattern=".txt"))-4),
+                                     choices = substr(list.files(paste0(data.dir,"Expression/"),pattern=".txt"),1,
+                                                      nchar(list.files(paste0(data.dir,"Expression/"),pattern=".txt"))-4),
                                      multiple = TRUE),
                          textInput("gene","Please input one gene of interest",placeholder = "Gene name ie TRIM21")
         ),
         conditionalPanel(condition="input.operation=='Survival'",
                          selectInput("cancerType2","Select a cancer type",
-                                     choices = substr(list.files(data.dir,"Expression/",pattern=".txt"),1,
-                                                      nchar(list.files(data.dir,"Expression/",pattern=".txt"))-4)),
+                                     choices = substr(list.files(paste0(data.dir,"Expression/"),pattern=".txt"),1,
+                                                      nchar(list.files(paste0(data.dir,"Expression/)",pattern=".txt"))-4)),
                          textInput("gene2","Please input one gene of interest",placeholder = "Gene name ie BRCA1"),
                          selectInput("operation2","Select automatic or manual cutoff", choices = c("Automatic", "Manual"))
                          
-- 
GitLab