
library(grid)
library(forestplot)
library(tidyverse)
library(lubridate)
library(dplyr)
dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFOAM2.csv",header=F,sep=",",na.strings = "")
data2<-dat[-1,2:13]
A1<-data2[3,12]
data2[3,12]<-data2[3,11]
data2[3,11]<-A1

datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])

pdf("E:/BaiduSyncdisk/nhanes2023/PFOAM2 .pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
              legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()
# 构建数据
dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFNAM2.csv",header=F,sep=",",na.strings = "")
data2<-dat[-1,2:13]
A1<-data2[3,12]
data2[3,12]<-data2[3,11]
data2[3,11]<-A1
datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])

pdf("E:/BaiduSyncdisk/nhanes2023/PFNAM2 .pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
            legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()
# 构建数据

dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFOSM2.csv",header=F,sep=",",na.strings = "")

data2<-dat[-1,2:13]
A1<-data2[3,12]
data2[3,12]<-data2[3,11]
data2[3,11]<-A1
datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])
pdf("E:/BaiduSyncdisk/nhanes2023/PFOSM2 .pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
            legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()
# 构建数据


dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFASM2.csv",header=F,sep=",",na.strings = "")
data2<-dat[-1,2:13]
A1<-data2[3,12]
data2[3,12]<-data2[3,11]
data2[3,11]<-A1

datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])
pdf("E:/BaiduSyncdisk/nhanes2023/PFASM2 .pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
            legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()


dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFHSM2.csv",header=F,sep=",",na.strings = "")
data2<-dat[-1,2:13]

datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])
pdf("E:/BaiduSyncdisk/nhanes2023/PFHSM2 .pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
            legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()


dat<-read.csv("E:/BaiduSyncdisk/nhanes2023/MAPFDAM2.csv",header=F,sep=",",na.strings = "")

data2<-dat[-1,2:13]
A1<-data2[5,5]
data2[5,5]<-data2[5,6]
data2[5,6]<-A1
datana<-c(NA,NA,NA)
data3<-rbind(datana,data2)
data4<-as.data.frame(dat[,1:4])
pdf("E:/BaiduSyncdisk/nhanes2023/PFDAM2.pdf",width =5.15, height =10)
forestplot( as.matrix(dat[,c(1,14)]),mean=data3[,c(1,4,7,10)], lower=data3[,c(2,5,8,11)], upper=data3[,c(3,6,9,12)],
            txt_gp=fpTxtGp(label=list(gpar(cex = 0.7,fontface=2),gpar(cex = 0.7),gpar(cex = 0.7),gpar(cex = 0.7)),ticks=gpar(cex=0.7),xlab=gpar(cex = 0.7),title=gpar(cex = 1.2)),
            legend = c("ALL","DII1", "DII2","DII3"),
            graph.pos= 2, graphwidth = unit(50,"mm"),graphheight= unit(250,"mm") , 
            boxsize=0.15, line.margin=unit(2,"mm"),lwd.ci = 2,lty.zero=2,lwd.zero=0.5,
            lineheight = unit(12,'mm'), colgap = unit(8,"mm"), zero=0, xticks = c(0.2,-0.1,0,0.1,0.2),
            col = fpColors(box = c("BLACK","#32B897", "#FFA500","#F27970" ),line = c("BLACK","#32B897", "#FFA500","#F27970" )))
dev.off()