PCA-3D Plot
1
0
Entering edit mode
Guest User ★ 12k
@guest-user-4897
Last seen 7.3 years ago
Dear All, I request help in generating "Sample-based 3D-PCA plot" (Principal component analysis). I used function "princomp" from package:stats to create a PCA object on the data-set. the data dimensions are 600 * 7. While genetaring, the plot were created on Genes with both "plot3d" and "scatterplot3d" functions, and I want the PCA-3d plot according to the samples. The code I used is, > dim(Expresso) [1] 618 7 > PCA_3d<-princomp(Expresso, cor=TRUE) > plot3d(PCA_3d$scores[,1:7],xlab="Component 1",main="My 3D + PCA",ylab="Component 2", zlab="Component 3", type="h", box=F, axes=F) > spheres3d(PCA_3d$scores[,1:7], radius=0.1, col="pink") > grid3d(side="z", at=list(z=0)) > text3d(PCA_3d$scores[,1:7], text=rownames(PCA_3d$scores), adj=1.3) I also tried to plot with function "scatterplot3d" > scatterplot3d(PCA_3d$scores[,1:3],xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21) > scatterplot3d(PCA_3d$scores [,1:3],xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21,bg=color) -- output of sessionInfo(): > sessionInfo() R version 2.15.1 (2012-06-22) Platform: x86_64-redhat-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ggplot2_0.9.3 reshape2_1.2.2 scatterplot3d_0.3-33 [4] rgl_0.93.935 DESeq_1.10.1 lattice_0.20-13 [7] locfit_1.5-8 Biobase_2.18.0 BiocGenerics_0.4.0 loaded via a namespace (and not attached): [1] annotate_1.36.0 AnnotationDbi_1.20.3 colorspace_1.2-1 [4] DBI_0.2-5 dichromat_2.0-0 digest_0.6.2 [7] genefilter_1.40.0 geneplotter_1.36.0 grid_2.15.1 [10] gtable_0.1.2 IRanges_1.16.5 labeling_0.1 [13] MASS_7.3-23 munsell_0.4 parallel_2.15.1 [16] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 [19] RSQLite_0.11.2 scales_0.2.3 splines_2.15.1 [22] stats4_2.15.1 stringr_0.6.2 survival_2.37-2 [25] tcltk_2.15.1 tools_2.15.1 XML_3.95-0.1 [28] xtable_1.7-0 -- Sent via the guest posting facility at bioconductor.org.
• 5.6k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 11 hours ago
United States
On 7/1/2013 8:28 AM, Chevala V V S Narayana [guest] wrote: > Dear All, > > I request help in generating "Sample-based 3D-PCA plot" (Principal component analysis). I used function "princomp" from package:stats to create a PCA object on the data-set. the data dimensions are 600 * 7. > > While genetaring, the plot were created on Genes with both "plot3d" and "scatterplot3d" functions, and I want the PCA-3d plot according to the samples. > > The code I used is, >> dim(Expresso) > [1] 618 7 >> PCA_3d<-princomp(Expresso, cor=TRUE) Both princomp() and prcomp() expect the data to be in a conventional format (with samples in rows and observations in columns). Microarray data are in general transposed from this format (with observations in rows and samples in columns), so you need to do princomp(t(Expresso), cor = TRUE) Best, Jim >> plot3d(PCA_3d$scores[,1:7],xlab="Component 1",main="My 3D > + PCA",ylab="Component 2", zlab="Component 3", type="h", box=F, axes=F) >> spheres3d(PCA_3d$scores[,1:7], radius=0.1, col="pink") >> grid3d(side="z", at=list(z=0)) >> text3d(PCA_3d$scores[,1:7], text=rownames(PCA_3d$scores), adj=1.3) > I also tried to plot with function "scatterplot3d" >> scatterplot3d(PCA_3d$scores[,1:3],xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21) >> scatterplot3d(PCA_3d$scores [,1:3],xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21,bg=color) > > > > > > > -- output of sessionInfo(): > >> sessionInfo() > R version 2.15.1 (2012-06-22) > Platform: x86_64-redhat-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=C LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > > other attached packages: > [1] ggplot2_0.9.3 reshape2_1.2.2 scatterplot3d_0.3-33 > [4] rgl_0.93.935 DESeq_1.10.1 lattice_0.20-13 > [7] locfit_1.5-8 Biobase_2.18.0 BiocGenerics_0.4.0 > > loaded via a namespace (and not attached): > [1] annotate_1.36.0 AnnotationDbi_1.20.3 colorspace_1.2-1 > [4] DBI_0.2-5 dichromat_2.0-0 digest_0.6.2 > [7] genefilter_1.40.0 geneplotter_1.36.0 grid_2.15.1 > [10] gtable_0.1.2 IRanges_1.16.5 labeling_0.1 > [13] MASS_7.3-23 munsell_0.4 parallel_2.15.1 > [16] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 > [19] RSQLite_0.11.2 scales_0.2.3 splines_2.15.1 > [22] stats4_2.15.1 stringr_0.6.2 survival_2.37-2 > [25] tcltk_2.15.1 tools_2.15.1 XML_3.95-0.1 > [28] xtable_1.7-0 > > > -- > Sent via the guest posting facility at bioconductor.org. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD COMMENT
0
Entering edit mode
I am thankful to You Mr. James W. MacDonald. But It didn't worked with function "princomp" when I use as > PCA_3d<-princomp(t(Expresso), cor=TRUE) Error in princomp.default(t(Normalized_Expresso), cor = TRUE) : 'princomp' can only be used with more units than variables On Mon, Jul 1, 2013 at 7:35 PM, James W. MacDonald <jmacdon@uw.edu> wrote: > > > On 7/1/2013 8:28 AM, Chevala V V S Narayana [guest] wrote: > >> Dear All, >> >> I request help in generating "Sample-based 3D-PCA plot" (Principal >> component analysis). I used function "princomp" from package:stats to >> create a PCA object on the data-set. the data dimensions are 600 * 7. >> >> While genetaring, the plot were created on Genes with both "plot3d" and >> "scatterplot3d" functions, and I want the PCA-3d plot according to the >> samples. >> >> The code I used is, >> >>> dim(Expresso) >>> >> [1] 618 7 >> >>> PCA_3d<-princomp(Expresso, cor=TRUE) >>> >> > Both princomp() and prcomp() expect the data to be in a conventional > format (with samples in rows and observations in columns). Microarray data > are in general transposed from this format (with observations in rows and > samples in columns), so you need to do > > princomp(t(Expresso), cor = TRUE) > > Best, > > Jim > > > plot3d(PCA_3d$scores[,1:7],**xlab="Component 1",main="My 3D >>> >> + PCA",ylab="Component 2", zlab="Component 3", type="h", box=F, axes=F) >> >>> spheres3d(PCA_3d$scores[,1:7], radius=0.1, col="pink") >>> grid3d(side="z", at=list(z=0)) >>> text3d(PCA_3d$scores[,1:7], text=rownames(PCA_3d$scores), adj=1.3) >>> >> I also tried to plot with function "scatterplot3d" >> >>> scatterplot3d(PCA_3d$scores[,**1:3],xlab="Component 1 (26.9%)",main="My >>> 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 >>> (12.4%)",type="h",box=FALSE,**pch=21) >>> scatterplot3d(PCA_3d$scores [,1:3],xlab="Component 1 (26.9%)",main="My >>> 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 >>> (12.4%)",type="h",box=FALSE,**pch=21,bg=color) >>> >> >> >> >> >> >> >> -- output of sessionInfo(): >> >> sessionInfo() >>> >> R version 2.15.1 (2012-06-22) >> Platform: x86_64-redhat-linux-gnu (64-bit) >> >> locale: >> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C >> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 >> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 >> [7] LC_PAPER=C LC_NAME=C >> [9] LC_ADDRESS=C LC_TELEPHONE=C >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> other attached packages: >> [1] ggplot2_0.9.3 reshape2_1.2.2 scatterplot3d_0.3-33 >> [4] rgl_0.93.935 DESeq_1.10.1 lattice_0.20-13 >> [7] locfit_1.5-8 Biobase_2.18.0 BiocGenerics_0.4.0 >> >> loaded via a namespace (and not attached): >> [1] annotate_1.36.0 AnnotationDbi_1.20.3 colorspace_1.2-1 >> [4] DBI_0.2-5 dichromat_2.0-0 digest_0.6.2 >> [7] genefilter_1.40.0 geneplotter_1.36.0 grid_2.15.1 >> [10] gtable_0.1.2 IRanges_1.16.5 labeling_0.1 >> [13] MASS_7.3-23 munsell_0.4 parallel_2.15.1 >> [16] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 >> [19] RSQLite_0.11.2 scales_0.2.3 splines_2.15.1 >> [22] stats4_2.15.1 stringr_0.6.2 survival_2.37-2 >> [25] tcltk_2.15.1 tools_2.15.1 XML_3.95-0.1 >> [28] xtable_1.7-0 >> >> >> -- >> Sent via the guest posting facility at bioconductor.org. >> >> ______________________________**_________________ >> Bioconductor mailing list >> Bioconductor@r-project.org >> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https: stat.e="" thz.ch="" mailman="" listinfo="" bioconductor=""> >> Search the archives: http://news.gmane.org/gmane.** >> science.biology.informatics.**conductor<http: news.gmane.org="" gmane="" .science.biology.informatics.conductor=""> >> > > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > -- Chevala. V V S Narayana Junior Research Fellow, NIPGR. [[alternative HTML version deleted]]
0
Entering edit mode
Hmmm. I generally use prcomp() for this sort of thing, so you could do pc <- prcomp(t(Expresso)) scatterplot3D(pc$x[,1:3]) or you could use the rgl package if you want to be able to rotate the plot. Best, Jim On 7/1/2013 1:48 PM, Veera Venkata Satyanarayana wrote: > I am thankful to You Mr. James W. MacDonald. But It didn't worked > with function "princomp" when I use as > > > PCA_3d<-princomp(t(Expresso), cor=TRUE) > Error in princomp.default(t(Normalized_Expresso), cor = TRUE) : > 'princomp' can only be used with more units than variables > > > > > On Mon, Jul 1, 2013 at 7:35 PM, James W. MacDonald <jmacdon at="" uw.edu=""> <mailto:jmacdon at="" uw.edu="">> wrote: > > > > On 7/1/2013 8:28 AM, Chevala V V S Narayana [guest] wrote: > > Dear All, > > I request help in generating "Sample-based 3D-PCA plot" > (Principal component analysis). I used function "princomp" > from package:stats to create a PCA object on the data-set. the > data dimensions are 600 * 7. > > While genetaring, the plot were created on Genes with both > "plot3d" and "scatterplot3d" functions, and I want the PCA- 3d > plot according to the samples. > > The code I used is, > > dim(Expresso) > > [1] 618 7 > > PCA_3d<-princomp(Expresso, cor=TRUE) > > > Both princomp() and prcomp() expect the data to be in a > conventional format (with samples in rows and observations in > columns). Microarray data are in general transposed from this > format (with observations in rows and samples in columns), so you > need to do > > princomp(t(Expresso), cor = TRUE) > > Best, > > Jim > > > plot3d(PCA_3d$scores[,1:7],xlab="Component 1",main="My 3D > > + PCA",ylab="Component 2", zlab="Component 3", type="h", > box=F, axes=F) > > spheres3d(PCA_3d$scores[,1:7], radius=0.1, col="pink") > grid3d(side="z", at=list(z=0)) > text3d(PCA_3d$scores[,1:7], text=rownames(PCA_3d$scores), > adj=1.3) > > I also tried to plot with function "scatterplot3d" > > scatterplot3d(PCA_3d$scores[,1:3],xlab="Component 1 > (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", > zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21) > scatterplot3d(PCA_3d$scores [,1:3],xlab="Component 1 > (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", > zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21,bg=color) > > > > > > > > -- output of sessionInfo(): > > sessionInfo() > > R version 2.15.1 (2012-06-22) > Platform: x86_64-redhat-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=C LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods > base > > other attached packages: > [1] ggplot2_0.9.3 reshape2_1.2.2 scatterplot3d_0.3-33 > [4] rgl_0.93.935 DESeq_1.10.1 lattice_0.20-13 > [7] locfit_1.5-8 Biobase_2.18.0 BiocGenerics_0.4.0 > > loaded via a namespace (and not attached): > [1] annotate_1.36.0 AnnotationDbi_1.20.3 colorspace_1.2-1 > [4] DBI_0.2-5 dichromat_2.0-0 digest_0.6.2 > [7] genefilter_1.40.0 geneplotter_1.36.0 grid_2.15.1 > [10] gtable_0.1.2 IRanges_1.16.5 labeling_0.1 > [13] MASS_7.3-23 munsell_0.4 parallel_2.15.1 > [16] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 > [19] RSQLite_0.11.2 scales_0.2.3 splines_2.15.1 > [22] stats4_2.15.1 stringr_0.6.2 survival_2.37-2 > [25] tcltk_2.15.1 tools_2.15.1 XML_3.95-0.1 > [28] xtable_1.7-0 > > > -- > Sent via the guest posting facility at bioconductor.org > <http: bioconductor.org="">. > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org <mailto:bioconductor at="" r-project.org=""> > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > > > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > > > > -- > Chevala. V V S Narayana > Junior Research Fellow, > NIPGR. > -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD REPLY
0
Entering edit mode
Dear, Yes, Its worked with function "prcomp": > PCA_3d<-prcomp(t(Normalized_Expresso), cor=TRUE) Here is the Question: while ploting the object PCA_3d with scatterplot3d from package:scatterplot3d, the x,y,z coordinates were given as PCA_3d$x[,1:3], but the PCA_3d$x has 7 PC components (columns) and 7 samples as rows. If I give the first three PC components [PC1, PC2, PC3] as coordinates, I insists to know about other PCs like [PC4,PC5, PC6, PC7]. Out of all which gives the best reliable pattern of samples on the plot. > scatterplot3d(PCA_3d$x[,1:3],xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21) Thanking You in advance, Satya On Mon, Jul 1, 2013 at 11:18 PM, Veera Venkata Satyanarayana < veeru.vsn@gmail.com> wrote: > I am thankful to You Mr. James W. MacDonald. But It didn't worked with > function "princomp" when I use as > > > PCA_3d<-princomp(t(Expresso), cor=TRUE) > Error in princomp.default(t(Normalized_Expresso), cor = TRUE) : > 'princomp' can only be used with more units than variables > > > > > > On Mon, Jul 1, 2013 at 7:35 PM, James W. MacDonald <jmacdon@uw.edu> wrote: > >> >> >> On 7/1/2013 8:28 AM, Chevala V V S Narayana [guest] wrote: >> >>> Dear All, >>> >>> I request help in generating "Sample-based 3D-PCA plot" (Principal >>> component analysis). I used function "princomp" from package:stats to >>> create a PCA object on the data-set. the data dimensions are 600 * 7. >>> >>> While genetaring, the plot were created on Genes with both "plot3d" and >>> "scatterplot3d" functions, and I want the PCA-3d plot according to the >>> samples. >>> >>> The code I used is, >>> >>>> dim(Expresso) >>>> >>> [1] 618 7 >>> >>>> PCA_3d<-princomp(Expresso, cor=TRUE) >>>> >>> >> Both princomp() and prcomp() expect the data to be in a conventional >> format (with samples in rows and observations in columns). Microarray data >> are in general transposed from this format (with observations in rows and >> samples in columns), so you need to do >> >> princomp(t(Expresso), cor = TRUE) >> >> Best, >> >> Jim >> >> >> plot3d(PCA_3d$scores[,1:7],**xlab="Component 1",main="My 3D >>>> >>> + PCA",ylab="Component 2", zlab="Component 3", type="h", box=F, axes=F) >>> >>>> spheres3d(PCA_3d$scores[,1:7], radius=0.1, col="pink") >>>> grid3d(side="z", at=list(z=0)) >>>> text3d(PCA_3d$scores[,1:7], text=rownames(PCA_3d$scores), adj=1.3) >>>> >>> I also tried to plot with function "scatterplot3d" >>> >>>> scatterplot3d(PCA_3d$scores[,**1:3],xlab="Component 1 >>>> (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 >>>> (12.4%)",type="h",box=FALSE,**pch=21) >>>> scatterplot3d(PCA_3d$scores [,1:3],xlab="Component 1 (26.9%)",main="My >>>> 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 >>>> (12.4%)",type="h",box=FALSE,**pch=21,bg=color) >>>> >>> >>> >>> >>> >>> >>> >>> -- output of sessionInfo(): >>> >>> sessionInfo() >>>> >>> R version 2.15.1 (2012-06-22) >>> Platform: x86_64-redhat-linux-gnu (64-bit) >>> >>> locale: >>> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C >>> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 >>> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 >>> [7] LC_PAPER=C LC_NAME=C >>> [9] LC_ADDRESS=C LC_TELEPHONE=C >>> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C >>> >>> attached base packages: >>> [1] stats graphics grDevices utils datasets methods base >>> >>> other attached packages: >>> [1] ggplot2_0.9.3 reshape2_1.2.2 scatterplot3d_0.3-33 >>> [4] rgl_0.93.935 DESeq_1.10.1 lattice_0.20-13 >>> [7] locfit_1.5-8 Biobase_2.18.0 BiocGenerics_0.4.0 >>> >>> loaded via a namespace (and not attached): >>> [1] annotate_1.36.0 AnnotationDbi_1.20.3 colorspace_1.2-1 >>> [4] DBI_0.2-5 dichromat_2.0-0 digest_0.6.2 >>> [7] genefilter_1.40.0 geneplotter_1.36.0 grid_2.15.1 >>> [10] gtable_0.1.2 IRanges_1.16.5 labeling_0.1 >>> [13] MASS_7.3-23 munsell_0.4 parallel_2.15.1 >>> [16] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 >>> [19] RSQLite_0.11.2 scales_0.2.3 splines_2.15.1 >>> [22] stats4_2.15.1 stringr_0.6.2 survival_2.37-2 >>> [25] tcltk_2.15.1 tools_2.15.1 XML_3.95-0.1 >>> [28] xtable_1.7-0 >>> >>> >>> -- >>> Sent via the guest posting facility at bioconductor.org. >>> >>> ______________________________**_________________ >>> Bioconductor mailing list >>> Bioconductor@r-project.org >>> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https: stat.="" ethz.ch="" mailman="" listinfo="" bioconductor=""> >>> Search the archives: http://news.gmane.org/gmane.** >>> science.biology.informatics.**conductor<http: news.gmane.org="" gman="" e.science.biology.informatics.conductor=""> >>> >> >> -- >> James W. MacDonald, M.S. >> Biostatistician >> University of Washington >> Environmental and Occupational Health Sciences >> 4225 Roosevelt Way NE, # 100 >> Seattle WA 98105-6099 >> >> > > > -- > Chevala. V V S Narayana > Junior Research Fellow, > NIPGR. > > -- Chevala. V V S Narayana Junior Research Fellow, NIPGR. [[alternative HTML version deleted]]
0
Entering edit mode
Hi, On Mon, Jul 1, 2013 at 11:07 AM, Veera Venkata Satyanarayana <veeru.vsn at="" gmail.com=""> wrote: > Dear, > Yes, Its worked with function "prcomp": >> PCA_3d<-prcomp(t(Normalized_Expresso), cor=TRUE) > > Here is the Question: > while ploting the object PCA_3d with scatterplot3d from > package:scatterplot3d, the x,y,z coordinates were given as PCA_3d$x[,1:3], > but the PCA_3d$x has 7 PC components (columns) and 7 samples as rows. If I > give the first three PC components [PC1, PC2, PC3] as coordinates, I > insists to know about other PCs like [PC4,PC5, PC6, PC7]. Out of all which > gives the best reliable pattern of samples on the plot. I didn't actually catch the question here. Do you want to try all possible pairs of 3 axes to see which is "best"? Just change the `[,1:3]` to include the PC's that you like (you are picking 1,2,3) to see which you think does better. Generally speaking, you should expect to get the best separation using the first three PCs since PC1 explains more of the variance than PC2, and PC2 > PC3, etc. but feel free to experiment as you like. James' suggestion to use rgl is a good one -- often times spinning the plot around interactively is quite helpful. -steve -- Steve Lianoglou Computational Biologist Bioinformatics and Computational Biology Genentech
ADD REPLY
0
Entering edit mode
Thank You Mr. Steve and Mr. James. Its really helped me to have a clear understanding of PCA function. Now I could able to plot and capture the 3D plots through package:rgl. Thanks Again.. On Tue, Jul 2, 2013 at 12:11 AM, Steve Lianoglou <lianoglou.steve@gene.com>wrote: > Hi, > > On Mon, Jul 1, 2013 at 11:07 AM, Veera Venkata Satyanarayana > <veeru.vsn@gmail.com> wrote: > > Dear, > > Yes, Its worked with function "prcomp": > >> PCA_3d<-prcomp(t(Normalized_Expresso), cor=TRUE) > > > > Here is the Question: > > while ploting the object PCA_3d with scatterplot3d from > > package:scatterplot3d, the x,y,z coordinates were given as > PCA_3d$x[,1:3], > > but the PCA_3d$x has 7 PC components (columns) and 7 samples as rows. If > I > > give the first three PC components [PC1, PC2, PC3] as coordinates, I > > insists to know about other PCs like [PC4,PC5, PC6, PC7]. Out of all > which > > gives the best reliable pattern of samples on the plot. > > I didn't actually catch the question here. > > Do you want to try all possible pairs of 3 axes to see which is > "best"? Just change the `[,1:3]` to include the PC's that you like > (you are picking 1,2,3) to see which you think does better. > > Generally speaking, you should expect to get the best separation using > the first three PCs since PC1 explains more of the variance than PC2, > and PC2 > PC3, etc. but feel free to experiment as you like. > > James' suggestion to use rgl is a good one -- often times spinning the > plot around interactively is quite helpful. > > -steve > > -- > Steve Lianoglou > Computational Biologist > Bioinformatics and Computational Biology > Genentech > -- Chevala. V V S Narayana Junior Research Fellow, NIPGR. [[alternative HTML version deleted]]
0
Entering edit mode
Dear All, Can You help me in adding labels to the scatterplot3d of PCA object. the code I used is > PCA_3d<-prcomp(t(Expresso), cor=TRUE) > scatterplot3d(PCA_3d$x[,1:3], xlab="Component 1 (26.9%)",main="My 3D PCA",ylab="Component 2(17.9%)", zlab="Component 3 (12.4%)",type="h",box=FALSE,pch=21) > text(PCA_3d$x[,1:3], labels=row.names(PCA_3d$x), cex=.5, pos=4) But with the text command, I'm not able to add labels in the plot. Kindly, I request your help to solve.. Thanks in advance. Satya On Tue, Jul 2, 2013 at 12:41 AM, Veera Venkata Satyanarayana < veeru.vsn@gmail.com> wrote: > Thank You Mr. Steve and Mr. James. Its really helped me to have a clear > understanding of PCA function. Now I could able to plot and capture the 3D > plots through package:rgl. > > Thanks Again.. > > > > On Tue, Jul 2, 2013 at 12:11 AM, Steve Lianoglou <lianoglou.steve@gene.com> > wrote: > >> Hi, >> >> On Mon, Jul 1, 2013 at 11:07 AM, Veera Venkata Satyanarayana >> <veeru.vsn@gmail.com> wrote: >> > Dear, >> > Yes, Its worked with function "prcomp": >> >> PCA_3d<-prcomp(t(Normalized_Expresso), cor=TRUE) >> > >> > Here is the Question: >> > while ploting the object PCA_3d with scatterplot3d from >> > package:scatterplot3d, the x,y,z coordinates were given as >> PCA_3d$x[,1:3], >> > but the PCA_3d$x has 7 PC components (columns) and 7 samples as rows. >> If I >> > give the first three PC components [PC1, PC2, PC3] as coordinates, I >> > insists to know about other PCs like [PC4,PC5, PC6, PC7]. Out of all >> which >> > gives the best reliable pattern of samples on the plot. >> >> I didn't actually catch the question here. >> >> Do you want to try all possible pairs of 3 axes to see which is >> "best"? Just change the `[,1:3]` to include the PC's that you like >> (you are picking 1,2,3) to see which you think does better. >> >> Generally speaking, you should expect to get the best separation using >> the first three PCs since PC1 explains more of the variance than PC2, >> and PC2 > PC3, etc. but feel free to experiment as you like. >> >> James' suggestion to use rgl is a good one -- often times spinning the >> plot around interactively is quite helpful. >> >> -steve >> >> -- >> Steve Lianoglou >> Computational Biologist >> Bioinformatics and Computational Biology >> Genentech >> > > > > -- > Chevala. V V S Narayana > Junior Research Fellow, > NIPGR. > > -- Chevala. V V S Narayana Junior Research Fellow, NIPGR. [[alternative HTML version deleted]]
0
Entering edit mode
Hi Satya, On 7/4/2013 9:18 AM, Veera Venkata Satyanarayana wrote: > Dear All, > > Can You help me in adding labels to the scatterplot3d of PCA object. > the code I used is > > > PCA_3d<-prcomp(t(Expresso), cor=TRUE) > > > scatterplot3d(PCA_3d$x[,1:3], xlab="Component 1 (26.9%)",main="My 3D > PCA",ylab="Component 2(17.9%)", zlab="Component 3 > (12.4%)",type="h",box=FALSE,pch=21) > > > text(PCA_3d$x[,1:3], labels=row.names(PCA_3d$x), cex=.5, pos=4) > > > But with the text command, I'm not able to add labels in the plot. > Kindly, I request your help to solve.. This is getting off-topic for this list, so I will give you a pointer and request that any other questions about the scatterplot3d package be taken to R-help, which is the correct list. A large number of packages come with a vignette, which is a more in depth introduction to a package and what you can do with it. The scatterplot3d package happens to have one, and it also happens to have an example of adding text to a 3D plot. You can access the vignette by either doing vignette(package = "scatterplot3d") ## here you can see that the vignette is called 's3d' vignette("s3d") or you can just google scatterplot3d, and then read the vignette on CRAN. Best, Jim > > Thanks in advance. > > Satya > > > > On Tue, Jul 2, 2013 at 12:41 AM, Veera Venkata Satyanarayana > <veeru.vsn at="" gmail.com="" <mailto:veeru.vsn="" at="" gmail.com="">> wrote: > > Thank You Mr. Steve and Mr. James. Its really helped me to have a > clear understanding of PCA function. Now I could able to plot and > capture the 3D plots through package:rgl. > > Thanks Again.. > > > > On Tue, Jul 2, 2013 at 12:11 AM, Steve Lianoglou > <lianoglou.steve at="" gene.com="" <mailto:lianoglou.steve="" at="" gene.com="">> wrote: > > Hi, > > On Mon, Jul 1, 2013 at 11:07 AM, Veera Venkata Satyanarayana > <veeru.vsn at="" gmail.com="" <mailto:veeru.vsn="" at="" gmail.com="">> wrote: > > Dear, > > Yes, Its worked with function "prcomp": > >> PCA_3d<-prcomp(t(Normalized_Expresso), cor=TRUE) > > > > Here is the Question: > > while ploting the object PCA_3d with scatterplot3d from > > package:scatterplot3d, the x,y,z coordinates were given as > PCA_3d$x[,1:3], > > but the PCA_3d$x has 7 PC components (columns) and 7 samples > as rows. If I > > give the first three PC components [PC1, PC2, PC3] as > coordinates, I > > insists to know about other PCs like [PC4,PC5, PC6, PC7]. > Out of all which > > gives the best reliable pattern of samples on the plot. > > I didn't actually catch the question here. > > Do you want to try all possible pairs of 3 axes to see which is > "best"? Just change the `[,1:3]` to include the PC's that you like > (you are picking 1,2,3) to see which you think does better. > > Generally speaking, you should expect to get the best > separation using > the first three PCs since PC1 explains more of the variance > than PC2, > and PC2 > PC3, etc. but feel free to experiment as you like. > > James' suggestion to use rgl is a good one -- often times > spinning the > plot around interactively is quite helpful. > > -steve > > -- > Steve Lianoglou > Computational Biologist > Bioinformatics and Computational Biology > Genentech > > > > > -- > Chevala. V V S Narayana > Junior Research Fellow, > NIPGR. > > > > > -- > Chevala. V V S Narayana > Junior Research Fellow, > NIPGR. > -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD REPLY

Login before adding your answer.

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