PCA script correction
0
0
Entering edit mode
8 months ago
prity6459 • 0

Hi, I wrote a PCA script to project my samples using chatgpt, which may not be appropriate! I have a PCA plot, which is great.

Now I want to get circles for three replicates on the PCA plot, and how do I colour them differently based on the individuals? (I am not able to use chatgpt in this scenario!)

Could you possibly assist me in improving the script line that begins with 'barplot' and 'plot' to produce a blue barplot and PCA with a circle of individuals? the script I use is below-

data <- read.csv("For mesophyll and epidermis f 211223.csv", row.names = 1)  # Assuming gene IDs are in the first column
data <- t(data)

library (FactoMineR)
head(data)
PCA(na.omit(data))

library(factoextra)
library(ggplot2)
summary(data)

res.pca <- PCA(data, scale.unit=TRUE, graph=F)

eigenvalues <- res.pca$eig
res.pca <- PCA(data,quali.sup=c(1))
head(res.pca$eig)
barplot(res.pca$eig[,2],main="Eigenvalues",names.arg=1:nrow(res.pca$eig)) #Can you plz improve this line?

#Correlation circle
head(res.pca$ind$coord)
plot(res.pca,choix = "var")

#to get the dotplot
plot(res.pca, choix = "ind", invisible = "quali") #Can you plz improve here to have circles for replicates coming from same sample?

PCA plot

correction script PCA • 393 views
ADD COMMENT
0
Entering edit mode

Plotting PCA with ggplot2

I see you have ggplot2 loaded, but I don't see it being used anywhere - these look like they are all base-R plots I think. If you insist on using chat GPT, I suggest refining the prompt to tell it to construct the plots with ggplot2 and not base-R. #whychatgptwillneverreplaceus

ADD REPLY

Login before adding your answer.

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