Sometimes the markers overlap too much with each other. This script produces an example of where the markers overlap/ are too squished together:
rm(list=ls())
setwd("/ForestPlots/R/")
source("/ForestPlots/R/forest_plots_helper_functions.R")
source("/ForestPlots/R/many_exp_many_out.R")
source("/ForestPlots/R/one_exp_many_out.R")
memodata <- read.delim("~/ForestPlots/inst/data/lungcancer.txt", as.is = TRUE)
Res<-memodata[memodata$subtype=="adenocarcinoma",]
Res<-Res[Res$Phenotype!="Smoking",]
Res$Phenotype<-gsub("^\s+|\s+$", "", Res$Phenotype) #remove leading and trailing white space from phenotype column
Res$subcat<-"Other risk factors"
Res$subcat[Res$Phenotype %in% c("Alpha-tocopherol",
"Beta-Carotene" ,
"Bilirubin",
"Calcium",
"Homocysteine",
"Iron",
"kynurenine",
"Magnesium",
"methionine",
"Retinol",
"Selenium",
"tryptophan",
"Vitamin B12",
"Vitamin B6",
"Vitamin D",
"Vitamin E")]<-"Vitamins and minerals"
Res$subcat[Res$Phenotype=="Smoking"] <-"Smoking"
Res$subcat[Res$Phenotype %in% c("Birth weight","body mass index","height","hip circumference","waist circumference","weight","waist-to-hip ratio")]<-"Anthropometrics"
Res$subcat[Res$Phenotype %in% c("FEV","Chronic bronchitis and chronic obstructive pulmonary disease","asthma")]<-"lung disease/function"
Res$subcat[Res$Phenotype %in% c("2hr glucose","Total cholesterol","CRP","fasting glucose","HDL cholesterol","MUFA","PUFA","Tot.FA")]<-"Metabolic biomarkers"
#Order the risk factors; plot function will use the order in the data
Res$order<-2
Res$order[Res$Phenotype=="Smoking"]<-1
Res$order[Res$subcat=="Other risk factors"]<-3
Res<-Res[order(Res$order),]
Res$colour_col=1
one_exp_many_out(inpt_Df = Res, eff_Col = "Beta", se_Col = "SE", exposure_Name = "Phenotype",
outcome_Name = "subcat",
forest_Title = 'OR (95% CI) for lung cancer \nper SD/log odds change in risk factor',
outfile_Name = "~/Google Drive/MR_base/papers/lung_cancer/plots/plot.png",
left_Col_Names = c("Phenotype", "SNPs"),
left_Col_Titles = c("\n","No. of \nSNPs"),
right_Col_Names = c("Pvalue"),
right_Col_Titles = c("\nP-value"),
summary_List = c("IVW"),
exp_ES = TRUE, #exponentiate
weight = TRUE, #inverse variance weight
sort_at_All=F,
Labels=c(0.25,0.5,1,2,4,8,16)) #weight marker size by inverse variance of log odds ratio
Sometimes the markers overlap too much with each other. This script produces an example of where the markers overlap/ are too squished together:
rm(list=ls())
setwd("
/ForestPlots/R/")/ForestPlots/R/forest_plots_helper_functions.R")source("
source("
/ForestPlots/R/many_exp_many_out.R")/ForestPlots/R/one_exp_many_out.R")source("
memodata <- read.delim("~/ForestPlots/inst/data/lungcancer.txt", as.is = TRUE)
Res<-memodata[memodata$subtype=="adenocarcinoma",]
Res<-Res[Res$Phenotype!="Smoking",]
Res$Phenotype<-gsub("^\s+|\s+$", "", Res$Phenotype) #remove leading and trailing white space from phenotype column
Res$subcat<-"Other risk factors"
Res$subcat[Res$Phenotype %in% c("Alpha-tocopherol",
"Beta-Carotene" ,
"Bilirubin",
"Calcium",
"Homocysteine",
"Iron",
"kynurenine",
"Magnesium",
"methionine",
"Retinol",
"Selenium",
"tryptophan",
"Vitamin B12",
"Vitamin B6",
"Vitamin D",
"Vitamin E")]<-"Vitamins and minerals"
Res$subcat[Res$Phenotype=="Smoking"] <-"Smoking"
Res$subcat[Res$Phenotype %in% c("Birth weight","body mass index","height","hip circumference","waist circumference","weight","waist-to-hip ratio")]<-"Anthropometrics"
Res$subcat[Res$Phenotype %in% c("FEV","Chronic bronchitis and chronic obstructive pulmonary disease","asthma")]<-"lung disease/function"
Res$subcat[Res$Phenotype %in% c("2hr glucose","Total cholesterol","CRP","fasting glucose","HDL cholesterol","MUFA","PUFA","Tot.FA")]<-"Metabolic biomarkers"
#Order the risk factors; plot function will use the order in the data
Res$order<-2
Res$order[Res$Phenotype=="Smoking"]<-1
Res$order[Res$subcat=="Other risk factors"]<-3
Res<-Res[order(Res$order),]
Res$colour_col=1
one_exp_many_out(inpt_Df = Res, eff_Col = "Beta", se_Col = "SE", exposure_Name = "Phenotype",
outcome_Name = "subcat",
forest_Title = 'OR (95% CI) for lung cancer \nper SD/log odds change in risk factor',
outfile_Name = "~/Google Drive/MR_base/papers/lung_cancer/plots/plot.png",
left_Col_Names = c("Phenotype", "SNPs"),
left_Col_Titles = c("\n","No. of \nSNPs"),
right_Col_Names = c("Pvalue"),
right_Col_Titles = c("\nP-value"),
summary_List = c("IVW"),
exp_ES = TRUE, #exponentiate
weight = TRUE, #inverse variance weight
sort_at_All=F,
Labels=c(0.25,0.5,1,2,4,8,16)) #weight marker size by inverse variance of log odds ratio