Commit 498d25a3e5245d2cbaa767c0d74807a65fd4c521
1 parent
2bf073a859
Exists in
master
For matching genes between two consolidated data files (UNTESTED)
Showing
1 changed file
with
62 additions
and
0 deletions
Show diff stats
RMatchGenes.R
... | ... | @@ -0,0 +1,62 @@ |
1 | +#Checking for similar genes in both data sets | |
2 | + | |
3 | +#Required libraries | |
4 | +library(MASS) | |
5 | +library(readr) | |
6 | +library(dplyr) | |
7 | + | |
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?: " %>% | |
12 | + readline(prompt = .) %>% | |
13 | + as.integer(.) | |
14 | + | |
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") | |
28 | + | |
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 | + | |
60 | +} | |
61 | + | |
62 | +Check2Match() |