Friday, January 12, 2018
Code to plot GTEx color coded expression levels
These are the instructions to plot GTEx color coded expression levels in R and ggplot2. You need to have two files, one with GTEx tissue names and expression values,
And a file with GTEx tissues and color code.
First lets order the RPKM data frame.
Next, merge RPKM and COLOR data frames while preserving the original order.
Next, add # sign for color codes.
It is important to reorder levels not to be alphabetically sorted as this is how they will appear on the graph.
First convert the column of the data frame to character vector, then recreate factor levels. Check the levels order.
Check if DATA$RPKM levels are in the correct order.
Similarly reorder factor levels for DATA$tissue_color_hex.
Use ggplot2 to plot the graph. Use + aes(colour=as.character(DATA$tissue_color_hex)) + scale_colour_identity() for custom colors.
The graph has the expression values of interest and it is color coded using GTEx colors.