# Load required libraries
library(ggplot2)
library(dplyr)

# Create sample data
set.seed(123)
data<-read.table(file = "E:/BaiduSyncdisk/nhanes2023/DATA FIGURE2 M2.csv" ,header=T,sep=",")
data$var[data$var=="DII"]<-"ZDII"
data<-data[data$p.val<0.05,]
data$P_Value_Transformed <- -as.numeric(data$p.val)
color_range <- colorRampPalette(c("#32B897", "#FFA500","#F27970" ))(n = 30)
pdf("E:/BaiduSyncdisk/nhanes2023/FIGURE2M2 FOR GA.pdf",width =9.97/1.3, height =7.11/1.3)
ggplot(data, aes(x = OUTCOME, y = var)) +
  geom_point(aes(size = P_Value_Transformed , color = B), shape = 16) +
  scale_color_gradientn(colours = color_range, limits = range(data$B), breaks = pretty(data$B, n = 5)) +
  scale_size(range = c(2, 7)) +
  theme_bw() +
  labs(x = "PFAS", y = "Food parameters", color = "¦Â", size = "P-value")
dev.off()

# Load required libraries
library(ggplot2)
library(dplyr)

# Create sample data
set.seed(123)
data<-read.table(file = "E:/BaiduSyncdisk/nhanes2023/DATA FIGURE2 M1.csv" ,header=T,sep=",")
data$var[data$var=="DII"]<-"ZDII"
data<-data[data$p.val<0.05,]
data$P_Value_Transformed <- -as.numeric(data$p.val)
color_range <- colorRampPalette(c("#32B897", "#FFA500","#F27970" ))(n = 30)
pdf("E:/BaiduSyncdisk/nhanes2023/FIGURE2M1.pdf",width =8, height =5)
ggplot(data, aes(x = OUTCOME, y = var)) +
  geom_point(aes(size = P_Value_Transformed , color = B), shape = 16) +
  scale_color_gradientn(colours = color_range, limits = range(data$B), breaks = pretty(data$B, n = 5)) +
  scale_size(range = c(2, 7)) +
  theme_bw() +
  labs(x = "PFAS", y = "Food parameters", color = "¦Â", size = "P-value")
dev.off()

