annotate preprocess_datasets/Affymetrix_Preprocessing_Functions.R @ 33:1367e5b24925 draft

Uploaded
author proteomisc
date Mon, 11 Dec 2023 12:16:58 +0000
parents b5eac045873c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
1 AffymetrixPreprocessingFunction<-function(rawdata,backgroundcorrection_method,normalization_method,summary_method,datasetsource="",listfullnames="")
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
2 {
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
3 colnames(exprs(rawdata))<-listfullnames
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
4 data.bg<-bg.correct(rawdata, method=backgroundcorrection_method)
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
5 data.norm<-normalize(data.bg, method=normalization_method)
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
6 data.sm<-threestep(data.norm, background=F, normalize=F,summary.method=summary_method)
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
7 data_matrix=exprs(data.sm)
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
8 sampleNames(data.sm)<-listfullnames
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
9 if(datasetsource=="extern"){
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
10 colnames(data_matrix)<-listfullnames
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
11 data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
12 experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
13 write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
14 row.names=T, col.names=T,file="Matrix.Data.tsv")
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
15 }else{
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
16 colnames(data_matrix)<-designo$sample
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
17 data.sm=ExpressionSet(data_matrix,phenoData=phenoData(data.sm),featureData=featureData(data.sm),
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
18 experimentData=experimentData(data.sm),annotation=annotation(data.sm),protocolData=protocolData(data.sm))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
19 write.table(format(exprs(data.sm), justify="right"),sep="\t", quote=FALSE,
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
20 row.names=T, col.names=T,file="Matrix.Data.tsv")
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
21 }
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
22 installed<-as.data.frame(installed.packages())
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
23 lbraries=paste(annotation(data.sm),"db",sep='.')
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
24 if(!lbraries%in%installed$Package){
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
25 suppressWarnings(suppressMessages(require("BiocManager", quietly = TRUE)))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
26 suppressMessages(suppressWarnings(BiocManager::install(lbraries[!lbraries%in%installed$Package])))}
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
27
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
28 suppressWarnings(suppressMessages(library(lbraries,character.only = TRUE)))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
29
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
30 symbol<-getSYMBOL(rownames(exprs(data.sm)), annotation(data.sm))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
31 return(list(data.bg=data.bg,data.norm=data.norm,data.sm=data.sm,matrix_data=exprs(data.sm),symbol=symbol))
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
32
b5eac045873c Uploaded
proteomisc
parents:
diff changeset
33 }