-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGSIMethDecon.R
More file actions
21 lines (21 loc) · 766 Bytes
/
Copy pathGSIMethDecon.R
File metadata and controls
21 lines (21 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
GSIMethDecon<-function(data){
data<-data.matrix(data)
group=names(table(colnames(data)))
index=colnames(data)
gsi<-gmaxgroup<-avebase<-c()
for(i in 1:nrow(data)){
gsit<-0
gmax<-names(which.max(tapply(as.numeric(data[i,]),index,function(x) mean(x,na.rm=T))))
for(j in 1:length(group)){
tmp<-(1-10^(mean(data[i,][which(index==group[j])],na.rm=T))/10^(mean(data[i,][which(index==gmax)],,na.rm=T)))/(length(group)-1)
gsit<-gsit+tmp
}
ave<-tapply(data[i,], index, function(x) mean(x,na.rm=T))
gmaxgroup<-c(gmaxgroup,gmax)
gsi<-c(gsi,gsit)
avebase<-rbind(avebase,ave)
}
rlt=data.frame(region=rownames(data),group=gmaxgroup,GSI=gsi,AVE=avebase)
rlt<-rlt[-which(rlt[,2]!="WBC" & rlt[,grep("WBC",colnames(rlt))]>0.1),]
return(rlt)
}