Commit 6a66705877a70dd83cb8cff53f5b52f447b4dc76
1 parent
769f081f9b
Exists in
master
Don't use this code yet
updated else if statements
Showing
1 changed file
with
20 additions
and
38 deletions
Show diff stats
RAutoClDs.R
... | ... | @@ -27,11 +27,9 @@ chngrownm <- function(mat){ |
27 | 27 | for(e in 1:col){ |
28 | 28 | if("!Sample_source_name_ch1"==mat[1,e]){ |
29 | 29 | colnames(mat)[e] <- "Brain_Region" |
30 | - } | |
31 | - else if("!Sample_title" == mat[1,e]){ | |
30 | + } else if("!Sample_title" == mat[1,e]){ | |
32 | 31 | colnames(mat)[e] <- "Title" |
33 | - } | |
34 | - else if("!Sample_geo_accession" == mat[1,e]){ | |
32 | + } else if("!Sample_geo_accession" == mat[1,e]){ | |
35 | 33 | colnames(mat)[e] <- "ID_REF" |
36 | 34 | } else{ |
37 | 35 | if(grepl("Sex|gender|Gender|sex",mat[2,e])==TRUE){ |
... | ... | @@ -68,19 +66,15 @@ cinfo <- function(mat){ |
68 | 66 | for(j in 2:col){ |
69 | 67 | if(grepl("Group",colnames(mat)[j]) == TRUE){ |
70 | 68 | mat[,j] <- gsub(".+:\\s|\\s.+;.+","",mat[,j]) |
71 | - } | |
72 | - else if(grepl("Age",colnames(mat)[j])==TRUE){ | |
69 | + } else if(grepl("Age",colnames(mat)[j])==TRUE){ | |
73 | 70 | mat[,j] <- gsub("\\D","",mat[,j])%>% |
74 | 71 | as.integer() |
75 | - } | |
76 | - else if(grepl("Sex",colnames(mat)[j])==TRUE){ | |
72 | + } else if(grepl("Sex",colnames(mat)[j])==TRUE){ | |
77 | 73 | mat[,j] <- gsub(".+:\\s","",mat[,j]) |
78 | - } | |
79 | - else if(grepl("PMI",colnames(mat)[j])==TRUE){ | |
74 | + } else if(grepl("PMI",colnames(mat)[j])==TRUE){ | |
80 | 75 | mat[,j] <- gsub("[^0-9\\.]","",mat[,j])%>% |
81 | 76 | as.numeric() |
82 | - } | |
83 | - else if(grepl("Braak",colnames(mat)[j])==TRUE){ | |
77 | + } else if(grepl("Braak",colnames(mat)[j])==TRUE){ | |
84 | 78 | mat[,j]<-gsub(".+:\\s","",mat[,j])%>% |
85 | 79 | as.roman()%>% |
86 | 80 | as.integer() |
... | ... | @@ -168,11 +162,9 @@ dndat <- function(NDATA){ |
168 | 162 | |
169 | 163 | if(NDATA[i,j] < -1){ |
170 | 164 | DDATA[i,j]=0L |
171 | - } | |
172 | - else if(NDATA[i,j] > 1){ | |
165 | + } else if(NDATA[i,j] > 1){ | |
173 | 166 | DDATA[i,j]=2L |
174 | - } | |
175 | - else if(-1 <= NDATA[i,j] && NDATA[i,j] < 1){ | |
167 | + } else if(-1 <= NDATA[i,j] && NDATA[i,j] < 1){ | |
176 | 168 | DDATA[i,j]=1L |
177 | 169 | } |
178 | 170 | } else{ |
... | ... | @@ -276,8 +268,7 @@ THEFT <- function(){ |
276 | 268 | geneIDNam <- genena %>% |
277 | 269 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idlocgpl) %>% |
278 | 270 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
279 | - } | |
280 | - else if(IDF == 0){ | |
271 | + } else if(IDF == 0){ | |
281 | 272 | #No information on this particular GPL file |
282 | 273 | idLOCGPL <- genena %>% |
283 | 274 | read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% |
... | ... | @@ -290,8 +281,7 @@ THEFT <- function(){ |
290 | 281 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% |
291 | 282 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
292 | 283 | } |
293 | - } | |
294 | - else if(fileex == 0){ | |
284 | + } else if(fileex == 0){ | |
295 | 285 | #We must create a file that we can access for later use |
296 | 286 | idLOCGPL <- genena %>% |
297 | 287 | read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% |
... | ... | @@ -305,8 +295,7 @@ THEFT <- function(){ |
305 | 295 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% |
306 | 296 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
307 | 297 | } |
308 | - } | |
309 | - else if(soft == FALSE){ | |
298 | + } else if(soft == FALSE){ | |
310 | 299 | geneIDNam <- genena %>% |
311 | 300 | read_delim(delim="\t",comment = "#")%>% |
312 | 301 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
... | ... | @@ -407,9 +396,8 @@ THEFT <- function(){ |
407 | 396 | ##Putting the ones without duplicates in their new homes |
408 | 397 | if(tabRDATID[j] == 1){ |
409 | 398 | NuRDATN[,j] <- RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])] |
410 | - } | |
411 | - ##Averaging duplicates and putting them in their new homes | |
412 | - else if(tabRDATID[j] > 1){ | |
399 | + } else if(tabRDATID[j] > 1){ | |
400 | + ##Averaging duplicates and putting them in their new homes | |
413 | 401 | NuRDATN[,j] <- rowMeans(RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])],na.rm = TRUE) |
414 | 402 | } |
415 | 403 | j <- j + 1 |
... | ... | @@ -476,10 +464,9 @@ THEFT <- function(){ |
476 | 464 | write.table(Dscrtalzdw, file = nfnaex2, sep = "\t",col.names = TRUE,row.names = FALSE) |
477 | 465 | n <- n +1 |
478 | 466 | } |
479 | - } | |
480 | - | |
467 | + } else if(numDAT == 2){ | |
481 | 468 | #CHOOSE A DATA FILE TO CLEAN OR SEVERAL DATA FILES TO CLEAN |
482 | - else if(numDAT == 2){ | |
469 | + | |
483 | 470 | #All the files you want to analyze |
484 | 471 | ANDIS <- select.list(choices = list.files()[GSEfileloc],multiple = TRUE, title = "Choose the file/files you want to analyze:") |
485 | 472 | if(length(ANDIS) == 0){ |
... | ... | @@ -541,8 +528,7 @@ THEFT <- function(){ |
541 | 528 | geneIDNam <- paste0("Clean_GPL",gplnum,".txt") %>% |
542 | 529 | read_delim(delim="\t",col_names = c("ID","Symbol"), comment = "!") |
543 | 530 | |
544 | - } | |
545 | - else if(clfileex == 0){ | |
531 | + } else if(clfileex == 0){ | |
546 | 532 | ##Lets Create a clean version |
547 | 533 | |
548 | 534 | ##Gene ID to Gene Name |
... | ... | @@ -565,8 +551,7 @@ THEFT <- function(){ |
565 | 551 | geneIDNam <- genena %>% |
566 | 552 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idlocgpl) %>% |
567 | 553 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
568 | - } | |
569 | - else if(IDF == 0){ | |
554 | + } else if(IDF == 0){ | |
570 | 555 | #No information on this particular GPL file |
571 | 556 | idLOCGPL <- genena %>% |
572 | 557 | read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% |
... | ... | @@ -579,8 +564,7 @@ THEFT <- function(){ |
579 | 564 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% |
580 | 565 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
581 | 566 | } |
582 | - } | |
583 | - else if(fileex == 0){ | |
567 | + } else if(fileex == 0){ | |
584 | 568 | #We must create a file that we can access for later use |
585 | 569 | idLOCGPL <- genena %>% |
586 | 570 | read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% |
... | ... | @@ -594,8 +578,7 @@ THEFT <- function(){ |
594 | 578 | read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% |
595 | 579 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
596 | 580 | } |
597 | - } | |
598 | - else if(soft == FALSE){ | |
581 | + } else if(soft == FALSE){ | |
599 | 582 | geneIDNam <- genena %>% |
600 | 583 | read_delim(delim="\t",comment = "#")%>% |
601 | 584 | dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) |
... | ... | @@ -696,9 +679,8 @@ THEFT <- function(){ |
696 | 679 | ##Putting the ones without duplicates in their new homes |
697 | 680 | if(tabRDATID[j] == 1){ |
698 | 681 | NuRDATN[,j] <- RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])] |
699 | - } | |
682 | + } else if(tabRDATID[j] > 1){ | |
700 | 683 | ##Averaging duplicates and putting them in their new homes |
701 | - else if(tabRDATID[j] > 1){ | |
702 | 684 | NuRDATN[,j] <- rowMeans(RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])],na.rm = TRUE) |
703 | 685 | } |
704 | 686 | j <- j + 1 |