Rohit,
> but this package is huge ... and m new to R so if i can get some
straight commands it
> will be really helpful ...
I never used "ord", but using the traditional "prcomp" and
scatterplot3d, you can do it like this:
library(scatterplot3d)
data <- read.table("your_data_file"......)
pca <- prcomp(data) # if you are loading a microarray, matrix you
should use prcomp(t(data))
scatterplot3d(pca$x[,1], pca$x[,2], pca$x[,3], main = "PCA 3D plot")
Good luck,
Frederico Arnoldi
_________________________________________________________________
NINGU?M PRECISA SABER O QUE VOC? EST? COMPRANDO. LEIA MAIS SOBRE ESSE
ASSUNTO AQUI.
rivately.aspx?tabid=1&catid=1&WT.mc_id=1590
I prefer the plots you can construct using the rgl package (which
provides an R interface to the OpenGL graphics standard). However,
this
requires some manual manuipulations to get just the plot you want.
Here
is a complete example:
############# start here ################
library(rgl)
# open the GL graphics windows
rgl.open()
# resize the graphics window programatically.
# Note: there seems to be no way to pass this information
# when you first create the window.
offset <- 50
par3d(windowRect=c(offset, offset, 640+offset, 640+offset))
rm(offset)
# clear all GL graphics elements.
# Not really needed here, but useful to include in case you
# need to rerun the code after fine tuning the display
rgl.clear()
# set the camera viewpoint. mainly useful for fine tuning;
# you can often omit this and live with the defaults.
rgl.viewpoint(theta=45, phi=30, fov=60, zoom=1)
# generate the basic figure
# assumes you have put the principal components into a structure
# called "data3" with names "PC1", "PC2", and "PC3". Modify for
# your situation. Also assumes that you have a vector of colors
# that you want to use for each point, perhaps reflecting a
# separate classification. Can omit the "colors" option if you
# want.
spheres3d(data3$PC1, data3$PC2, data3$PC3, radius=0.3,
color=myColors, alpha=1, shininess=20)
# Note that there are lots of other 'primitive' functions
# in the package for other 3D shapes
# set the 3D aspect ratio
aspect3d(1, 1, 1)
# add axes
axes3d(col='black')
# add labels, which are related to title and subtitle
title3d("", "", "PC1", "PC2", "PC3", col='black')
# set the background color
bg3d("white")
# can optionally set a background to "gray" and give
# it reflective properties.
# now work with the figure interactively to align it at the
# angles that show the best separation between the groups
# improve the lighting
# start by working in the dark
rgl.clear(type='lights')
# add specular (point-source) light
rgl.light(-45, 20, ambient='black', diffuse='#dddddd',
specular='white')
# add ambient light
rgl.light(60, 30, ambient='#dddddd', diffuse='#dddddd',
specular='black')
# save the result as a PNG file
rgl.snapshot("threePC.png")
############################### END HERE ####################
Frederico Arnoldi wrote:
> Rohit,
>
>
>> but this package is huge ... and m new to R so if i can get some
straight commands it
>> will be really helpful ...
>>
>
> I never used "ord", but using the traditional "prcomp" and
scatterplot3d, you can do it like this:
>
> library(scatterplot3d)
> data <- read.table("your_data_file"......)
> pca <- prcomp(data) # if you are loading a microarray, matrix you
should use prcomp(t(data))
> scatterplot3d(pca$x[,1], pca$x[,2], pca$x[,3], main = "PCA 3D plot")
>
> Good luck,
> Frederico Arnoldi
>
> _________________________________________________________________
> NINGU?M PRECISA SABER O QUE VOC? EST? COMPRANDO. LEIA MAIS SOBRE
ESSE ASSUNTO AQUI.
>
> rivately.aspx?tabid=1&catid=1&WT.mc_id=1590
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
http://news.gmane.org/gmane.science.biology.informatics.conductor
>