Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created June 9, 2016 16:26
Show Gist options
  • Save explodecomputer/61758bb8ea4af3f4c270bdf799499f39 to your computer and use it in GitHub Desktop.
Save explodecomputer/61758bb8ea4af3f4c270bdf799499f39 to your computer and use it in GitHub Desktop.
meth cvd
library(readxl)
a <- read_excel("~/Downloads/CVD_traits_summary.xlsx", skip=2)
names(a)[1] <- "Phenotype"
a1 <- a[,c(1,2:4)]
a2 <- a[,c(1,5:7)]
a3 <- a[,c(1,8:10)]
a4 <- a[,c(1,11:13)]
a5 <- a[,c(1,14:16)]
a6 <- a[,c(1,17:19)]
names(a1) <- names(a2) <- names(a3) <- names(a4) <- names(a5) <- names(a6) <- c("Phenotype", "Beta", "SE", "pval")
b <- rbind(a1, a2, a3, a4, a5, a6)
nom <- expand.grid(1:nrow(a), adjusted=c(TRUE, FALSE), group=c("Children", "Mothers", "Combined"))
b$adjusted <- nom$adjusted
b$group <- nom$group
# Convert the units to standard deviation units by dividing effects and standard errors by the standard deviation of the phenotype (e.g. mothers and children and both combined will have different SD values for each phenotype)
ggplot(subset(b, group != "both"), aes(x=group, y=Beta)) +
geom_hline(yintercept=0, linetype="dotted") +
geom_point(aes(colour=adjusted), size=3, position=position_dodge(0.4)) +
geom_errorbar(aes(colour=adjusted, ymin=Beta - 1.96 * SE, ymax=Beta + 1.96 * SE), width=0, position=position_dodge(0.4)) +
facet_grid(Phenotype ~ .) +
scale_colour_brewer(type="qual") +
coord_flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment