1
0
Entering edit mode
M Tuhin • 0
Last seen 12 months ago
Australia

Enter the body of text here

Hi All, I need some urgent help regrading pca analysis to show the clustering of my 13 samples based on treatment condition. I have run the code and generated a biplot which is showing the 13 points represent 13 samples but the problem is I want to draw an ellipse for 2/3 replicates under the same treatment. How can i do that? Could anyone help me in this regards?

# Without data normalization

colnames(df)

ta <- df[, 2:14]

ta <- as.matrix(ta)

metadata$Group <- rep(NA, ncol(ta)) metadata$Group[seq(1,2)] <- 'Batch 1 Control'

metadata$Group[seq(3,4)] <- 'Batch 1 P100' metadata$Group[seq(5,7)] <- 'Batch 2 Control'

metadata$Group[seq(8,10)] <- 'Batch 2 P25' metadata$Group[seq(11,13)] <- 'Batch 2 P100'

library(ggplot2)

library(ggrepel)

library(PCAtools)

biplot(tpp.pca)

biplot(tpp.pca, pointSize = 5, lab = NULL, labSize = 4, colby = 'Group', shape = 'Group', legendPosition = 'right')

biplot(tpp.pca, pointSize = 3, lab = p\$yvars, labSize = 4, colby = 'Group', shape = 'Group', legendPosition = 'right')

# All of these codes are not producing ellipse

biplot(tpp.pca, pointSize = 5, lab = NULL, labSize = 4, colby = 'Group', shape = 'Group', legendPosition = 'right') + geom_point() + stat_ellipse(aes(group = 'Group'), type = "norm")

# An incomplete ellipse is formed from the above code

biplot(tpp.pca, pointSize = 5, lab = NULL, labSize = 4, colby = 'Group', shape = 'Group', ellipse = TRUE, legendPosition = 'right')

# Above code results in:

Too few points to create an ellipse

# library(ggforce) also used (may be wrong way)

biplot(tpp.pca, pointSize = 5, lab = NULL, labSize = 4, colby = 'Group', shape = 'Group', ellipse = TRUE, legendPosition = 'right') +

ggforce::geom_mark_ellipse(aes(color = 'Group'))r

# please also include the results of running the following in an R session

sessionInfo( )



Biplot FactoMineR proteomics PCAtools ellipse • 1.0k views
1
Entering edit mode
Kevin Blighe ★ 3.9k
@kevin
Last seen 5 weeks ago
Republic of Ireland

Hi,

Please increase the values for xlim and / or ylim.

Kind regards,

Kevin

0
Entering edit mode

Hi kevin many thanks for your answer? How can I found the existing up and lower limit? If I increase these limits instead of NULL, will then the following code work?

biplot(tpp.pca, pointSize = 5, lab = NULL, labSize = 4, colby = 'Group', shape = 'Group', ellipse = TRUE, xlim = NULL, ylim = NULL legendPosition = 'right')

This is my existing graph. I want to have an ellipse around every cluster.

0
Entering edit mode

Hi, you can observe the values on the current axes, and then set new limits of greater absolute values via xlim and ylim`, and then re-generate the plot.