To create my dotplot I am using the following text file:
## filename difference RMSD
1bso.pdb 1.0 0.5645
1cj51.9.pdb 2.0 3.5596
1cj51.1.pdb 3.0 3.5573
3qzj.pdb 3.0 0.8302
1bsy.pdb 4.0 0.5387
1cj51.5.pdb 8.0 3.9864
2gj5.pdb 10.0 0.8446
1cj51.10.pdb 11.0 3.5914
1uz2.pdb 12.0 1.7741
2blg.pdb 12.0 0.5449
The 1st column is the file name, second column in the difference and the 3rd is the RMSD. The data was ordered so the difference is ascending.
I can create individual dot plots using the following commands:
# This plots the difference
library(lattice)
data <- read.table("~/Documents/Beta_test_area/pa.txt", header=F, sep="\t")
dotplot(V1~V2, xlim=c(0, 150), xlab="CCS Difference", data=data)
# This plots the RMSD
dotplot(V1~V3, xlim=c(0, 5), xlab="RMSD", data=data)
On the graph the data on the Y axis is ordered by file name and the data is not plotted as in the text file, how can I order the Y axis to mirror the order in the data file?
The other problem I am having is combining the plots. How can I have the make the plots so that I have the plots in one row but over two columns. With the difference plot on the left and the RMSD plot on the right.
@Roman’s part #1 is correct — here’s a slightly slick way to get the order the way you want it.
The
grid.arrangefunction from thegridExtrapackage is handy for arranging lattice plots:Or (from @Aaron):
Alternatively as @Roman suggested you can create small multiples.
Or
although here I really don’t know how to set the x axis limits panel-by-panel, other than doing something nasty like trying to add invisible points appropriately.
edit: panel-by-panel scaling from Josh O’Brien, latticeExtra from Aaron