Question: Change point size and remove outline in scater's plotPCA
gravatar for CodeAway
19 months ago by
CodeAway30 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 angela.ubn0 • written 19 months ago by CodeAway30
gravatar for James W. MacDonald
19 months ago by
United States
James W. MacDonald48k 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 19 months ago by James W. MacDonald48k

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 19 months ago by CodeAway30

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 19 months ago • written 19 months ago by Aaron Lun21k
gravatar for angela.ubn
8 months ago by
angela.ubn0 wrote:

If you need to change the size and shape, you probably need to convert the associated attributes as a factor. 


New_sceset$sc3_7_clusters <- as.factor(New_sceset$sc3_7_clusters)

New_sceset$cell_type <- as.factor(New_sceset$cell_type)

p <- plotPCA(New_sceset, colour_by = 'sc3_7_clusters', shape_by = 'cell_type')

p + scale_color_manual(values = rainbow(7)) + scale_shape_manual(values = c(16, 17))


It works for me. :D

ADD COMMENTlink written 8 months ago by angela.ubn0
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: 226 users visited in the last hour