**810**wrote:

This is my code for PCA using SVD , i get a neat plot , I want to add percatge to the axis I used to get in deseq2 plot im not sure how it adds to it

```
library(ISLR)
ncidat = (NON_CODING[,-1])
dim(ncidat)
ncidat[1:5,1:16]
X = t(scale(t(ncidat),center=TRUE,scale=FALSE))
View(X)
################
sv = svd(t(X))
U = sv$u
V = sv$v
D = sv$d
###############
## in R calculate the rank of a matrix is by
qr(t(X))$rank
cols = as.numeric(as.factor(colnames(ncidat)))
plot(U[,1],U[,2],type="n",xlab="PC1",ylab="PC2")
text(U[,1],U[,2],colnames(X),col=cols)
par(mfrow=c(1,2))
Z = t(X)%*%V
# plot PC1 vs PC2
plot(Z[,1], Z[,2], type ="n", xlab="PC1", ylab="PC2")
text(Z[,1], Z[,2], colnames(X), col=cols)
pc_dat<- data.frame(type = rownames(Z), PC1 = Z[,1], PC2= Z[,2])
library(ggplot2)
p<-ggplot(pc_dat,aes(x=PC1, y=PC2, col=type)) + geom_point() +
geom_text(aes(label = type), hjust=0, vjust=0)
p<-p + theme(text = element_text(size = 25))
p
```

Any suggestion or help would be highly appreciated how to add percentage on the PC1 and PC2 axis ....

Did you try 3.4 The percentage code from http://huboqiang.cn/2016/03/03/RscatterPlotPCA

4.7ki seen that code but i'm not sure how to pass my Principal component I mean which object is storing the principal component .

Can you have a look at my code and let me know ?

810sv$d (D above) values are related to pc standard.deviation. Use formula to convert sv$d values to pc standard deviations. If you are interested in displaying pc percentage, it is better to run PCA instead of SVD.

13kokay...so i will give it a try

810