Commit 131711985086e2a5856937a57f7d4ea89de4f22c

Authored by Efrain Gonzalez
1 parent e53c3c5908
Exists in master

An automated version of RCleanDscret.R

Working on outputting more insightful errors and warnings. (UNTESTED)
Showing 1 changed file with 28 additions and 28 deletions   Show diff stats
... ... @@ -14,45 +14,45 @@ library(stringr)
14 14 chngrownm <- function(mat){
15 15 row <- dim(mat)[1]
16 16 col <- dim(mat)[2]
17   - j <- 1
18   - x <- 1
19   - p <- 1
20   - a <- 1
21   - b <- 1
  17 + e <- 1
  18 + r <- 1
  19 + a <- 1
  20 + h <- 1
22 21 g <- 1
23   - for(j in 1:col){
24   - if("!Sample_source_name_ch1"==mat[1,j]){
25   - colnames(mat)[j] <- "Brain_Region"
  22 + o <- 1
  23 + for(e in 1:col){
  24 + if("!Sample_source_name_ch1"==mat[1,e]){
  25 + colnames(mat)[e] <- "Brain_Region"
26 26 }
27   - if("!Sample_title" == mat[1,j]){
28   - colnames(mat)[j] <- "Title"
  27 + if("!Sample_title" == mat[1,e]){
  28 + colnames(mat)[e] <- "Title"
29 29 }
30   - if("!Sample_geo_accession" == mat[1,j]){
31   - colnames(mat)[j] <- "ID_REF"
  30 + if("!Sample_geo_accession" == mat[1,e]){
  31 + colnames(mat)[e] <- "ID_REF"
32 32 } else{
33   - if(grepl("Sex|gender|Gender|sex",mat[2,j])==TRUE){
34   - colnames(mat)[j] <- paste0("Sex",x)
35   - x = x + 1
  33 + if(grepl("Sex|gender|Gender|sex",mat[2,e])==TRUE){
  34 + colnames(mat)[e] <- paste0("Sex",r)
  35 + r = r + 1
36 36 }
37   - if(grepl("postmorteminterval|PMI|pmi",mat[2,j])==TRUE){
38   - colnames(mat)[j] <- paste0("PMI",p)
39   - p = p + 1
40   - }
41   - if(grepl("age|Age|AGE",mat[2,j])==TRUE){
42   - colnames(mat)[j] <- paste0("Age",a)
  37 + if(grepl("postmorteminterval|PMI|pmi",mat[2,e])==TRUE){
  38 + colnames(mat)[e] <- paste0("PMI",a)
43 39 a = a + 1
44   - }
45   - if(grepl("braak|b&b",mat[2,j])==TRUE){
46   - colnames(mat)[j] <- paste0("Braak",b)
47   - b = b + 1
48 40 }
49   - if(grepl("group|disease|control|AD|normal|diagnosis|Alzheimer|Control|Normal",mat[2,j])==TRUE){
50   - colnames(mat)[j] <- paste0("Group",g)
  41 + if(grepl("age|Age|AGE",mat[2,e])==TRUE){
  42 + colnames(mat)[e] <- paste0("Age",h)
  43 + h = h + 1
  44 + }
  45 + if(grepl("braak|b&b",mat[2,e])==TRUE){
  46 + colnames(mat)[e] <- paste0("Braak",g)
51 47 g = g + 1
52 48 }
  49 + if(grepl("group|disease|control|AD|normal|diagnosis|Alzheimer|Control|Normal",mat[2,e])==TRUE){
  50 + colnames(mat)[e] <- paste0("Group",o)
  51 + o = o + 1
  52 + }
53 53  
54 54 }
55   - j = j + 1
  55 + e = e + 1
56 56 }
57 57 mat
58 58 }