Question: Change point size and remove outline in scater's plotPCA
gravatar for CodeAway
8 months ago by
CodeAway20 wrote:

Hello All,

Just need a quick help, with regards to the plotPCA function of the "really excellent" scater package, that I am using for single-cell RNAseq analysis of 10X data.  I wish to change the size of the points and also remove the gray outlines that currently appear around the points.

I tried using "scale_size_manual" and "scale_shape_manual", but these did not have any effect.

I would really appreciate any help.

Many thanks.

ADD COMMENTlink modified 8 months ago by James W. MacDonald45k • written 8 months ago by CodeAway20
gravatar for James W. MacDonald
8 months ago by
United States
James W. MacDonald45k wrote:

Rather than trying to hack things by calling ggplot2 functions directly, you might just read the help page for plotPCA, which says

size_by: character string defining the column of 'pData(object)' to be
          used as a factor by which to define the size of points in the
          plot. Alternatively, a data frame with one column containing
          values to map to sizes.

You don't show your code, but presumably there is something in the help page that affects whether or not a gray outline should be drawn around your plotting symbols.

ADD COMMENTlink written 8 months ago by James W. MacDonald45k

Thanks, James.  I am actually not using "size_by", so that is left to default.

I was able to change the colors of the points as below:

ppcah <- plotPCA(sce, pca_data_input="pdata", colour_by="sample_type", shape_by=NULL) + 
  scale_fill_manual(values=c("WT"="blue", "R172K"="red")) +
  labs(fill="Type", title="PCA plot of QC metrics")

using scale_fill_manual.  But if I use scale_shape_manual or scale_size_manual, nothing changes.

Thanks in advance, for any responses.


ADD REPLYlink written 8 months ago by CodeAway20

For what it's worth, I usually just pull out the coordinates from the object returned by plotPCA and replot those in a separate call, rather than trying to wrestle with ggplot2 and scater at the same time. In my opinion, scater is intended for quick production of decent-looking plots for data exploration, usually for use in relatively informal analysis reports that get shown to colleagues or collaborators. If you want customized publication-quality figures, you'll have to do a bit more work.

ADD REPLYlink modified 8 months ago • written 8 months ago by Aaron Lun18k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 308 users visited in the last hour