Change point size and remove outline in scater's plotPCA
2
0
Entering edit mode
CodeAway ▴ 70
@codeaway-12991
Last seen 3.5 years ago

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.

scater rnaseq single-cell • 4.8k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 4 hours ago
United States

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
angela.ubn • 0
@angelaubn-11783
Last seen 5.1 years ago

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

e.g.  

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 COMMENT

Login before adding your answer.

Traffic: 752 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