Created
October 31, 2016 11:05
-
-
Save mbarnkob/c0fa8aae4c0347484248eedf90d493be to your computer and use it in GitHub Desktop.
Revisions
-
mbarnkob created this gist
Oct 31, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ### Visualization of hazard ratio's in TCGA data based on a single gene ### ================= # Goal: To visualize survival data (deaths) based on the expression level of a single gene # as either high or low, and the hazard ratio between those two. # Date: 2016-10-30 # Author: Mike Barnkob, www.mikebarnkob.dk ### Data df_data <- data.frame(Cancer=c("Brain", "Colorectal", "Kidney clear cell carcinoma", "Kidney renal papillary carcinoma"), HR=c(1.03, 0.98, 1.27, 1.22), HR_lower=c(0.97, 0.62, 1.16, 1.03), HR_upper=c(1.09, 1.55, 1.38, 1.45) ) ### Visualize if (!require('ggplot2')) install.packages('ggplot2'); library('ggplot2') # Load ggplot2 library #Based on http://www.gettinggeneticsdone.com/2011/03/forest-plots-using-rstats-and-ggplot2.html and https://github.com/hadley/ggplot2/issues/1441 #Layout inspired by Fivethirtyeight's election tables: http://projects.fivethirtyeight.com/2016-election-forecast/#margins p <- ggplot(df_data, aes(x=Cancer, y=HR, ymin=HR_lower, ymax=HR_upper)) + geom_linerange(size=8, colour="#a6d8f0") + geom_hline(aes(x=0, yintercept=1), lty=1) + geom_point(size=3, shape=21, fill="#008fd5", colour = "white", stroke = 1) + scale_y_continuous(limits = c(0.5, 2)) + coord_flip() + ggtitle("Hazard Ratio for Gene of Interest") + theme_minimal() p