Commit cb3deb0578045972ebb5540d8827f7516f0b3c4d

Authored by Efrain Gonzalez
1 parent fc0d5afa8a
Exists in master

Update that allows for more data set inputs at once

Showing 1 changed file with 55 additions and 48 deletions   Show diff stats
... ... @@ -6,57 +6,64 @@ library(readr)
6 6 library(dplyr)
7 7  
8 8 Check2Match <- function(){
9   -#Bring in the two files
10   -##Number of rows with clinical data for first file
11   -numrow1 <- "How many rows of clinical data are their in the first data set?: " %>%
  9 + numrows <- "How many rows of clinical data are their in the each data set?: " %>%
12 10 readline(prompt = .) %>%
  11 + strsplit(.,split = ",") %>%
  12 + .[[1]] %>%
13 13 as.integer(.)
  14 + i <- 1
  15 + ANDIS <- select.list(choices = list.files(),multiple = TRUE, title = "Choose the file/files you want to analyze:")
14 16  
15   -##Number of rows with clinical data for second file
16   -numrow2 <- "How many rows of clinical data are their in the second data set?: " %>%
17   - readline(prompt = .) %>%
18   - as.integer(.)
19   -
20   -edfile <- file.choose()
21   -ed <- edfile %>%
22   - read_delim(.,delim = "\t")
23   -
24   -ednocd <- ed[-(1:numrow1),]
25   -eddfile <- file.choose()
26   -edd <- eddfile %>%
27   - read_delim(.,delim = "\t")
  17 + for(i in 1:length(numrows)){
  18 + if( i == 1){
  19 + edfile <- ANDIS[i]
  20 + ed <- edfile %>%
  21 + read_delim(.,delim = "\t")
  22 + ednocd <- ed[-(1:numrows[1]),]
  23 + #Second file brought in
  24 + eddfile <- ANDIS[i + 1]
  25 + edd <- eddfile %>%
  26 + read_delim(.,delim = "\t")
  27 + eddnocd <- edd[-(1:numrows[2]),]
  28 +
  29 + ##Fully matched both data sets
  30 + eddy <- inner_join(ednocd,eddnocd)
  31 + #Matches
  32 + meds <- eddy[,1]
  33 +
  34 + }
  35 + if(i > 1 && i + 1 < length(numrows)){
  36 + eddfile <- ANDIS[i + 1]
  37 + edd <- eddfile %>%
  38 + read_delim(.,delim = "\t")
  39 + eddnocd <- edd[-(1:numrows[i + 1]),]
  40 + ##Fully matched both data sets
  41 + eddy <- inner_join(meds,eddnocd)
  42 + meds <- eddy[,1]
28 43  
29   -eddnocd <- edd[-(1:numrow2),]
30   -
31   -##Number of columns that belong to the first data file
32   -numbcol1 <- dim(ednocd)[2]
33   -##Number of columns that belong to the second data file
34   -numbcol2 <- dim(eddnocd)[2]
35   -
36   -##Fully matched both data sets
37   -eddy <- inner_join(ednocd,eddnocd)
38   -#Matched ed
39   -eddy[,1:numbcol1]
40   -Finedm <- rbind(ed[1:numrow1,],eddy[,1:numbcol1])
41   -nam_fil_ed <- strsplit(edfile,"[\\|/]") %>%
42   - .[[1]] %>%
43   - .[length(.)] %>%
44   - gsub("\\D","",.) %>%
45   - c("GSE",.,"matched.txt") %>%
46   - paste(collapse = "")
47   -write.table(Finedm,file = nam_fil_ed,sep = "\t",row.names = FALSE)
48   -#Matched edd
49   -eddy[,(numbcol1 + 1):dim(eddy)[2]]
50   -fineddm <- cbind(eddy[,1],eddy[,(numbcol1 + 1):dim(eddy)[2]])
51   -Fineddm <- rbind(edd[1:numrow2,],fineddm)
52   -nam_fil_edd <- strsplit(eddfile,"[\\|/]") %>%
53   - .[[1]] %>%
54   - .[length(.)] %>%
55   - gsub("\\D","",.) %>%
56   - c("GSE",.,"matched.txt") %>%
57   - paste(collapse = "")
58   -write.table(Fineddm,file = nam_fil_edd,sep = "\t",row.names = FALSE)
59   -
  44 +
  45 + }
  46 + i <- i + 1
  47 + }
  48 + meds
  49 + for(j in 1:length(numrows)){
  50 + edfile <- ANDIS[j]
  51 + ed <- edfile %>%
  52 + read_delim(.,delim = "\t")
  53 + ednocd <- ed[-(1:numrows[j]),]
  54 + #use meds to match
  55 + eddy <- inner_join(meds,ednocd)
  56 + Finedm <- rbind(ed[1:numrows[j],],eddy)
  57 + nam_fil_ed <- strsplit(edfile,"[\\|/]") %>%
  58 + .[[1]] %>%
  59 + .[length(.)] %>%
  60 + gsub("\\D","",.) %>%
  61 + c("GSE",.,"matched.txt") %>%
  62 + paste(collapse = "")
  63 + write.table(Finedm,file = nam_fil_ed,sep = "\t",row.names = FALSE)
  64 + j <- j + 1
  65 + }
  66 + meds
60 67 }
61 68  
62 69 -Check2Match()
  70 +Check2Match()
63 71 \ No newline at end of file