diff --git a/RAutoClDs.R b/RAutoClDs.R index ae53876..6d20426 100644 --- a/RAutoClDs.R +++ b/RAutoClDs.R @@ -27,11 +27,9 @@ chngrownm <- function(mat){ for(e in 1:col){ if("!Sample_source_name_ch1"==mat[1,e]){ colnames(mat)[e] <- "Brain_Region" - } - else if("!Sample_title" == mat[1,e]){ + } else if("!Sample_title" == mat[1,e]){ colnames(mat)[e] <- "Title" - } - else if("!Sample_geo_accession" == mat[1,e]){ + } else if("!Sample_geo_accession" == mat[1,e]){ colnames(mat)[e] <- "ID_REF" } else{ if(grepl("Sex|gender|Gender|sex",mat[2,e])==TRUE){ @@ -68,19 +66,15 @@ cinfo <- function(mat){ for(j in 2:col){ if(grepl("Group",colnames(mat)[j]) == TRUE){ mat[,j] <- gsub(".+:\\s|\\s.+;.+","",mat[,j]) - } - else if(grepl("Age",colnames(mat)[j])==TRUE){ + } else if(grepl("Age",colnames(mat)[j])==TRUE){ mat[,j] <- gsub("\\D","",mat[,j])%>% as.integer() - } - else if(grepl("Sex",colnames(mat)[j])==TRUE){ + } else if(grepl("Sex",colnames(mat)[j])==TRUE){ mat[,j] <- gsub(".+:\\s","",mat[,j]) - } - else if(grepl("PMI",colnames(mat)[j])==TRUE){ + } else if(grepl("PMI",colnames(mat)[j])==TRUE){ mat[,j] <- gsub("[^0-9\\.]","",mat[,j])%>% as.numeric() - } - else if(grepl("Braak",colnames(mat)[j])==TRUE){ + } else if(grepl("Braak",colnames(mat)[j])==TRUE){ mat[,j]<-gsub(".+:\\s","",mat[,j])%>% as.roman()%>% as.integer() @@ -168,11 +162,9 @@ dndat <- function(NDATA){ if(NDATA[i,j] < -1){ DDATA[i,j]=0L - } - else if(NDATA[i,j] > 1){ + } else if(NDATA[i,j] > 1){ DDATA[i,j]=2L - } - else if(-1 <= NDATA[i,j] && NDATA[i,j] < 1){ + } else if(-1 <= NDATA[i,j] && NDATA[i,j] < 1){ DDATA[i,j]=1L } } else{ @@ -276,8 +268,7 @@ THEFT <- function(){ geneIDNam <- genena %>% read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idlocgpl) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) - } - else if(IDF == 0){ + } else if(IDF == 0){ #No information on this particular GPL file idLOCGPL <- genena %>% read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% @@ -290,8 +281,7 @@ THEFT <- function(){ read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) } - } - else if(fileex == 0){ + } else if(fileex == 0){ #We must create a file that we can access for later use idLOCGPL <- genena %>% read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% @@ -305,8 +295,7 @@ THEFT <- function(){ read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) } - } - else if(soft == FALSE){ + } else if(soft == FALSE){ geneIDNam <- genena %>% read_delim(delim="\t",comment = "#")%>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) @@ -407,9 +396,8 @@ THEFT <- function(){ ##Putting the ones without duplicates in their new homes if(tabRDATID[j] == 1){ NuRDATN[,j] <- RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])] - } - ##Averaging duplicates and putting them in their new homes - else if(tabRDATID[j] > 1){ + } else if(tabRDATID[j] > 1){ + ##Averaging duplicates and putting them in their new homes NuRDATN[,j] <- rowMeans(RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])],na.rm = TRUE) } j <- j + 1 @@ -476,10 +464,9 @@ THEFT <- function(){ write.table(Dscrtalzdw, file = nfnaex2, sep = "\t",col.names = TRUE,row.names = FALSE) n <- n +1 } - } - + } else if(numDAT == 2){ #CHOOSE A DATA FILE TO CLEAN OR SEVERAL DATA FILES TO CLEAN - else if(numDAT == 2){ + #All the files you want to analyze ANDIS <- select.list(choices = list.files()[GSEfileloc],multiple = TRUE, title = "Choose the file/files you want to analyze:") if(length(ANDIS) == 0){ @@ -541,8 +528,7 @@ THEFT <- function(){ geneIDNam <- paste0("Clean_GPL",gplnum,".txt") %>% read_delim(delim="\t",col_names = c("ID","Symbol"), comment = "!") - } - else if(clfileex == 0){ + } else if(clfileex == 0){ ##Lets Create a clean version ##Gene ID to Gene Name @@ -565,8 +551,7 @@ THEFT <- function(){ geneIDNam <- genena %>% read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idlocgpl) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) - } - else if(IDF == 0){ + } else if(IDF == 0){ #No information on this particular GPL file idLOCGPL <- genena %>% read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% @@ -579,8 +564,7 @@ THEFT <- function(){ read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) } - } - else if(fileex == 0){ + } else if(fileex == 0){ #We must create a file that we can access for later use idLOCGPL <- genena %>% read_delim(delim="\t",col_names = FALSE, comment = "!", n_max = 1000) %>% @@ -594,8 +578,7 @@ THEFT <- function(){ read_delim(delim="\t",col_names = TRUE, comment = "!", skip = idLOCGPL) %>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) } - } - else if(soft == FALSE){ + } else if(soft == FALSE){ geneIDNam <- genena %>% read_delim(delim="\t",comment = "#")%>% dplyr::select(.,ID,grep("Symbol|^ORF\\s*$|^gene_assignment\\s*$",colnames(.))) @@ -696,9 +679,8 @@ THEFT <- function(){ ##Putting the ones without duplicates in their new homes if(tabRDATID[j] == 1){ NuRDATN[,j] <- RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])] - } + } else if(tabRDATID[j] > 1){ ##Averaging duplicates and putting them in their new homes - else if(tabRDATID[j] > 1){ NuRDATN[,j] <- rowMeans(RAWDATNUM[,which(RAWDATID==rownames(tabRDATID)[j])],na.rm = TRUE) } j <- j + 1