I'm definitely a neophyte to R for visualizing data, so bear with me.
I'm looking to create side-by-side dot plots of seven categorical samples with many gene expression values corresponding with individual gene names. mydata.csv file looks like the following
B27 B28 B30 B31 LTNP5.IFN.1 LTNP5.IFN.2 LTNP5.IL2.1
1 13800.91 13800.91 13800.91 13800.91 13800.91 13800.91 13800.91
2 6552.52 5488.25 3611.63 6552.52 6552.52 6552.52 6552.52
3 3381.70 1533.46 1917.30 2005.85 3611.63 4267.62 5488.25
4 2985.37 1188.62 1051.96 1362.32 2717.68 2985.37 5016.01
5 1917.30 2862.19 2625.29 2493.26 2428.45 2717.68 4583.02
6 990.69 777.97 1269.05 1017.26 5488.25 5488.25 4267.62
I would like each sample data to be organized in its own dot plot in one graph. Additionally, if I could point out individual data points of interest, that would be great.
Thanks!
You can use base R, but you need to convert to
matrix
first.or, we can transpose the matrix to arrange it by sample:
Considering your [toy] data is stored in a data frame called
a
:produces
What we did: Loaded required libraries (
reshape2
to convert from wide to long andggplot2
to, well, plot);melt
ed the data into long formmat (more difficult to read, easier to process) and then plotted withggplot
.I introduced
trial
to point to each "run" each variable was measured, and so I plottedtrial
vsvalue
at each level ofvariable
. Thefacet_wrap
part puts each plot into a subplot region determined byvariable
.