diff --git a/RAutoClDs.R b/RAutoClDs.R index 0ae7af1..6121a8c 100644 --- a/RAutoClDs.R +++ b/RAutoClDs.R @@ -14,45 +14,45 @@ library(stringr) chngrownm <- function(mat){ row <- dim(mat)[1] col <- dim(mat)[2] - j <- 1 - x <- 1 - p <- 1 - a <- 1 - b <- 1 + e <- 1 + r <- 1 + a <- 1 + h <- 1 g <- 1 - for(j in 1:col){ - if("!Sample_source_name_ch1"==mat[1,j]){ - colnames(mat)[j] <- "Brain_Region" + o <- 1 + for(e in 1:col){ + if("!Sample_source_name_ch1"==mat[1,e]){ + colnames(mat)[e] <- "Brain_Region" } - if("!Sample_title" == mat[1,j]){ - colnames(mat)[j] <- "Title" + if("!Sample_title" == mat[1,e]){ + colnames(mat)[e] <- "Title" } - if("!Sample_geo_accession" == mat[1,j]){ - colnames(mat)[j] <- "ID_REF" + if("!Sample_geo_accession" == mat[1,e]){ + colnames(mat)[e] <- "ID_REF" } else{ - if(grepl("Sex|gender|Gender|sex",mat[2,j])==TRUE){ - colnames(mat)[j] <- paste0("Sex",x) - x = x + 1 + if(grepl("Sex|gender|Gender|sex",mat[2,e])==TRUE){ + colnames(mat)[e] <- paste0("Sex",r) + r = r + 1 } - if(grepl("postmorteminterval|PMI|pmi",mat[2,j])==TRUE){ - colnames(mat)[j] <- paste0("PMI",p) - p = p + 1 - } - if(grepl("age|Age|AGE",mat[2,j])==TRUE){ - colnames(mat)[j] <- paste0("Age",a) + if(grepl("postmorteminterval|PMI|pmi",mat[2,e])==TRUE){ + colnames(mat)[e] <- paste0("PMI",a) a = a + 1 - } - if(grepl("braak|b&b",mat[2,j])==TRUE){ - colnames(mat)[j] <- paste0("Braak",b) - b = b + 1 } - if(grepl("group|disease|control|AD|normal|diagnosis|Alzheimer|Control|Normal",mat[2,j])==TRUE){ - colnames(mat)[j] <- paste0("Group",g) + if(grepl("age|Age|AGE",mat[2,e])==TRUE){ + colnames(mat)[e] <- paste0("Age",h) + h = h + 1 + } + if(grepl("braak|b&b",mat[2,e])==TRUE){ + colnames(mat)[e] <- paste0("Braak",g) g = g + 1 } + if(grepl("group|disease|control|AD|normal|diagnosis|Alzheimer|Control|Normal",mat[2,e])==TRUE){ + colnames(mat)[e] <- paste0("Group",o) + o = o + 1 + } } - j = j + 1 + e = e + 1 } mat }