Closed julien-roux closed 7 years ago
Hi Julien
As the docs for plotExpression
state, the x
argument is used to give cell variable (cell metadata or feature expression) to use on the x-axis of the plot (e.g. so you can plot feature expression against total features, or expression of gene 1 against expression of gene 2). Each point on the plot represents a cell, so it does not make sense for x
to be a column of fData(object)
.
However, if you don't specify x
then you get the violin plots for a set of genes. I think this is what you're getting at. There's no argument to change the x-labels, so there are two options:
Replace existing featureNames with symbols (e.g. featureNames(object) <- fData(object)$symbol
- obviously, symbols need to be unique for this to work.
Use the capabilities of ggplot2
- the output of plotExpression
is a ggplot object, so many ggplot manipulations work. e.g.
plotExpression(object, myGenes) + scale_x_discrete(labels = fData(object)[myGenes, "symbol"])
Hope that helps Davis
Great!
I had tried something like solution 1, but the symbols are indeed not unique, so some tweaking was needed...
Solution 2 works just fine, thanks for that!
Julien
Hi Davis, I want to plot the expression of a subset of genes of interest using the
plotExpression
function. However the default labels are Ensembl IDs (the feature names in my SCESet object) which are not easy to decipher... I have asymbol
column in thefeatureData
of mySCESet
object and I would like to use this as x-axis label.The intuitive command to run seems to be:
plotExpression(sce, myGenes, x="symbol", alpha=0.2) + fontsize
However I get this error:
My feeling is that
x
should be a column offData(object)
notpData(object)
.Is that an error?