Closed:3D PCA issue
3
2
Entering edit mode
6.8 years ago
1769mkc ★ 1.2k

Im trying to make a 3D PCA but i m not sure if its really working or not i cannot label my sample which i intend to here is my code anyone can help or any suggestion how can i label my samples in my final plot.

d <- read.csv("~/analysis/gene_fpkm/PRIMARY_AUX_ATPASE.csv",header = TRUE)
names(d)
model <- prcomp(t(d[,-1]), scale=TRUE)
plotPCA <- function(x, nGroup) {
n <- ncol(x) 
 }
  fit <- hclust(dist(x), method="complete") 
 groups <- cutree(fit, k=nGroup)
if(n == 3) { # 3d plot
plot3d(x, col=groups, type="s", size=1, axes=F)
axes3d(edges=c("x--", "y--", "z"), lwd=3, axes.len=2, labels = TRUE)
mtext3d(text)
grid3d("x")
grid3d("y")
grid3d("z")
 } else { # 2d plot
maxes <- apply(abs(x), 2, max)
rangeX <- c(-maxes[1], maxes[1])
rangeY <- c(-maxes[2], maxes[2])
plot(x, col=groups, pch=19, xlab=colnames(x)[1], ylab=colnames(x)[2], xlim=rangeX, ylim=rangeY)
lines(c(0,0), rangeX*2)
lines(rangeY*2, c(0,0))
 }
}
plotPCA(model$x[,1:3], 5)

this is the code im running i cannot label my sample in which comes in the final 3D pca .any suggestion or help would be highly appreciated

R • 749 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2743 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