Hello - I'm using the ALL dataset from the Bioconductor suite. I'm trying to create a simple graph with 5 separate boxplots that represent the different gene expression between M/F. I can create a single boxplot without any trouble:
But when I add another gene I get an error? I thought my syntax looked clean?
Error in exprs(ALL)["1043_s_at", "38354_at", ] :
incorrect number of dimensions
For basic plotting, you can use par(mfrow=c(1,5)) for 5 boxplots in a window. Example code for 2 below:
lapply(c("1043_s_at","38354_at"), function(x) boxplot(exprs(ALL)[x,]~pData(ALL)$sex, main=paste0("Expression of ",x), col=rainbow(2)))
There are two issues in your code:
subsetting was incorrect. You were supposed to use c() for subsetting rows from a dataframe
Box plot accepts only one y when you are plotting against a factor (one Y in Y ~ X formula). You were passing two arguments that too with incorrect subsetting. Even if boxplot accepts two y values (which it doesn't), you code will fail because of incorrect subsetting.
If you don't want to use, apply functions, you can use following for two boxplots: