I am using the IsoGene CRAN package, but when using the function IsoPlot, I do not seem to be able to change the title of the plots.
I am just trying to reproduce Figure 3 of this paper. This is the code:
library(affy)
library(IsoGene)
data(dopamine)
express <- data.frame(exprs(dopamine))
dose <- pData(dopamine)$dose
IsoPlot(dose,express[56,],type="ordinal", add.curve=TRUE)
The image they show in the paper for this code is this:
However, I obtain this, which might be a bug in the package:
You see the Gene name does not appear, and I have no way of showing it, cause IsoPlot would not accept the "main" parameter.
So anyone has a clue of how to change the title of IsoPlot, or at least just make it show the gene name properly like their example in their paper?
Thanks!
If you look at the function code (by typing IsoPlot
in the console), you can see that the last line of the function is:
title(paste("Gene: ", row.names(y), sep = ""))
which ought to give you the desired title, since row.names(express[56,])
returns 256_at
.
However, if you look at the very first line of the function body, you'll see this:
y <- as.numeric(y)
this converts the y
argument of IsoPlot
to a numeric vector, stripping off the row name in the process. Thus, when it comes time to add the title at the end, row.name(y)
is equal to NULL
and nothing gets printed. So I would agree this is a bug. You can file a bug report to let the package author know, and hopefully they will correct it.
For now, as a workaround, you can modify the function. To do this, copy the function code from the console and paste it into an R script. Then give the function a name, so that the first line of the function looks something like this:
myIsoPlot = function (x, y, type = c("continuous", "ordinal"), add.curve = FALSE) {
Add this as the first line of the function (before y <- as.numeric(y)
):
my_title = row.names(y)
Change the last line of the function to this:
title(paste("Gene: ", my_title, sep = ""))
Now load the function and then run it:
myIsoPlot(dose, express[56,], type="ordinal", add.curve=TRUE)
Here's a bit of a hack if you don't want to modify the function: You can "cover" the default title with a white rectangle and then add your own title. But you need to place the white rectangle by hand (you could write code to automate it, but it's probably more work than just modifying the IsoPlot
function):
IsoPlot(dose, y=express[56,], type="ordinal", add.curve=TRUE)
# White rectangle to cover default title
rect(0, 11, 10, 15, xpd=TRUE, col="white", border="white")
# New title
title(paste("Gene:", row.names(express[56,])))