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?
Please help me with your experiences.
Finalized script for PCA using Bioconductor::PCAtools
Principle component analysis
Without data normalization
library(readxl)
df <- read_excel("tpp.xlsx")
colnames(df)
ta <- df[, 2:14]
ta <- as.matrix(ta)
metadata <- data.frame(row.names = colnames(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)
tpp.pca <- pca(ta, metadata = metadata, scale = FALSE)
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')
Adding ellipse is still not working
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
include your problematic code here with any corresponding output
please also include the results of running the following in an R session
sessionInfo( )
```

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.
Hi, you can observe the values on the current axes, and then set new limits of greater absolute values via
xlimandylim, and then re-generate the plot.