PCAtools - change colour of points
1
0
Entering edit mode
Terra • 0
@terra-24154
Last seen 19 months ago
Australia

Hi,

I'm running PCAtools on a cancer and control samples with this code:

bp1 <- PCAtools::biplot(pcaobj = PCA,
                   colby = 'group',
                   colkey = c(control = 'blue', cancer = 'pink'),
                   legendPosition = "right",
                   lab = NULL, 
                   hline = 0, vline = 0)

        geom_point(shape = 1,size = 3,colour = "black") +

        theme(legend.title = element_blank(),
              legend.position=c(0.9,0.9),
              legend.background = element_rect(fill="white", size=.5, linetype="dotted"),
              legend.box.background = element_rect(colour = "black"))

The error I'm getting is: Scale for 'colour' is already present. Adding another scale for 'colour', which will replace the existing scale.

Running the above code I get the plots, but they're just empty circles, however if I comment out colkey I'll get the default colours. I'm not sure what I'm doing wrong here.

sessionInfo( )

R version 4.0.3 (2020-10-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.7

PCAtools • 3.2k views
ADD COMMENT
2
Entering edit mode
Kevin Blighe ★ 4.0k
@kevin
Last seen 17 days ago
Republic of Ireland

One of the ideas behind PCAtools is that one does not require extra ggplot2 'add on' functions, like you are using:

geom_point(shape = 1,size = 3,colour = "black") +

        theme(legend.title = element_blank(),
              legend.position=c(0.9,0.9),
              legend.background = element_rect(fill="white", size=.5, linetype="dotted"),
              legend.box.background = element_rect(colour = "black"))

You can apply the same functionality via parameters that are passed to biplot()

Irrespective, in your code, there is no plus sign ('+') to link biplot() with these extra functions.

The message that you receive is a warning message, I believe, not an error message. Can you please confirm that control and cancer are part of your metadata column called group?

Kevin

ADD COMMENT
0
Entering edit mode

Hi,

Thank you! I feel so silly, my columns weren't control and cancer I had labelled them as something else. It works now, much appreciated.

Perfect, I'll adapt my code so I can omit using ggplot2, it was a bit of a rushed attempt at getting the graph to appear how I wanted it.

Thank you again!

ADD REPLY
1
Entering edit mode

No problem / Sin problema / Sem problema

ADD REPLY

Login before adding your answer.

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