--- title: "Final THYROCHEM report - REPORT - tables" author: "Xanthi D. Andrianou - Water and Health Lab" output: html_document: number_sections: yes theme: flatly toc: yes word_document: default Date: August 22, 2016 --- ```{r setup, cache=FALSE, include=FALSE} options(width = 90) ``` This report is based on the full analysis of the THYROCHEM dataset including both the Cypriot and Romanian data. # Preliminaries ```{r Packages, echo=FALSE, include=FALSE, warning=TRUE} #CHANGE 160822 - LOAD EACH PACKAGE SEPARATELY library("ggplot2") library("dplyr") library("data.table") library("Hmisc") library("stargazer") library("psych") library("plyr") library("corrplot") library("tableone") library("sjPlot") library("corrplot") library("ICC") library("irr") library("coefplot") library("car") library("knitr") #pkg<-c("ggplot2","dplyr","data.table","Hmisc","stargazer","psych","plyr","tableone", "sjPlot","corrplot","ICC", "irr","coefplot","car","knitr") #out<-lapply(pkg, function(x) { # if(!require(x,character.only = TRUE)) #install.packages(x,character.only = TRUE) #} #) ``` ## Packages used The R packages used in the analysis are the following: "ggplot2","dplyr","data.table","Hmisc","stargazer","psych","plyr","tableone", "sjPlot","corrplot","ICC", "irr","coefplot","car","knitr" Complete information on the versions and the exact citations are provided in the end of the report. --- ## Raw data files The raw data files used for the analysis are the following: * Cyprus + questionnaire - CY_20150714_Questionnaire_DF.csv + BPA results - CY_BPA_spot_rawdata_DF.csv and CY_BPA_morn_rawdata_DF.csv + Iodine results (incl. creatinine) - CY_creat_iodine_DF.csv * Romania + questionnaire - RO_Questionnaire_150711_DF.csv + BPA results - RO_BPA_rawdata.csv + Iodine results - RO_creat_iodine_DF.csv ```{r VariableLists, include=FALSE, hide=TRUE, warning=FALSE} #variables from the whole questionnaire that will be recoded for the analysis quest_vars<-c( "CODE", "status", "country", #demographics "age", "weight", "height", "marstat", "edu", "tsh", "ft4", "antitg", "antitpo", "smokst", "alccons", #drinking water from 20l "dwh20l", "glh20l", "dwbh20l", "glbh20lb", "dwa20l", "gla20l", "dwba20l", "glba20lb", "ref20l", "reffr20l", #microware use "MwaveFrw", #canned food "tommc", "tunamc", "cornmc", "stdrmc", "vegmc", "fishmc", "meatmc", "frtmc", "cnotmc", #PCPs "shmpwc", "conrwc", "bylnwc", "srglwc", "hdspwc", "hrfmwc", "hrdewc", "hrsywc", "nlphwc", "lppnwc", "fecmwc", #knowledge "natknowl", "chemknowl", #cleaning "dshwshm", "dshwshsd", "mopm", "mopd", "toilm", "toild", "bthrm", "bthrd", "winm", "wind", "othcm", "othcd", #chlorine use "dshwshchl", "mopchl", "toilchl", "bthrchl", "winchl", "othcchl", "lauweek", #perfume "perfwc", #deodorant "liqdeowc", "soldeowc", "sprdeowc", #cosmetics "mkupw", "lpstw", "eylnw", "rougw", "mascw", "mkremw") #the variables of the questionnaire that are to be used in the analysis quest_analysis_vars<-c("CODE", "status", "country", "age", "weight", "heightM", "BMI", "BMI_cat", "marstat", "edu", "tsh", "ft4", "antitg", "antitpo", "smokst", "alccons", "daily20lglass", #drinking water from 20l "MwaveFrw", #microware use "weekPORTIONScanned", #canned food "weekMINScleaning", #cleaning "weekPORTIONSpcps", #PCPs "perfwc", #perfume "weekPORTIONSdeo", #deodorant "weekPORTIONScosm"#cosmetics ) #demographic variables demo_vars<-c("age","weight", "heightM", "BMI", "BMI_cat", "smokst", "alccons", "marstat", "edu") #exposures from the questionnaire expo_vars<-c("daily20lglass", #drinking water from 20l "MwaveFrw", #microware use "weekPORTIONScanned", #canned food "weekMINScleaning", #cleaning "weekPORTIONSpcps", #PCPs "perfwc", #perfume "weekPORTIONSdeo", #deodorant "weekPORTIONScosm"#cosmetics ) #hormones horm_vars_iod_sp<-c("tsh", "ft4","iod_ugPERlt_spot") #hormones and antibodies horm_vars_cat<-c("tsh_cat","ft4_cat", "antitg", "antitpo") #urine measurement variables - incl. morning and spot urine_levs_vars<-c("BPF_ngPERlt_spot","BPA_ngPERlt_spot","ClBPA_ngPERlt_spot","Cl35_2BPA_ngPERlt_spot", "Cl33_2BPA_ngPERlt_spot","ClxBPA_ngPERlt_spot","BPF_ngPERg_spot","BPA_ngPERg_spot","ClBPA_ngPERg_spot","Cl35_2BPA_ngPERg_spot", "Cl33_2BPA_ngPERg_spot","ClxBPA_ngPERg_spot", "BPF_ngPERlt_morn","BPA_ngPERlt_morn","ClBPA_ngPERlt_morn","Cl35_2BPA_ngPERlt_morn", "Cl33_2BPA_ngPERlt_morn","ClxBPA_ngPERlt_morn","BPF_ngPERg_morn","BPA_ngPERg_morn","ClBPA_ngPERg_morn","Cl35_2BPA_ngPERg_morn", "Cl33_2BPA_ngPERg_morn","ClxBPA_ngPERg_morn") ln_vars_spot<-c("ln_BPF_ngPERlt_spot","ln_BPA_ngPERlt_spot", "ln_ClBPA_ngPERlt_spot","ln_Cl35_2BPA_ngPERlt_spot", "ln_Cl33_2BPA_ngPERlt_spot","ln_ClxBPA_ngPERlt_spot", "ln_BPF_ngPERg_spot","ln_BPA_ngPERg_spot", "ln_ClBPA_ngPERg_spot","ln_Cl35_2BPA_ngPERg_spot", "ln_Cl33_2BPA_ngPERg_spot","ln_ClxBPA_ngPERg_spot") ln_vars_morn<-c("ln_BPF_ngPERlt_morn","ln_BPA_ngPERlt_morn", "ln_ClBPA_ngPERlt_morn","ln_Cl35_2BPA_ngPERlt_morn", "ln_Cl33_2BPA_ngPERlt_morn","ln_ClxBPA_ngPERlt_morn", "ln_BPF_ngPERg_morn","ln_BPA_ngPERg_morn", "ln_ClBPA_ngPERg_morn","ln_Cl35_2BPA_ngPERg_morn", "ln_Cl33_2BPA_ngPERg_morn","ln_ClxBPA_ngPERg_morn") ``` ## Variable lists The variables were all taken from the raw data. Questionnaire variables were summarized to be used in the summary analysis of the exposures. Variables that were not directly measured such as BMI or the creatinine-adjustment of the urinary concentrations were created during the analysis. Specific variable lists were created and used in the present script for efficiency. List of the different combinations of the variables used in the analysis: * quest_vars - all the variables extracted from the questionnaire and used in the analysis * quest_analysis_vars - questionnaire variables used in the final analysis * demo_vars - demographics and anthropometric characteristics * expo_vars - summary of the "questionniare exposures" * horm_vars_iod_sp - hormones and spot iodine (ng/L) (all continuous) * horm_vars_cat - categorical variables of the hormone levels and the antibodies + _Note: the categorization of the hormone leves was done separately for Cyprus and Romania since the normal levels differ in the two countries._ * urine_levs_vars - ng/L urine levels both spot and morning (raw, ng/L and ng/g) * urine_levs_vars_av - urine levels average levels {derived with the function (spot+morn)/2} * ln_vars_spot - ln-transformed ng/L and ng/g - spot * ln_vars_morn - ln-transformed ng/L and ng/g - morning * ln_vars_av - ln-transformed average ng/L and ng/g - (ln of the average not average of the ln_spot and ln_morn) * quant_vars - quantiles of the BPF, BPA and ClxBPA (ng/L) ## Functions General functions * creatine_adj -- creatinine adjustment (ng/L concentrations divided by the creatinine) _Note: iodine concentrations were already adjusted for creatinine and the units were ug/L and ug/g (unadjusted and adjusted, respectively) * spot_morn_av -- average of spot and morning - applied to the ng/L and the ng/g * gm_func -- geometric mean * gsd_func -- geometric standard deviation * break_quant -- breaking the quantiles (0,0.25,0.50,0.75,1) - including the lowest bound * t_test_unpaired_table -- table for the results of the unpaired t-test - applied to the ln-transformed ng/L and ng/g concentrations, hormones etc. * wilcox_test_unpaired_table -- table for the results of the unpaired Wilcoxon test - applied to the raw ng/L and ng/g concentrations, hormones etc. ```{r GenFunctions, echo=FALSE, include=FALSE, warning=FALSE} ### Functions #make the creatinine-adjustment concentrations for the BPA etc. creatine_adj<-function(ngPERlt_conc,creatinine_gPERlt){ ngPERlt_conc/creatinine_gPERlt} spot_morn_av<-function(spot,morn){ (spot+morn)/2} gm_func<-function(x){geometric.mean(x, na.rm = TRUE)} gsd_func <- function(x, na.rm=TRUE){exp(sd(log(x), na.rm=na.rm))} expx <- function(x) (exp(x)) break_quant<-function (var){cut(var, breaks=quantile(var, c(0,0.25,0.50,0.75,1), na.rm=TRUE), include.lowest = TRUE)} t_test_unpaired_table<-function (variable, group) {unlist(t.test(log(variable)~group)[c("estimate","p.value","statistic")])} wilcox_test_unpaired_table<-function (variable, group) {unlist(wilcox.test(variable~group)[c("p.value","statistic")])} ``` Logistic regression functions _Νotes: The logistic regression fuctions were used separately for each country and the pooled samples. All the concentration variables were used in the models log-transformed (to the natural logarithm) including the hormones, iodine and creatinine. * _Univariate regressions_ + All variables (incl. those recoded from the questionnaires) were included in univariate models * _Multivariate regressions_ + LR1: adjusted for age, BMI, tsh and ft4 + LR2: adjusted for age, BMI, tsh, ft4 and spot iodine ```{r RegFunctions, echo=FALSE, include=FALSE, warning=FALSE} #regression functions #Logistic regression outcome: TND #regression functions # univariate - crude estimates LR_status01_x1<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ ", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) }#no country - with creatinine - either spot or morning # univariate and creatinine - CY, RO and pooled LR_status01_x1_spot_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } # multivatiare for spot ng/L and creatinine - CY, RO and pooled LR1_status01_multix_spot_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ age + BMI + ln_tsh + ln_ft4 + ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } LR2_status01_multix_spot_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ age + BMI + ln_tsh + ln_ft4 + ln_iod_ugPERlt_spot + ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } #models with country as covariate and creatinine adjustment - only spot levels # univariate and creatinine - CY, RO and pooled # used only for the demo, questionnaire etc. LR_status01_x1_country<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ country +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } # used with the concentrations LR_status01_x1_country_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ country + ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } # multivatiare for spot ng/L and creatinine - CY, RO and pooled LR1_status01_multix_country_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ country + age + BMI + ln_tsh + ln_ft4 + ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } LR2_status01_multix_country_CR<-function(var, dataframe) { formula <- as.formula(paste("status01 ~ country + age + BMI + ln_tsh + ln_ft4 + ln_iod_ugPERlt_spot + ln_creat_gPERlt_spot +", var)) res.logist <- glm(formula, data = dataframe, family = binomial(link=logit)) } ``` ```{r DataImport, echo=FALSE, include=FALSE, warning=FALSE} ###CY data #Questionnaire CY_questionnaire<-read.csv("CY_20150714_Questionnaire_DF.csv", header=TRUE) str(CY_questionnaire) #taking just the variables we need -- see variables.r script CY_quest<-CY_questionnaire[, c(quest_vars)] str(CY_quest) #Get BPA results - add ClxBPA and make creatinine adjustment #spot CY_BPA_spot<-read.csv("CY_BPA_spot_rawdata_DF.csv", header=TRUE) #sum of the BPA analogs - ClxBPA_ngPERlt_spot CY_BPA_spot$ClxBPA_ngPERlt_spot<-with(CY_BPA_spot, ClBPA_ngPERlt_spot+Cl35_2BPA_ngPERlt_spot+Cl33_2BPA_ngPERlt_spot) str(CY_BPA_spot) #morn CY_BPA_morn<-read.csv("CY_BPA_morn_rawdata_DF.csv", header=TRUE) #sum of the BPA analogs - ClxBPA_ngPERlt_morn CY_BPA_morn$ClxBPA_ngPERlt_morn<-with(CY_BPA_morn, ClBPA_ngPERlt_morn+Cl35_2BPA_ngPERlt_morn+Cl33_2BPA_ngPERlt_morn) str(CY_BPA_morn) #merging spot and morning BPA CY_all_BPA<-merge(CY_BPA_spot, CY_BPA_morn) str(CY_all_BPA) summary(CY_all_BPA) #Get the iodine data - incl. the creatinine adjustment of iodine #and the creatinine concentrations CY_iod<-read.csv("CY_creat_iodine_DF.csv", header=TRUE) str(CY_iod) #Merging all the dfs with the measurements CY_meas<-merge(CY_all_BPA, CY_iod) #take only the ngPERlt, creatinine and ngPERg concentrations NOTE: iodine also taken - CY_meas_SHRT<-CY_meas[grep("_ngPERlt|_ngPERg|_gPERlt|iod|CODE",colnames(CY_meas))] #creatinine adjustment - SPOT CY_meas_SHRT$BPF_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(BPF_ngPERlt_spot, creat_gPERlt_spot)) CY_meas_SHRT$BPA_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(BPA_ngPERlt_spot, creat_gPERlt_spot)) CY_meas_SHRT$ClBPA_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(ClBPA_ngPERlt_spot, creat_gPERlt_spot)) CY_meas_SHRT$Cl35_2BPA_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(Cl35_2BPA_ngPERlt_spot, creat_gPERlt_spot)) CY_meas_SHRT$Cl33_2BPA_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(Cl33_2BPA_ngPERlt_spot, creat_gPERlt_spot)) CY_meas_SHRT$ClxBPA_ngPERg_spot<-with(CY_meas_SHRT, creatine_adj(ClxBPA_ngPERlt_spot, creat_gPERlt_spot)) #creatinine adjustment - MORN CY_meas_SHRT$BPF_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(BPF_ngPERlt_morn, creat_gPERlt_morn)) CY_meas_SHRT$BPA_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(BPA_ngPERlt_morn, creat_gPERlt_morn)) CY_meas_SHRT$ClBPA_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(ClBPA_ngPERlt_morn, creat_gPERlt_morn)) CY_meas_SHRT$Cl35_2BPA_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(Cl35_2BPA_ngPERlt_morn, creat_gPERlt_morn)) CY_meas_SHRT$Cl33_2BPA_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(Cl33_2BPA_ngPERlt_morn, creat_gPERlt_morn)) CY_meas_SHRT$ClxBPA_ngPERg_morn<-with(CY_meas_SHRT, creatine_adj(ClxBPA_ngPERlt_morn, creat_gPERlt_morn)) str(CY_meas_SHRT) summary(CY_meas_SHRT) ###Get the RO data RO_questionnaire<-read.csv("RO_Questionnaire_150711_DF.csv", header=TRUE) str(RO_questionnaire) #taking just the variables we need -- see variables.r script RO_quest<-RO_questionnaire[, c(quest_vars)] str(RO_quest) RO_iod<-read.csv("RO_creat_iodine_DF.csv", header=TRUE) str(RO_iod) RO_BPA<-read.csv("RO_BPA_rawdata.csv", header=TRUE) #sum of the BPA analogs - ClxBPA_ngPERlt_spot RO_BPA$ClxBPA_ngPERlt_spot<-with(RO_BPA, ClBPA_ngPERlt_spot+Cl35_2BPA_ngPERlt_spot+Cl33_2BPA_ngPERlt_spot) RO_meas<-merge(RO_BPA, RO_iod) #take only the ngPERlt, creatinine and ngPERg concentrations (the latter are only available for iodine) - NOTE: iodine also taken RO_meas_SHRT<-RO_meas[grep("_ngPERg|_ngPERlt|_gPERlt|iod_|CODE",colnames(RO_meas))] #make the creatinine-adjusted concentrations for the BPA etc. RO_meas_SHRT$BPF_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(BPF_ngPERlt_spot, creat_gPERlt_spot)) RO_meas_SHRT$BPA_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(BPA_ngPERlt_spot, creat_gPERlt_spot)) RO_meas_SHRT$ClBPA_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(ClBPA_ngPERlt_spot, creat_gPERlt_spot)) RO_meas_SHRT$Cl35_2BPA_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(Cl35_2BPA_ngPERlt_spot, creat_gPERlt_spot)) RO_meas_SHRT$Cl33_2BPA_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(Cl33_2BPA_ngPERlt_spot, creat_gPERlt_spot)) RO_meas_SHRT$ClxBPA_ngPERg_spot<-with(RO_meas_SHRT, creatine_adj(ClxBPA_ngPERlt_spot, creat_gPERlt_spot)) str(RO_meas_SHRT) summary(RO_meas_SHRT) #merge the measurements meas_SHRT<-rbind.fill(CY_meas_SHRT, RO_meas_SHRT) summary(meas_SHRT) ##Merge the questionnaires to make the clean up and handle the variables and split them up again questionnaires<-rbind(CY_quest, RO_quest) #str(questionnaires) ``` ## Questionnaire variable recoding List of the final external exposure measurement variables are: * Water consumption from 20L PC bottles * Weekly use of microwave (with plastic container?) * Weekly consumption of canned food (number of portions) * Duration of cleaning activities (as proxy to chlorine exposures) * Weekly use of PCPs (sum of: shampoo, conditioner, body lotion, shower gel, hair dye, hair foam, hair spray, nail polish, lip care products, face cream) * Weekly use of perfume and deodorant * Weekly use of perfume and deodorant and weekly use of cosmetics (makeup, lipstick, eyeliner, rouge, mascara, makeup remover). ```{r QuestVarRecoding, echo=FALSE, include=FALSE, hide=TRUE} #'Missing values handling questionnaires[questionnaires==999]<-NA questionnaires[, c("liqdeowc","soldeowc","mkremw")][questionnaires[, c("liqdeowc","soldeowc","mkremw")]==99]<- NA questionnaires[, c("marstat","edu","smokst","alccons","ref20l","reffr20l")][questionnaires[, c("marstat","edu","smokst","alccons","ref20l","reffr20l")]==9]<- NA #make BMI variable questionnaires$heightM=(questionnaires$height/100) questionnaires$BMI<-round(questionnaires$weight/(questionnaires$heightM^2), digits=2) #add BMI categories questionnaires$BMI_cat=(cut(questionnaires$BMI, breaks=c(0,18.4,24.9,29.9,Inf), labels=c("Underweight","Normal","Overweight","Obese"))) #making the categorical variables as factors and renaming them questionnaires$marstat<-factor(questionnaires$marstat) questionnaires$marstat<-revalue(questionnaires$marstat, c("9"="NA","1"="Single","2"="Married","3"="Divorced","4"="Widow","5"="Other")) questionnaires$edu<-factor(questionnaires$edu) questionnaires$edu<-revalue(questionnaires$edu, c("9"="NA","1"="Primary","2"="Secondary","3"="University","4"="University","5"="Other")) questionnaires$smokst<-factor(questionnaires$smokst) questionnaires$smokst<-revalue(questionnaires$smokst, c("9"="NA","0"="Never","1"="Currently","2"="Past")) questionnaires$alccons<-factor(questionnaires$alccons) questionnaires$alccons<-revalue(questionnaires$alccons, c("9"="NA","0"="Never/Rarely","1"="Weekend","2"="Often")) questionnaires$antitg<-factor(questionnaires$antitg) questionnaires$antitg<-revalue(questionnaires$antitg, c("9"="NA","0"="Negative","1"="Positive")) questionnaires$antitpo<-factor(questionnaires$antitpo) questionnaires$antitpo<-revalue(questionnaires$antitpo, c("9"="NA","0"="Negative","1"="Positive")) questionnaires$ref20l<-factor(questionnaires$ref20l) questionnaires$ref20l<-revalue(questionnaires$ref20l, c("9"="NA","0"="No","1"="Yes")) questionnaires$reffr20l<-factor(questionnaires$reffr20l) questionnaires$reffr20l<-revalue(questionnaires$reffr20l, c("9"="NA","0"="0to10times","1"="10to20times","2"="21to50times","3"="morethan50times")) #YES/NO - factor variables that are continuous taken to be changed to factors quest_YN_cat<-which(names(questionnaires)%in%c( "ref20l", #use of chlorine - categorical "dshwshchl","mopchl","toilchl","bthrchl","winchl","othcchl")) questionnaires[, quest_YN_cat] <- lapply(questionnaires[, quest_YN_cat], as.factor) #functions for quest recoding daily20lglass<-function(x){ with(x, ((dwh20l*glh20l)+(dwbh20l*glbh20lb)+(dwa20l*gla20l)+(dwba20l*glba20lb))/7)} weekPORTIONScanned<-function(x){ with(x, ((tommc+tunamc+cornmc+stdrmc+vegmc+fishmc+meatmc+frtmc+cnotmc)/4))} dailyMINScleaning<-function(x){ with(x, ((dshwshm*dshwshsd)+(mopm*mopd)+(toilm*toild)+(bthrm*bthrd)+(winm*wind)+(othcm*othcd))/30)} weekMINScleaning<-function(x){ with(x, ((dshwshm*dshwshsd)+(mopm*mopd)+(toilm*toild)+(bthrm*bthrd)+(winm*wind)+(othcm*othcd))/4)} dailyPORTIONSpcps<-function(x){ with(x, ((shmpwc+conrwc+bylnwc+srglwc+hdspwc+hrfmwc+ hrdewc+hrsywc+nlphwc+lppnwc+fecmwc+liqdeowc+soldeowc+sprdeowc)/7))} weekPORTIONSpcps<-function(x){ with(x, ((shmpwc+conrwc+bylnwc+srglwc+hdspwc+hrfmwc+ hrdewc+hrsywc+nlphwc+lppnwc+fecmwc)))} weekPORTIONSdeo<-function(x){ with(x, (liqdeowc+soldeowc+sprdeowc))} dailyPORTIONScosm<-function(x){ with(x, ((mkupw+lpstw+eylnw+rougw+mascw+mkremw)/7))} weekPORTIONScosm<-function(x){ with(x, (mkupw+lpstw+eylnw+rougw+mascw+mkremw))} #### #summary variable for the water questionnaires$daily20lglass<-daily20lglass(questionnaires) #weekly consuption of canned food questionnaires$weekPORTIONScanned<-weekPORTIONScanned(questionnaires) #cleaning duration day questionnaires$dailyMINScleaning<-dailyMINScleaning(questionnaires) #cleaning duration weekly questionnaires$weekMINScleaning<-weekMINScleaning(questionnaires) #daily use of PCPs - incl. deodorant questionnaires$dailyPORTIONSpcps<-dailyPORTIONSpcps(questionnaires) #pcps use weekly - excl. deodorant questionnaires$weekPORTIONSpcps<-weekPORTIONSpcps(questionnaires) #deodorant weekly use questionnaires$weekPORTIONSdeo<-weekPORTIONSdeo(questionnaires) #daily use of cosmetics questionnaires$dailyPORTIONScosm<-dailyPORTIONScosm(questionnaires) #weekly use of cosmetics questionnaires$weekPORTIONScosm<-weekPORTIONScosm(questionnaires) #Get a short version of the questionnaire questionnaires_SHRT<-questionnaires[,c(quest_analysis_vars)] #split by country to be used separately in the respective analyses CY_quest_SHRT<-questionnaires_SHRT[which(questionnaires_SHRT$country=='CY'),] summary(CY_quest_SHRT) RO_quest_SHRT<-questionnaires_SHRT[which(questionnaires_SHRT$country=="RO"),] summary(RO_quest_SHRT) ``` ``` {r DFs_merge, echo=FALSE, include=FALSE} #merge the measurements with the questionnaire CY_SHRT<-merge(CY_quest_SHRT, CY_meas_SHRT) RO_SHRT<-merge(RO_quest_SHRT, RO_meas_SHRT) SHRT<-rbind.fill(CY_SHRT, RO_SHRT) ``` ```{r BoxQQplotsShapiroCODE, echo=FALSE, warning=FALSE} #normality test #get only numeric variables of the measurement_data df to perform the shapiro test norm_test_df<-sapply(SHRT, is.numeric) norm_test_df2<-SHRT[,norm_test_df] df.shapiro<-lapply(norm_test_df2,shapiro.test) #Check for normality - using boxplots and QQplots #get the raw urine variables raw_vars<-SHRT[ ,c("CODE", urine_levs_vars)] #melt the raw markers dataframe to make the QQplots raw_vars_melt<-melt(raw_vars) #the status used as id variables raw_vars_melt$ln_value<-log(raw_vars_melt$value) raw_vars_ggplot<-ggplot(data=raw_vars_melt)+ facet_wrap(~variable, scales="free",ncol=6)+ theme(text=element_text(size=12),title=element_text(size=16,face="bold")) #get the raw hormone variables horm_raw_vars<-SHRT[ ,c("CODE", c(horm_vars_iod_sp,"iod_ugPERlt_morn","iod_ugPERg_spot","iod_ugPERg_morn"))] horm_raw_vars_melt<-melt(horm_raw_vars) horm_raw_vars_melt$ln_value<-log(horm_raw_vars_melt$value) horm_raw_vars_ggplot<-ggplot(data=horm_raw_vars_melt)+ facet_wrap(~variable, scales="free",ncol=2)+ theme(text=element_text(size=12),title=element_text(size=16,face="bold")) ``` ```{r BoxQQplotsFIG, echo=FALSE, include=FALSE, fig.width=12, fig.height=8, warning=FALSE} kable(t(sapply(df.shapiro, '[', c("statistic","p.value"))), caption="Shapiro test for normality results.") writeLines("Boxplots for the compounds measured in urine\n") raw_vars_ggplot+geom_boxplot(mapping = aes(x=variable, y=value))+ggtitle("Non-transformed variables") raw_vars_ggplot+stat_qq(aes(sample=value))+ggtitle("Non-transformed variables") raw_vars_ggplot+geom_boxplot(mapping = aes(x=variable, y=ln_value))+ggtitle("Log-transformed variables") raw_vars_ggplot+stat_qq(aes(sample=ln_value))+ggtitle("Log-transformed variables") writeLines("Boxplots for the hormones and iodine levels") horm_raw_vars_ggplot+geom_boxplot(mapping = aes(x=variable, y=value))+ggtitle("Non-transformed variables") horm_raw_vars_ggplot+stat_qq(aes(sample=value))+ggtitle("Non-transformed variables") horm_raw_vars_ggplot+geom_boxplot(mapping = aes(x=variable, y=ln_value))+ggtitle("Log-transformed variables") horm_raw_vars_ggplot+stat_qq(aes(sample=ln_value))+ggtitle("Log-transformed variables") ``` ```{r SHRT_additional_cleanup, echo=FALSE, include=FALSE, warning=FALSE} #Make a big dataframe with the CY_SHRT and RO_SHRT to ln-transform the urine variables add the status01 variable and use in the stats where the whole population is needed #SHRT will be separated again as CY_log_SHRT and RO_log_SHRT to be used in the regressions and other stats where log variables are necessary #add the status01 SHRT$status01[SHRT$status=="CA"]<-"1" SHRT$status01[SHRT$status=="CO"]<-"0" SHRT$status01<-as.factor(SHRT$status01) #make the ln-transformed variables SHRT$ln_BPF_ngPERlt_spot<-log(SHRT$BPF_ngPERlt_spot) SHRT$ln_BPA_ngPERlt_spot<-log(SHRT$BPA_ngPERlt_spot) SHRT$ln_ClBPA_ngPERlt_spot<-log(SHRT$ClBPA_ngPERlt_spot) SHRT$ln_Cl35_2BPA_ngPERlt_spot<-log(SHRT$Cl35_2BPA_ngPERlt_spot) SHRT$ln_Cl33_2BPA_ngPERlt_spot<-log(SHRT$Cl33_2BPA_ngPERlt_spot) SHRT$ln_ClxBPA_ngPERlt_spot<-log(SHRT$ClxBPA_ngPERlt_spot) SHRT$ln_BPF_ngPERg_spot<-log(SHRT$BPF_ngPERg_spot) SHRT$ln_BPA_ngPERg_spot<-log(SHRT$BPA_ngPERg_spot) SHRT$ln_ClBPA_ngPERg_spot<-log(SHRT$ClBPA_ngPERg_spot) SHRT$ln_Cl35_2BPA_ngPERg_spot<-log(SHRT$Cl35_2BPA_ngPERg_spot) SHRT$ln_Cl33_2BPA_ngPERg_spot<-log(SHRT$Cl33_2BPA_ngPERg_spot) SHRT$ln_ClxBPA_ngPERg_spot<-log(SHRT$ClxBPA_ngPERg_spot) SHRT$ln_BPF_ngPERlt_morn<-log(SHRT$BPF_ngPERlt_morn) SHRT$ln_BPA_ngPERlt_morn<-log(SHRT$BPA_ngPERlt_morn) SHRT$ln_ClBPA_ngPERlt_morn<-log(SHRT$ClBPA_ngPERlt_morn) SHRT$ln_Cl35_2BPA_ngPERlt_morn<-log(SHRT$Cl35_2BPA_ngPERlt_morn) SHRT$ln_Cl33_2BPA_ngPERlt_morn<-log(SHRT$Cl33_2BPA_ngPERlt_morn) SHRT$ln_ClxBPA_ngPERlt_morn<-log(SHRT$ClxBPA_ngPERlt_morn) SHRT$ln_BPF_ngPERg_morn<-log(SHRT$BPF_ngPERg_morn) SHRT$ln_BPA_ngPERg_morn<-log(SHRT$BPA_ngPERg_morn) SHRT$ln_ClBPA_ngPERg_morn<-log(SHRT$ClBPA_ngPERg_morn) SHRT$ln_Cl35_2BPA_ngPERg_morn<-log(SHRT$Cl35_2BPA_ngPERg_morn) SHRT$ln_Cl33_2BPA_ngPERg_morn<-log(SHRT$Cl33_2BPA_ngPERg_morn) SHRT$ln_ClxBPA_ngPERg_morn<-log(SHRT$ClxBPA_ngPERg_morn) SHRT$ln_tsh<-log(SHRT$tsh) SHRT$ln_ft4<-log(SHRT$ft4) SHRT$ln_iod_ugPERlt_spot<-log(SHRT$iod_ugPERlt_spot) SHRT$ln_iod_ugPERg_spot<-log(SHRT$iod_ugPERg_spot) SHRT$ln_iod_ugPERlt_morn<-log(SHRT$iod_ugPERlt_morn) SHRT$ln_iod_ugPERg_morn<-log(SHRT$iod_ugPERg_morn) SHRT$ln_creat_gPERlt_spot<-log(SHRT$creat_gPERlt_spot) SHRT$ln_creat_gPERlt_morn<-log(SHRT$creat_gPERlt_morn) summary(SHRT) CY_log_SHRT<-SHRT[which(SHRT$country=='CY'),] #summary(CY_log_SHRT) RO_log_SHRT<-SHRT[which(SHRT$country=="RO"),] #summary(RO_log_SHRT) ``` ```{r CountryDFs_DEMO, echo=FALSE, include=FALSE, warning=TRUE} #CY #categories for TSH and fT4 CY_SHRT$tsh_cat=(cut(CY_SHRT$tsh, breaks=c(0,0.399,3.999,Inf), labels=c("<0.4","0.4-4",">4"))) CY_SHRT$ft4_cat=(cut(CY_SHRT$ft4, breaks=c(0,9.999,23.999,Inf), labels=c("<10","10-24",">24"))) #tables with the descriptives overall and by status CY_demo_overall<-CreateTableOne(vars=demo_vars, data=CY_SHRT) CY_demo_by_status<-CreateTableOne(vars=demo_vars, strata=c("status"), data=CY_SHRT) CY_expo_overall<-CreateTableOne(vars=expo_vars, data=CY_SHRT) CY_expo_by_status<-CreateTableOne(vars=expo_vars, strata=c("status"), data=CY_SHRT) ###WORKING ON RO #categories for TSH and fT4 RO_SHRT$tsh_cat=(cut(RO_SHRT$tsh, breaks=c(0,0.2799,4.1999,Inf), labels=c("<0.27","0.27-4.2",">4.2"))) RO_SHRT$ft4_cat=(cut(RO_SHRT$ft4, breaks=c(0,10.699,22.699,Inf), labels=c("<10.6","10.6-22.7",">22.7"))) #tables with the descriptives overall and by status RO_demo_overall<-CreateTableOne(vars=demo_vars, data=RO_SHRT) RO_demo_by_status<-CreateTableOne(vars=demo_vars,strata=c("status"), data=RO_SHRT) RO_expo_overall<-CreateTableOne(vars=expo_vars, data=RO_SHRT) RO_expo_by_status<-CreateTableOne(vars=expo_vars, strata=c("status"), data=RO_SHRT) CY1=print(CY_demo_overall) CY1_status=print(CY_demo_by_status, exact= c("BMI_cat","alccons", "marstat","edu")) CY2=print(CY_expo_overall, nonnormal = expo_vars) CY2_status=print(CY_expo_by_status, nonnormal = expo_vars) RO1=print(RO_demo_overall) RO1_status=print(RO_demo_by_status, exact= c("BMI_cat","alccons", "marstat","edu"))# RO2=print(RO_expo_overall, nonnormal = expo_vars) RO2_status=print(RO_expo_by_status, nonnormal = expo_vars) ``` ```{r CountryDFs_HORM, echo=FALSE, include=FALSE} #CY #note: the CY hormones descriptive table included also the iodine for the morning samples and the comparisons CY_horm_table<-CreateContTable(c(horm_vars_iod_sp, "iod_ugPERlt_morn","iod_ugPERg_spot", "iod_ugPERg_morn"),data=CY_SHRT) CY_horm_table_by_status<-CreateContTable(c(horm_vars_iod_sp, "iod_ugPERlt_morn","iod_ugPERg_spot", "iod_ugPERg_morn"),strata=c("status"),data=CY_SHRT) #added to make table 1 -160822 CY_horm_table_spot<-CreateContTable(c(horm_vars_iod_sp, "iod_ugPERg_spot"),data=CY_SHRT) CY_horm_table_by_status_spot<-CreateContTable(c(horm_vars_iod_sp, "iod_ugPERg_spot"),strata=c("status"),data=CY_SHRT) CY_horm_cat_table<-CreateCatTable(horm_vars_cat,data=CY_SHRT) CY_horm_cat_table_by_status<-CreateCatTable(horm_vars_cat,strata=c("status"),data=CY_SHRT) #RO RO_horm_table<-CreateContTable(c(horm_vars_iod_sp,"iod_ugPERg_spot"),data=RO_SHRT) RO_horm_table_by_status<-CreateContTable(c(horm_vars_iod_sp,"iod_ugPERg_spot"),strata=c("status"),data=RO_SHRT) RO_horm_cat_table<-CreateCatTable(horm_vars_cat,data=RO_SHRT) RO_horm_cat_table_by_status<-CreateCatTable(horm_vars_cat,strata=c("status"),data=RO_SHRT) ``` # Cyprus ```{r CY_hormdescr, echo=FALSE, include=FALSE} CY_horm_kable=print(CY_horm_table, nonnormal = c(horm_vars_iod_sp, "iod_ugPERlt_morn","iod_ugPERg_spot", "iod_ugPERg_morn")) CY_horm_status_kable=print(CY_horm_table_by_status, nonnormal = c(horm_vars_iod_sp, "iod_ugPERlt_morn","iod_ugPERg_spot", "iod_ugPERg_morn")) #added to make table 1 CY_horm_spot_kable=print(CY_horm_table_spot, nonnormal = c(horm_vars_iod_sp, "iod_ugPERg_spot")) CY_horm_status_spot_kable=print(CY_horm_table_by_status_spot, nonnormal = c(horm_vars_iod_sp, "iod_ugPERg_spot")) CY_horm_cat_kable=print(CY_horm_cat_table) CY_horm_cat_status_kable=print(CY_horm_cat_table_by_status) ``` ```{r CY_HormPlots, fig.width=6, fig.height=3,echo=FALSE, include=TRUE, fig.show='asis', warning=FALSE} #hormone boxplots CY_TSH<-ggplot(CY_SHRT, aes(factor(status), tsh, fill=status)) CY_TSH+geom_boxplot()+ labs(x="Status", y="TSH, mIU/L", title="TSH levels (CY)")+ geom_hline(aes(yintercept=0.4), color="green")+ geom_hline(aes(yintercept=4), color="green")+ theme(text = element_text(size=20)) CY_FT4<-ggplot(CY_SHRT, aes(factor(status), ft4,fill=status)) CY_FT4+geom_boxplot()+ labs(x="Status", y="FT4, pmol/L", title="FT4 levels (CY)")+ geom_hline(aes(yintercept=10), color="orange")+ geom_hline(aes(yintercept=24), color="orange")+ theme(text = element_text(size=20)) ``` ```{r CY_UrineMeasDescriptivesCODE, echo=FALSE, include=FALSE, hide=TRUE,warning=FALSE} #Urine measurements analysis #CY CY_urine_lev_table<-CreateContTable(c(urine_levs_vars), funcAdditional = list(gm=gm_func, gsd=gsd_func), data=CY_SHRT) CY_Urine_lev_table_by_status<-CreateContTable(c(urine_levs_vars), funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("status"), data=CY_SHRT) CY_U1=print(CY_urine_lev_table, nonnormal= c(urine_levs_vars)) CY_U2=print(CY_Urine_lev_table_by_status, nonnormal=c(urine_levs_vars)) CY_urine_lev_table_spot<-CreateContTable(urine_levs_vars[c(1:12)], funcAdditional = list(gm=gm_func, gsd=gsd_func), data=CY_SHRT) CY_Urine_lev_table_spot_by_status<-CreateContTable(urine_levs_vars[c(1:12)], funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("status"), data=CY_SHRT) CY_U1_spot=print(CY_urine_lev_table_spot, nonnormal= c(urine_levs_vars)) CY_U2_spot=print(CY_Urine_lev_table_spot_by_status, nonnormal=c(urine_levs_vars)) ``` ```{r SampleTypeReprod, echo=FALSE, include=FALSE, warning=FALSE} ###ONLY FOR CY #PAIRED COMPARISON - WITH T-TEST - BETWEEN THE MORNING AND THE SPOT SAMPLES #ICC CALCULATION #------------------ ln_BPF_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_BPF_ngPERlt_spot","ln_BPF_ngPERlt_morn")] ln_BPF_df_ngPERlt_melt<-melt(ln_BPF_df_ngPERlt, value.name="ln_BPF_ngPERlt", variable.name="BPF1_sample_type") ln_BPA_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_BPA_ngPERlt_spot","ln_BPA_ngPERlt_morn")] ln_BPA_df_ngPERlt_melt<-melt(ln_BPA_df_ngPERlt, value.name="ln_BPA_ngPERlt", variable.name="BPA1_sample_type") ln_ClBPA_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_ClBPA_ngPERlt_spot","ln_ClBPA_ngPERlt_morn")] ln_ClBPA_df_ngPERlt_melt<-melt(ln_ClBPA_df_ngPERlt, value.name="ln_ClBPA_ngPERlt", variable.name="ClBPA1_sample_type") ln_Cl35_2BPA_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_Cl35_2BPA_ngPERlt_spot","ln_Cl35_2BPA_ngPERlt_morn")] ln_Cl35_2BPA_df_ngPERlt_melt<-melt(ln_Cl35_2BPA_df_ngPERlt, value.name="ln_Cl35_2BPA_ngPERlt", variable.name="Cl35_2BPA1_sample_type") ln_Cl33_2BPA_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_Cl33_2BPA_ngPERlt_spot","ln_Cl33_2BPA_ngPERlt_morn")] ln_Cl33_2BPA_df_ngPERlt_melt<-melt(ln_Cl33_2BPA_df_ngPERlt, value.name="ln_Cl33_1BPA_ngPERlt", variable.name="Cl33_2BPA1_sample_type") ln_ClxBPA_df_ngPERlt<-CY_log_SHRT[ ,c("status","CODE","ln_ClxBPA_ngPERlt_spot","ln_ClxBPA_ngPERlt_morn")] ln_ClxBPA_df_ngPERlt_melt<-melt(ln_ClxBPA_df_ngPERlt, value.name="ln_ClxBPA_ngPERlt", variable.name="ClxBPA1_sample_type") ln_BPF_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_BPF_ngPERg_spot","ln_BPF_ngPERg_morn")] ln_BPF_df_ngPERg_melt<-melt(ln_BPF_df_ngPERg, value.name="ln_BPF_ngPERg", variable.name="BPF2_sample_type") ln_BPA_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_BPA_ngPERg_spot","ln_BPA_ngPERg_morn")] ln_BPA_df_ngPERg_melt<-melt(ln_BPA_df_ngPERg, value.name="ln_BPA_ngPERg", variable.name="BPA2_sample_type") ln_ClBPA_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_ClBPA_ngPERg_spot","ln_ClBPA_ngPERg_morn")] ln_ClBPA_df_ngPERg_melt<-melt(ln_ClBPA_df_ngPERg, value.name="ln_ClBPA_ngPERg", variable.name="ClBPA2_sample_type") ln_Cl35_2BPA_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_Cl35_2BPA_ngPERg_spot","ln_Cl35_2BPA_ngPERg_morn")] ln_Cl35_2BPA_df_ngPERg_melt<-melt(ln_Cl35_2BPA_df_ngPERg, value.name="ln_Cl35_2BPA_ngPERg", variable.name="Cl35_2BPA2_sample_type") ln_Cl33_2BPA_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_Cl33_2BPA_ngPERg_spot","ln_Cl33_2BPA_ngPERg_morn")] ln_Cl33_2BPA_df_ngPERg_melt<-melt(ln_Cl33_2BPA_df_ngPERg, value.name="ln_Cl33_2BPA_ngPERg", variable.name="Cl33_2BPA2_sample_type") ln_ClxBPA_df_ngPERg<-CY_log_SHRT[ ,c("status","CODE","ln_ClxBPA_ngPERg_spot","ln_ClxBPA_ngPERg_morn")] ln_ClxBPA_df_ngPERg_melt<-melt(ln_ClxBPA_df_ngPERg, value.name="ln_ClxBPA_ngPERg", variable.name="ClxBPA2_sample_type") ICC_df<-cbind(ln_BPF_df_ngPERlt_melt, ln_BPA_df_ngPERlt_melt, ln_ClBPA_df_ngPERlt_melt, ln_Cl35_2BPA_df_ngPERlt_melt, ln_Cl33_2BPA_df_ngPERlt_melt, ln_ClxBPA_df_ngPERlt_melt, ln_BPF_df_ngPERg_melt, ln_BPA_df_ngPERg_melt, ln_ClBPA_df_ngPERg_melt, ln_Cl35_2BPA_df_ngPERg_melt, ln_Cl33_2BPA_df_ngPERg_melt, ln_ClxBPA_df_ngPERg_melt) ICC_df$sample_type[ICC_df$BPF1_sample_type=="ln_BPF_ngPERlt_spot"]<-"spot" ICC_df$sample_type[ICC_df$BPF1_sample_type=="ln_BPF_ngPERlt_morn"]<-"morning" ICC_df2<-ICC_df[,c(1,2,4,8,12,16,20,24,28,32,36,40,44,48,49)] ICCest_participant_S<-t(sapply(ICC_df2[c(-1,-2,-15)], function(x) unlist(ICCest(ICC_df2$CODE, x, alpha=0.05, CI.type="S")[c("ICC","LowerCI","UpperCI")]))) ``` ```{r PairedTests,echo=FALSE, include=TRUE, hide=TRUE, warning=FALSE} #Paired t_tests paired_t_test<- function (var1, var2) {unlist(t.test(var1, var2, paired = TRUE, na.rm=TRUE)[c("method","p.value")])} #ngPERlt BPF_ngPERlt<-paired_t_test(CY_log_SHRT$ln_BPF_ngPERlt_spot, CY_log_SHRT$ln_BPF_ngPERlt_morn) BPA_ngPERlt<-paired_t_test(CY_log_SHRT$ln_BPA_ngPERlt_spot, CY_log_SHRT$ln_BPA_ngPERlt_morn) ClBPA_ngPERlt<-paired_t_test(CY_log_SHRT$ln_ClBPA_ngPERlt_spot, CY_log_SHRT$ln_ClBPA_ngPERlt_morn) Cl35_2BPA_ngPERlt<-paired_t_test(CY_log_SHRT$ln_Cl35_2BPA_ngPERlt_spot, CY_log_SHRT$ln_Cl35_2BPA_ngPERlt_morn) Cl33_2BPA_ngPERlt<-paired_t_test(CY_log_SHRT$ln_Cl33_2BPA_ngPERlt_spot, CY_log_SHRT$ln_Cl33_2BPA_ngPERlt_morn) ClxBPA_ngPERlt<-paired_t_test(CY_log_SHRT$ln_ClxBPA_ngPERlt_spot, CY_log_SHRT$ln_ClxBPA_ngPERlt_morn) #ngPERg BPF_ngPERg<-paired_t_test(CY_log_SHRT$ln_BPF_ngPERg_spot, CY_log_SHRT$ln_BPF_ngPERg_morn) BPA_ngPERg<-paired_t_test(CY_log_SHRT$ln_BPA_ngPERg_spot, CY_log_SHRT$ln_BPA_ngPERg_morn) ClBPA_ngPERg<-paired_t_test(CY_log_SHRT$ln_ClBPA_ngPERg_spot, CY_log_SHRT$ln_ClBPA_ngPERg_morn) Cl35_2BPA_ngPERg<-paired_t_test(CY_log_SHRT$ln_Cl35_2BPA_ngPERg_spot, CY_log_SHRT$ln_Cl35_2BPA_ngPERg_morn) Cl33_2BPA_ngPERg<-paired_t_test(CY_log_SHRT$ln_Cl33_2BPA_ngPERg_spot, CY_log_SHRT$ln_Cl33_2BPA_ngPERg_morn) ClxBPA_ngPERg<-paired_t_test(CY_log_SHRT$ln_ClxBPA_ngPERg_spot, CY_log_SHRT$ln_ClxBPA_ngPERg_morn) CY_pooled_paired_t_test<-rbind(BPF_ngPERlt, BPA_ngPERlt, ClBPA_ngPERlt, Cl35_2BPA_ngPERlt, Cl33_2BPA_ngPERlt, ClxBPA_ngPERlt, BPF_ngPERg, BPA_ngPERg, ClBPA_ngPERg, Cl35_2BPA_ngPERg, Cl33_2BPA_ngPERg, ClxBPA_ngPERg) #separate cases and controls CA_CY_log_SHRT<-CY_log_SHRT[which(CY_log_SHRT$status=='CA'),] CO_CY_log_SHRT<-CY_log_SHRT[which(CY_log_SHRT$status=='CO'),] ``` ## Table S4 ```{r CY_UrineMeasDescriptives_paired_ICC, echo=FALSE, include=TRUE, warning=FALSE} #printing the descriptives kable(summary(CY_urine_lev_table), caption="CY - Summary of the urinary levels (all participants)") #printing the ICC and paired t-tests writeLines("Note: All the t-tests have been applied to the ln-transformed concentrations") kable(cbind(CY_pooled_paired_t_test, ICCest_participant_S), caption = "Paired t-test p-values and ICC - spot and morning samples - CY (pooled population) - Table S4") ``` # Romania ```{r RO_hormdescr, echo=FALSE, include=FALSE} RO_horm_kable=print(RO_horm_table, nonnormal = c(horm_vars_iod_sp,"iod_ugPERg_spot")) RO_horm_status_kable=print(RO_horm_table_by_status, nonnormal = c(horm_vars_iod_sp,"iod_ugPERg_spot")) RO_horm_cat_kable=print(RO_horm_cat_table) RO_horm_cat_status_kable=print(RO_horm_cat_table_by_status) ``` ```{r RO_HormPlots, fig.width=6, fig.height=3,echo=FALSE, include=TRUE, fig.show='asis', warning=FALSE} RO_TSH<-ggplot(RO_SHRT, aes(factor(status), tsh, fill=status)) RO_TSH+geom_boxplot()+ labs(x="Status", y="TSH, mIU/L", title="TSH levels (RO)")+ geom_hline(aes(yintercept=0.27), color="green")+ geom_hline(aes(yintercept=4.2), color="green")+ theme(text = element_text(size=20)) RO_FT4<-ggplot(RO_SHRT, aes(factor(status), ft4,fill=status)) RO_FT4+geom_boxplot()+ labs(x="Status", y="FT4, pmol/L", title="FT4 levels (RO)")+ geom_hline(aes(yintercept=10.6), color="orange")+ geom_hline(aes(yintercept=22.7), color="orange")+ theme(text = element_text(size=20)) ``` ```{r RO_UrineMeasDescriptivesCODE, echo=FALSE, include=FALSE, hide=TRUE,warning=FALSE} #Urine measurements analysis RO_urine_lev_table<-CreateContTable(urine_levs_vars,funcAdditional = list(gm=gm_func, gsd=gsd_func), data=RO_SHRT) RO_Urine_lev_table_by_status<-CreateContTable(urine_levs_vars,funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("status"), data=RO_SHRT) RO_U1=print(RO_urine_lev_table, nonnormal=c(urine_levs_vars))#kable(RO_U1, caption="RO - Summary of the urinary levels (all participants)") RO_U2=print(RO_Urine_lev_table_by_status, nonnormal=c(urine_levs_vars))#kable(RO_U2, caption="RO - Summary of the urinary levels (by status)") ``` # Working on the both countries (pooled population) ```{r PooledPopulation, echo=FALSE, include=FALSE, hide=TRUE, warning=FALSE} #table with the descriptives overall and by status SHRT_demo_overall<-CreateTableOne(vars=demo_vars, data=SHRT) SHRT_demo_by_status<-CreateTableOne(vars=demo_vars, strata=c("status"), data=SHRT) SHRT_demo_by_country<-CreateTableOne(vars=demo_vars, strata=c("country"), data=SHRT) #table with the descriptives overall and by status SHRT_expo_overall<-CreateTableOne(vars=expo_vars, data=SHRT) SHRT_expo_by_status<-CreateTableOne(vars=expo_vars, strata=c("status"), data=SHRT) SHRT_expo_by_country<-CreateTableOne(vars=expo_vars, strata=c("country"), data=SHRT) #separate cases and controls CA_SHRT<-SHRT[which(SHRT$status=='CA'),] CO_SHRT<-SHRT[which(SHRT$status=="CO"),] CreateTableOne(data=CA_SHRT) CreateTableOne(data=CO_SHRT) #Hormone and urine levels descriptives pooled population and by status (in the pooled) horm_table<-CreateContTable(c(horm_vars_iod_sp,"iod_ugPERg_spot"),data=SHRT) horm_table_by_status<-CreateContTable(c(horm_vars_iod_sp,"iod_ugPERg_spot"),strata=c("status"),data=SHRT) horm_table_by_country<-CreateContTable(c(horm_vars_iod_sp,"iod_ugPERg_spot"),strata=c("country"),data=SHRT) horm_cat_table<-CreateCatTable(horm_vars_cat,data=SHRT) horm_cat_table_by_status<-CreateCatTable(horm_vars_cat,strata=c("status"),data=SHRT) horm_cat_table_by_country<-CreateCatTable(horm_vars_cat,strata=c("country"),data=SHRT) urine_lev_table<-CreateContTable(urine_levs_vars[c(1:12)],funcAdditional = list(gm=gm_func, gsd=gsd_func), data=SHRT) urine_lev_status_table<-CreateContTable(urine_levs_vars [c(1:12)],funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("status"),data=SHRT) urine_lev_country_table<-CreateContTable(urine_levs_vars [c(1:12)],funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("country"),data=SHRT) ### making tables by status with country comparison #for the cases CASES_country_table<-CreateContTable(urine_levs_vars[c(1:12)],funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("country"), data=CA_SHRT) #for the controls CONTROLS_country_table<-CreateContTable(urine_levs_vars [c(1:12)],funcAdditional = list(gm=gm_func, gsd=gsd_func), strata=c("country"),data=CO_SHRT) ``` ## Descriptives and comparisons - demographics, hormones, iodine and urinary levels of BPA, BPF, ClxBPA ```{r descrtables, echo=FALSE, include=FALSE, hide=TRUE} SH1=print(SHRT_demo_overall) SH1_status=print(SHRT_demo_by_status, exact= c("BMI_cat","alccons", "marstat","edu")) SH1_country=print(SHRT_demo_by_country, exact= c("BMI_cat","alccons", "marstat","edu")) SH2=print(SHRT_expo_overall, nonnormal = expo_vars) SH2_status=print(SHRT_expo_by_status, nonnormal = expo_vars) SH2_country=print(SHRT_expo_by_country, nonnormal = expo_vars) SH3=print(horm_table, nonnormal =c( horm_vars_iod_sp, "iod_ugPERg_spot")) SH3_status=print(horm_table_by_status, nonnormal =c(horm_vars_iod_sp, "iod_ugPERg_spot")) SH3_country=print(horm_table_by_country, nonnormal =c(horm_vars_iod_sp, "iod_ugPERg_spot")) SH4=print(horm_cat_table) SH4_status=print(horm_cat_table_by_status) SH4_country=print(horm_cat_table_by_country) SH5=print(urine_lev_table, nonnormal=c(urine_levs_vars)) SH5_status=print(urine_lev_status_table, nonnormal=c(urine_levs_vars)) SH5_country=print(urine_lev_country_table, nonnormal=c(urine_levs_vars)) SH6=print(CASES_country_table, nonnormal=c(urine_levs_vars)) SH7=print(CONTROLS_country_table, nonnormal=c(urine_levs_vars)) ``` ### Table 1, Table S1, Table S3 ```{r SHRTComparisonsPRINT, echo=FALSE, include=TRUE, warning=FALSE} #Overall table 1 kable(cbind(SH1, SH1_status, CY1, CY1_status, RO1, RO1_status), caption="Demographics (all study population - by status and in the two countries - Table 1)") kable(cbind(SH3, SH3_status, CY_horm_spot_kable, CY_horm_status_spot_kable, RO_horm_kable, RO_horm_status_kable), caption="Hormone and iodine (all study population - by status and in the two countries) - Table 1") kable(cbind(SH5, SH5_status, CY_U1_spot, CY_U2_spot, RO_U1, RO_U2), caption="BPA, BPF, ClxBPA (all study population - by status and in the two countries) - Table 1") kable(cbind(SH2,SH2_status, CY2, CY2_status, RO2, RO2_status), caption="Determinants of exposure (all study population - by status and in the two countries) - Table S1") kable(cbind(SH4, SH4_status, SH4_country), caption="Antibodies (all study population) - Table S2") kable(SH5_country, caption="BPA, BPF, ClxBPA - by country - Table S3") kable(SH1_country, caption="Demographics by country") kable(SH2_country, caption="Determinants of exposure by country") kable(SH3_country, caption="Hormones and iodine levels by country") ``` ## Logistic regressions ```{r PooledRegressions_UNI, echo=FALSE, include=TRUE, results='asis', warning=FALSE} #Regressions #univariate - simple demo_vars_uni_models<-lapply(c(demo_vars[-5]), function(x) LR_status01_x1(x, SHRT)) expo_vars_uni_models<-lapply(c(expo_vars), function(x) LR_status01_x1(x, SHRT)) horm_vars_iod_sp_uni_models<-lapply(c("ln_tsh","ln_ft4","ln_iod_ugPERlt_spot"), function(x) LR_status01_x1(x, SHRT)) ln_vars_spot_uni_models_CR<-lapply(c(ln_vars_spot[c(2,1,6)]), function(x) LR_status01_x1_spot_CR(x, SHRT)) #univariate - simple AND country adjustment demo_vars_uni_country_models<-lapply(c(demo_vars[-5]), function(x) LR_status01_x1_country(x, SHRT)) expo_vars_uni_country_models<-lapply(c(expo_vars), function(x) LR_status01_x1_country(x, SHRT)) horm_vars_iod_sp_uni_country_models<-lapply(c("ln_tsh","ln_ft4","ln_iod_ugPERlt_spot"), function(x) LR_status01_x1_country(x, SHRT)) ln_vars_spot_uni_country_models_CR<-lapply(c(ln_vars_spot[c(2,1,6)]), function(x) LR_status01_x1_country_CR(x, SHRT)) ``` ### Table S6, Table S7 * Demographics - table S6 - A `r sjt.glm(c(demo_vars_uni_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` * Questionnaire exposures - table S6 - A `r sjt.glm(c(expo_vars_uni_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` * Hormone levels and iodine - table S6 - A `r sjt.glm(c(horm_vars_iod_sp_uni_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` Study-site adjusted univariate logistic regression * Demographics - table S6 - B `r sjt.glm(c(demo_vars_uni_country_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` * Questionnaire exposures - table S6 - B `r sjt.glm(c(expo_vars_uni_country_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` * Hormone levels and iodine - table S6 - B `r sjt.glm(c(horm_vars_iod_sp_uni_country_models),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` * BPF, BPA and ClxBPA - table S7 `r sjt.glm(c(ln_vars_spot_uni_country_models_CR),group.pred = FALSE, showLogLik = TRUE, showAIC = TRUE, showFamily = TRUE, no.output = TRUE)$knitr` ```{r 5to95df, echo=FALSE, include=FALSE} #function for the 5-95 percentiles gettherange<-function(x){ top=quantile(x, 0.95 ,na.rm=TRUE) bottom=quantile(x, 0.05 ,na.rm=TRUE) x[x>top|xtop|x