Unable to change point size in plotExpression()
1
0
Entering edit mode
kushshah ▴ 10
@kushshah-20393
Last seen 2.3 years ago
University of North Carolina, Chapel Hi…

Seems relatively basic, but I can't find a way to change graph dynamics using the plotExpression() function in scater. For example, I have the following gene expression plot: https://ibb.co/q9p1Zq5

I am coloring points by cell type, but there are so many points and they are too big - therefore, alpha cells seem to trump the other cells because they are near the top of the shading hierarchy.

Specifically, I want to be able to do the following:

  1. Decrease point size
  2. Create and change point borders
  3. Change transparency of points
  4. Change legend title

In general, within plotExpression() and other plotting functions in scater, how are these sorts of changes made to the default graphs? I noticed that plotExpression() can take in an aes() object as an argument - is this the way? If so, how must this be formatted? I tried the following code:

plotExpression(sce, features=rownames(var.out.nospike)[chosen.genes], colour_by = "Characteristics.cell.type.", aesth = aes(size=2) + fontsize

but it results in an unused argument error referring to aesth. I have also tried adding a theme object like this:

plotExpression(sce, features=rownames(var.out.nospike)[chosen.genes]) + theme(axis.text=element_text(size=8)

but I don't think you can specify point size in a theme object. Any help or references to coded examples would be much appreciated!

scater plotexpression singlecellexperiment plotting • 1.9k views
ADD COMMENT
1
Entering edit mode
Aaron Lun ★ 28k
@alun
Last seen 11 hours ago
The city by the bay

If one were to follow the rabbit hole in ?plotExpression, you would see:

...: Additional arguments for visualization, see ?"scater-plot-args" for details.

From there, you should be able to find a point_size argument that... well, changes the point size. Similarly point_alpha can change the transparency of the points.

Point borders are hard coded. An option could be added, but clearly no one has felt the need for it. If you want to change them, I guess you could operate on the ggplot object to edit the point parameters (e.g., with + geom_point or something).

Legend titles are dependent on the variable name (i.e., the feature name or the metadata column name), which is a fairly sensible and generalizable strategy. If you want to change it, you can either change what the variable is called in the SingleCellExperiment object; or you can edit the ggplot object afterwards.

scater used to have some facilities for operating on the aes objects generated by ggplot2. However, their use required the user to know how the plotting variables were named inside the scater functions - this breaks encapsulation and should not be the user's business or responsibility. Frankly, if a user knows enough to create aes objects, then they should just use ggplot2 directly. scater's plotting functions are intended for quick and convenient visualization - I'm afraid that publication quality plots will require some more manual effort.

ADD COMMENT
0
Entering edit mode

Thanks Aaron. Didn't realize there were extra arguments in scater-plot-args. This is really helpful. In the list of extra arguments, I didn't see any way to add a chart title - is this possible for plotExpression()?

ADD REPLY
1
Entering edit mode

Can't you just use ggtitle? See, e.g., Figure 12 here.

ADD REPLY

Login before adding your answer.

Traffic: 760 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6