diff preprocess_datasets/Affymetrix_Preprocessing_Functions.R @ 0:ebf6607b4e6a draft

Uploaded
author proteomisc
date Sat, 02 Dec 2023 14:15:26 +0000
parents
children 4b3faf457c37
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/preprocess_datasets/Affymetrix_Preprocessing_Functions.R	Sat Dec 02 14:15:26 2023 +0000
@@ -0,0 +1,32 @@
+AffymetrixPreprocessingFunction<-function(path="",rawdata,backgroundcorrection_method,normalization_method,summary_method,datasetsource="",listfullnames="")
+{
+  colnames(exprs(rawdata))<-listfullnames
+  data.bg<-bg.correct(rawdata, method=backgroundcorrection_method)
+  data.norm<-normalize(data.bg, method=normalization_method)
+  data.sm<-threestep(data.norm, background=F, normalize=F,summary.method=summary_method)
+  data_matrix=exprs(data.sm)  
+  sampleNames(data.sm)<-listfullnames
+  if(datasetsource=="extern"){
+  colnames(data_matrix)<-listfullnames
+  data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
+  experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
+   write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
+            row.names=T, col.names=T,file="Matrix.Data.tsv")
+  }else{
+  colnames(data_matrix)<-designo$sample
+  data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
+  experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
+  write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
+            row.names=T, col.names=T,file="Matrix.Data.tsv")
+  }
+  installed<-as.data.frame(installed.packages())
+  lbraries=paste(annotation(data.sm),"db",sep='.')
+  if(!lbraries%in%installed$Package){
+  biocLite(lbraries[!lbraries%in%installed$Package])}
+  
+  suppressWarnings(suppressMessages(library(lbraries,character.only = TRUE)))
+  
+  symbol<-getSYMBOL(rownames(exprs(data.sm)), annotation(data.sm))
+  return(list(data.bg=data.bg,data.norm=data.norm,data.sm=data.sm,matrix_data=exprs(data.sm),symbol=symbol))
+  
+  }