Home > other >  R language PCA drawing mistake how to solve
R language PCA drawing mistake how to solve

Time:12-04

The library (limma)
Setwd (" C: \ \ Users \ \ feh \ \ Desktop \ \ GSE49710 \ \ 11. PCA ")
Rt=read. Table (" symbol. TXT ", the header=T, check the names=F)
Rt=as matrix (rt)
Rownames (rt)=rt [1]
Exp=rt [2: ncol (rt)]
Dimnames=list (rownames (exp), colnames (exp))
data=https://bbs.csdn.net/topics/matrix (as numeric (as matrix (exp)), nrow=nrow (exp), dimnames=dimnames)
data=https://bbs.csdn.net/topics/avereps (data)
data=https://bbs.csdn.net/topics/data [rowMeans (data)> 0.5,]


Data. The class & lt; - rownames (data)
Data<- scale (data)
Data [is na (data)] <0
Data. The pca & lt; - prcomp (data, scale.=TRUE)
Write. The table (predict (data. Pca), the file="newTab. XLS", quote=F, sep="\ t")

# visualization
The library (ggplot2)
Cluster=read. Table (" cluster. TXT ", the header=F)
Group=paste0 (" cluster ", as the vector (cluster [2]))
PcaPredict=predict (data. Pca)
PCA=data frame (PCA1=pcaPredict [1], PCA2=pcaPredict [2], group=group)
the Error in the data frame (PCA1=pcaPredict [1], PCA2=pcaPredict [2], group=group) :
The parameter value means different line number: 19860, 131


(PDF file="PCA. PDF, height=5, width=6.5)
Ggplot (data=https://bbs.csdn.net/topics/PCA, aes (PCA1, PCA2)) + geom_point [color=group) (aes) +
+ + theme_bw ()
+ theme (plot. Margin=unit (rep (1.5, 4), 'lines')) +
+ theme (panel. Grid. Major=element_blank (), the panel, the grid. The minor=element_blank ())
the Error in ggplot (data=https://bbs.csdn.net/topics/PCA, aes (PCA1, PCA2)) : can't find the objects' PCA '
Dev. Off ()

about the Error in the data frame (PCA1=pcaPredict [1], PCA2=pcaPredict [2], group=group) :
The parameter value means different line number: 19860, 131 how to understand? How to solve?
 
  • Related