I am trying to make a Trellis graph with Lattice but I am not able to make it as I wish. I like how it looks so far, and I just need some help tuning it to look exactly what I want.
I will give you the data I am trying to plot, the R code I am using, the graph I get, and finally the graph that I would like to make.
1. Here is the data:CSV File
2. Here is my R code:
Infection<-read.table("stack.csv", header=TRUE, sep=",")
attach(Infection)
head(Infection)
Infection.st<-stack(Infection[,2:13])
head(Infection.st)
Infection.st[,"gene"]<-Infection[,1]
head(Infection.st)
summary(Infection.st$ind)
Infection.st$ind<-factor(Infection.st$ind, levels=c("Disease.12h", "Control.12h", "Disease.4d", "Control.4d",
"Disease.3h", "Control.3h", "Disease.24h", "Control.24h",
"Disease.48h", "Control.48h", "Disease.72h", "Control.72h"))
summary(Infection.st$ind)
xyplot(values~ind|gene, xlab = NULL,layout=c(7,16), main="Gene Expression after infection", auto.key=list(columns = 6, cex = .8),
pch = 21, cex = .7, scales = list(x = list(draw = FALSE)), data=Infection.st, group=ind)
3) Here is the graph I get: https: //dl.dropboxusercontent.com/u/62277598/Stack.pdf (remove the space after colon)
4) Finally the graph I want would look like this: Desired Graph
Now I would like to get the following things in my graph as you can see in my hand made picture:
a) each time point with different symbols, but disease empty and control filled (same color is okay). Another option is to have different types of items for each point and vary the color for disease and control (for example, red and green).
b) change the scale of the x axis. Since it is time series data, it would be nice to represent it. However it does not to be precise. For example, just a space between the 12h and 4 days, then smaller space after 4 days. It would be nice to have disease and control sample close in each time point.
c) finally it would be great if I could change the scale. There are some genes that are low expressed and I am just plotting it in a new graph. I thought to sort the expression by 4 days and then put genes grouped by the expression level.
PS: I don't have 10 reputation to post more than two links or images.
Thanks for your time.
I asked this question sometime ago. Here is the solution. The only thing I did not do was to change the distance between the time points. That is actually unnecessary.
Let me know if you have any questions.