-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_diabetes_pheno
36 lines (29 loc) · 960 Bytes
/
get_diabetes_pheno
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
cbind(BiobankB[,1],BiobankB[,grep("diabetes",colnames(BiobankB))])->temp
age<-rep(0,nrow(BiobankB))
age[which(temp[,5]<30)]<-1
age[which(temp[,6]<30)]<-1
age[which(temp[,7]<30)]<-1
insulin<-rep(0,nrow(BiobankB))
insulin[which(temp[,8]=="Yes")]<-1
insulin[which(temp[,9]=="Yes")]<-1
insulin[which(temp[,10]=="Yes")]<-1
insulin+age=dm
dm2<-rep(0,nrow(BiobankB))
dm2[which(dm==2)]<-1
cbind(temp[,1],dm2)->dm1
save(dm1,file="dm1.Rd")
t2d<-rep(0,nrow(BiobankB))
t2d[which(temp[,1]=="Yes")]<-1
t2d[which(temp[,2]=="Yes")]<-1
t2d[which(temp[,3]=="Yes")]<-1
t2d[which(dm==2)]<-0
cbind(temp[,1],t2d)->dm2
save(dm2,file="dm2.Rd")
grep("30750",colnames(bd),value=T)
[1] "f.30750.0.0" "f.30750.1.0"
cbind(bd[,1],bd$f.30750.0.0,bd$f.30750.1.0)->hb
hb[,2]->hba
hba[which(is.na(hb[,2])==T)]<-hb[which(is.na(hb[,2])==T),3]
inormal <- function(x) qnorm((rank(x, na.last = "keep") - 0.5) / sum(!is.na(x)))
cbind(bd[,1],inormal(hba))->hba1c
save(hba1c,file="hba1c.Rd")