Quick tutorial for analysing your own data
--------------------------------------------------------
[0. Download R (http://cran.r-project.org) and install it
if you haven't done so already. Install the shapes package.]
1. Start R on your machine
2. load in the shapes library by typing:
library(shapes)
3. Read in your data. This is often the hardest part!
For 2D points the co-ordinates should be in a file in the form:
x1 y1 x2 y2 x3 y3 ... xk yk
with object 1 followed by object 2 followed by object 3 .... etc.
See: http://www.maths.nott.ac.uk/~ild/bookdata
for some examples. The co-ordinates should be white space
separated and return characters
are ignored. For 3D points the data should be in a file in the form:
x1 y1 z1 x2 y2 z2 x3 y3 z3 ... xk yk zk
for each object.
One way to read in the data is to type in:
k<-8 #Number of points
m<-2 #Number of dimensions
new.dat<-read.in("c:/Windows/Desktop/gorf.dat",k,m)
#Note the use of / here
#Note <- is the same thing as =
Any text after a # sign is just a comment and need not be typed again of course!
There are some datasets already loaded into the shapes library
(e.g. gorf.dat,gorm.dat,qset2.dat,qcet2.dat,qlet2.dat,macm.dat,macf.dat,digit3.dat).
4. Carry out shape analysis - see the manual for examples.
e.g.
plotshapes(new.dat) #plot the data
out.procf<-procGPA(new.dat) #carries out generalised Procrustes analysis of females
plotshapes(out.procf$rotated) #plots the Procrustes rotated objects
shapepca(out.procf) #plots the first few PCs
out.procm<-procGPA(gorm.dat) #carries out generalised Procrustes analysis of males
plotshapes(out.procm$rotated) #plots the Procrustes rotated objects
shapepca(out.procm) #plots the first few PCs
tpsgrid(out.procf$mshape,out.procm$mshape,-0.6,-0.6,1.2) #TPS grid from female mean to male mean
riemdist(out.procf$mshape,out.procm$mshape) #the Riemannian shape distance between the
#mean shapes
5. For further information on each command, including options type
help(procGPA)
For example if you want to carry out Procrustes analysis without scaling then type:
out.noscale<-procGPA(new.dat,scale=FALSE)
6. Further examples can be seen in the help() commands or in the manual.
Also, there is a short demo obtained by typing:
demo(shapes)
Ian Dryden 18-12-03