利用R语言计算DII
library(dplyr)
library(foreign)
#read the XPT file and merge the data from all years choosed
DRITOT_H = read.xport("C:/Users/15870/Desktop/NHANES_DATA/CQnhanes/2013-2014/DIET/DRITOT_H.XPT") #bracket filled with file path
DRITOT_G = read.xport("C:/Users/15870/Desktop/NHANES_DATA/CQnhanes/2011-2012/DIET/DRITOT_G.XPT")
#...
datas = bind_rows(DR1TOT_G,DR1TOT_H) # merge the data in different years
#the diagram of calculating dietary inflammation index (DII)
#reference: Shivappa N, Steck SE, Hurley TG, Hussey JR, Hébert JR. Designing and developing a literature-derived, population-based dietary inflammatory index. Public Health Nutr. 2014 Aug;17(8):1689-96. doi: 10.1017/S1368980013002115IF: 3.2 Q3 . Epub 2013 Aug 14. PMID: 23941862; PMCID: PMC3925198.
#1. get the Global daily mean intake (units/d), standard deviation and Overall inflammatory effect score respectively according to the elements used to calculate the DII
dit_mean = c('DR1TALCO'=13.98, 'DR1TVB12'=5.15, 'DR1TVB6'=1.47,'DR1TBCAR'=3718.00, 'DR1TCAFF'=8.05,'DR1TCARB'=272.20,'DR1TCHOL'=279.4,
'DR1TKCAL'=2056.00,'DR1TTFAT'=71.40,'DR1TFIBE'=18.80,'DR1TFOLA'=273.00,'DR1TIRON'=13.35,'DR1TMAGN'=310.10,'DR1TMFAT'=27.00,'DR1TNIAC'=25.90,
'DR1TPROT'=79.40,'DR1TPFAT'=13.88,'DR1TVB2'=1.70,'DR1TSFAT'=28.60,'DR1TSELE'=67.00,'DR1TVB1'=1.70,'DR1TVARA'=983.90,'DR1TVC'=118.20,
'DR1TVD'=6.26,'DR1TATOC'=8.73,'DR1TZINC'=9.84,'n_3PUFA'=1.06,'n_6PUFA'=10.80) #Global daily mean intake
dit_sd = c('DR1TALCO'=3.72, 'DR1TVB12'=2.70, 'DR1TVB6'=0.74,'DR1TBCAR'=1720.00, 'DR1TCAFF'=6.67,'DR1TCARB'=40.00,'DR1TCHOL'=51.20,
'DR1TKCAL'=338.00,'DR1TTFAT'=19.40,'DR1TFIBE'=4.90,'DR1TFOLA'=70.70,'DR1TIRON'=3.71,'DR1TMAGN'=139.40,'DR1TMFAT'=6.10,'DR1TNIAC'=11.77,
'DR1TPROT'=13.90,'DR1TPFAT'=3.76,'DR1TVB2'=0.79,'DR1TSFAT'=8.00,'DR1TSELE'=25.10,'DR1TVB1'=0.66,'DR1TVARA'=518.60,'DR1TVC'=43.46,
'DR1TVD'=2.21,'DR1TATOC'=1.49,'DR1TZINC'=2.19,'n_3PUFA'=1.06,'n_6PUFA'=7.50) #standard deviation
overall_infla_score = c('DR1TALCO'=-0.278, 'DR1TVB12'=0.106, 'DR1TVB6'=-0.365,'DR1TBCAR'=-0.584, 'DR1TCAFF'=-0.110,'DR1TCARB'=0.097,'DR1TCHOL'=0.110, 'DR1TKCAL'=0.180,'DR1TTFAT'=0.298,'DR1TFIBE'=-0.663,'DR1TFOLA'=-0.190,'DR1TIRON'=0.032,'DR1TMAGN'=-0.484,'DR1TMFAT'=-0.009,'DR1TNIAC'=-0.246,
'DR1TPROT'=0.021,'DR1TPFAT'=-0.337,'DR1TVB2'=-0.068,'DR1TSFAT'=0.373,'DR1TSELE'=-0.191,'DR1TVB1'=-0.098,'DR1TVARA'=-0.401,'DR1TVC'=-0.424,
'DR1TVD'=-0.446,'DR1TATOC'=-0.419,'DR1TZINC'=-0.313,'n_3PUFA'=-0.436,'n_6PUFA'=-0.159) #Overall inflammatory effect score
# 2. choose the items used to calculate the DII
cols = c("DR1TKCAL", "DR1TALCO", "DR1TVB12", "DR1TVB6", "DR1TBCAR", "DR1TCAFF", "DR1TCARB", "DR1TCHOL", "DR1TTFAT", "DR1TFIBE", "DR1TFOLA", "DR1TIRON", "DR1TMAGN", "DR1TMFAT","DR1TNIAC", "DR1TPROT", "DR1TPFAT", "DR1TVB2", "DR1TSFAT", "DR1TSELE", "DR1TVB1","DR1TVARA", "DR1TVC","DR1TVD", "DR1TATOC", "DR1TZINC", "n_3PUFA" , "n_6PUFA")# you can change it according to items that you want to use to calculate the DII
# 3. choose the columns needed in the dataset ; you can change it except "SEQN" according to items that you want to use to calculate the DII
data_cols = c('SEQN','DR1TKCAL','DR1TALCO','DR1TVB12','DR1TVB6','DR1TBCAR','DR1TCAFF','DR1TCARB','DR1TCHOL','DR1TTFAT','DR1TFIBE','DR1TFOLA','DR1TIRON','DR1TMAGN','DR1TMFAT','DR1TNIAC','DR1TPROT','DR1TPFAT','DR1TVB2','DR1TSFAT','DR1TSELE','DR1TVB1','DR1TVARA','DR1TVC','DR1TVD','DR1TATOC','DR1TZINC','DR1TP225','DR1TP183','DR1TP184','DR1TP226','DR1TP205','DR1TP204','DR1TP182') #SEQN: each participant‘s ID
data_needed <- datas[,data_cols] #choose the data needed
# 4. calculate the items needed for calculating DII
data_needed <-mutate(data_needed,
n_3PUFA = DR1TP225+DR1TP183+DR1TP184+DR1TP226+DR1TP205, #calculate the Omega-3 Polyunsaturated Fatty Acids;
#reference: Shahidi F, Ambigaipalan P. Omega-3 Polyunsaturated Fatty Acids and Their Health Benefits. Annu Rev Food Sci Technol. 2018 Mar 25;9:345-381. doi: 10.1146/annurev-food-111317-095850IF: 12.4 Q1 . PMID: 29350557.
n_6PUFA = DR1TP204+DR1TP182) #calculate the Omega-6 Polyunsaturated Fatty Acids;
#reference: Lands B. Consequences of essential fatty acids. Nutrients. 2012 Sep;4(9):1338-57. doi: 10.3390/nu4091338. Epub 2012 Sep 24. PMID: 23112921; PMCID: PMC3475243.
data_needed['DR1TCAFF'] <- data_needed['DR1TCAFF']/1000 #convert the unit of caffeine
data_needed <- na.omit(data_needed) #delete the participants having missing data
# 5. transformed to Z-score.This is achieved by subtracting the‘standard mean’ from the amount reported and dividing this value by its standard deviation
for(i in colnames(data_needed)){
if(i %in% cols){
data_needed[,i] <- (data_needed[,i]-dit_mean[i])/dit_sd[i]
}
}
# 6. convert the value to percentile score
rownums = nrow(data_needed)
for(j in 1:rownums){
for(i in cols){
data_needed[j,i] = pnorm(data_needed[j,i],mean = 0, sd = 1,lower.tail = TRUE, log.p = FALSE)
}
}
# 7. To achieve a symmetrical distribution with values centred on 0 (null) and bounded between -1 (maximally anti-inflammatory) and +1 (maximally pro-inflammatory), each percentile score is doubled and then ‘1’ is subtracted.
data_needed[,cols] <- data_needed[,cols]*2 - 1
# 8. The centred percentile value for each food parameter is then multiplied by its respective ‘overall food parameterspecific inflammatory effect score’ to obtain the ‘food parameter-specific DII score’
for(n in colnames(data_needed)){
if(n %in% cols){
data_needed[,n] = data_needed[,n]*overall_infla_score[n]
}
}
# 9.Sum all of the ‘food parameter-specific DII scores’ to create the ‘overall DII score’ for an individua
data_needed <- data_needed %>% mutate(DII = rowSums(select(.,cols)))
# 10.write the datasheet to excel
write.csv(data_needed,'C:/Users/15870/Desktop/NHANES_DATA/CQnhanes/dii_data.csv')#bracket filled with file path