Re: morphometric functions for R users

2010-07-15 Thread Jimena BoHe
Dr. Slice

Thank you so much. They are definitely useful.

Jimena.


-- 
Jimena Bohórquez Herrera, M. Sc.

PhD Student on Marine Sciences.
Centro Interdisciplinario de Ciencias Marinas - Instituto Politécnico
Nacional.
La Paz, Baja California Sur, México.

Researcher
Fundación Colombiana para la Investigación y Conservación de Tiburones y
Rayas - SQUALUS
Cali - Colombia

On Thu, Jul 15, 2010 at 12:29 PM, Dennis E. Slice
wrote:

>
> Subject: morphometric functions for R users
> From: marta rufino 
> Date: Thu, 15 Jul 2010 08:56:37 -0700 (PDT)
> To: morphmet_test_000 
>
> Dear list members,
>
> I have been following and enjoying Claude's book outline's part
> (morphometrics with R), which is great (at least for me... I am an R
> fan).
> Thus, I have been creating some functions to help me in some tasks. I
> though that maybe there are more pleople, working on this subject,
> that might be interested. Thus, I am sharing them here. The code is
> not the best one (I am not a programer - for example, the 'for' should
> be 'apply', etc.), but it is working :) when I have time, I can try to
> improve it.
> Feel free to use it and improve it :)
>
> :)
> Cheers,
> M
>
> ##3
> ##3
> # functions to do morphometric analysis
> ##3
> # functions done after Claude's book. 'Morphometrics with R'
> # Marta M. Rufino
> # 15-7-2010
> ##3
> ##3
> ##3
> ##3
>
> open.tps.outline=function(fil){
>  # to test: fil="D:\\MARTA\\Pos Doc\\navalha\\navalha\
> \nav_outline2_no path.tps"
>  # fil is the file name, with respective extension and path
>  # note the file is better to not include the path for each image.
>  # X and Y are outline coordinates, ind is the individual number and
> facto the fcator (i.e. image name)
>  # note that facto should then be arranged accordingly
>
># open the file
>kk=scan(fil, what="char", quote="",sep="\n", strip.white=T,
> quiet=T)
>kk=casefold(kk, upper=F)
>
>#detect outlines, number of points, etc.
>sp=grep("points=",kk) # outline points
>n=length(sp) # number of configurations
>p=as.numeric(sub("points=","",kk[sp])) #number of outline points
> in each animal
>sp.start=sp+1 #starting location of the
>sp.end=sp+p #ending position of each curve
>im=kk[grep("image=", kk)]#list of images
>im=sub("image=","",im)
>im=sub(".tif","",im); im=sub(".jpg","",im)
>
>  # extract outline coordinates
>  # this would be much better, if done with a apply function... :(
>  newd=array(NA, c(1,4))
>  colnames(newd)= c("X","Y","ind","facto")
>  for(ii in 1:n){
>
> kk1=data.frame(X=as.numeric(unlist(strsplit(kk[sp.start[ii]:sp.end[ii]],
> " ")))[seq(1,p[ii]*2,2)],
>
> Y=as.numeric(unlist(strsplit(kk[sp.start[ii]:sp.end[ii]], " ")))
> [seq(2,p[ii]*2,2)],
>   ind=ii, facto=im[ii])
>newd=rbind(newd, kk1)
>}
>newd=newd[-1,]
>  # plot(Y~X, newd[newd$N==1,], typ="o", asp=1) #Check plotting
>  xyplot(Y~X, newd, groups=facto, typ="l", aspect="iso") #Check
> plotting
>  newd
> #  if(scale){
> #  for(ii in 1:length(table(newd$ind))){
> #kk=scale(newd[newd$ind==ii,1:2], center=T, scale=F)
> #kk=kk/max(kk)
> #newd[newd$ind==ii,1:2]= kk
> #}}
>  }
>
>
>
> vharmonics=function(dat){
>  # vharmonics goes for visualize harmonics
>  # function to plot original contour (on grey) vs. NEF and
> efourier fitted contour, with varying number of harmonics (5-15).
>  # dat= data file of the original contour coordinates, X,Y
>  # note that your 'dat' should be scaled and centered (this bit,
> I have some doubts
>  names(dat)=c("X","Y")
>  par(mar=c(2,2,2,2), mfrow=c(1,1))
>  plot(dat, typ="l", main="Harmonics reconstruction of outline:
> EFA",
>  asp=1, axes=F, ylim=c(min(dat$Y), max(dat
> $Y+3)), xlim=range(dat$X))
>  box(col="grey90")
>  for(jj in 1:11){
>ii=seq(0,3,.3)[jj]; kk=c(5:16)[jj]
># Using efourier
>f1=efourier(dat, n=kk)
>f2=iefourier(f1$an, f1$bn, f1$cn, f1$dn, k=kk, n=100)
>polygon(dat$X, dat$Y+ii, col="grey80", border=0)
>lines(f2$x, f2$y+ii, col=2)
>text(dat$X[1], c(dat$Y+ii)[1], paste(kk,"harm."), col=2,
> pos=4, cex=.7)
># Using NEF instead
>f1=NEF(dat, n=kk)
>f2=iefourier(f1$A, f1$B, f1$C, f1$D, k=kk, n=100)
>lines(f2$x, f2$y+ii, col=4)
>legend("topleft", c("efourier","NEF"), text.col=c(2,4), cex=.
> 7, box.col=0)
>}}
>
>
>
> nharmonics=function(dat, P){
>  # nharmonics goes for Number of harmonics. Function to pl

Re: CVA in MorphoJ vs LDA in R

2010-07-15 Thread Stefan Schlager

Dear Louis and Martha,

the difference between lda in R and a cva - is that lda uses the 
covariance matrix and not the pooled within group covariance matrix.


greetings

Stefan

BTW.: at the moment i am working on a Rpackage that implements sliding 
of surface and curve semilandmarks (on 3D-meshes including reprojection 
- using a very fast command line app coded on the base of vcglib 
(meshlab)), it also contains a cva and some tools for importing and 
exporting meshes that can be rendered by the rgl package and for 
importing data from and to "landmark" etc. if someone is interested 
in testing (documentation is sadly abit behind), mail me.

 Am 15.07.2010 20:31, schrieb morphmet:



 Original Message 
Subject: RE: CVA in MorphoJ vs LDA in R
Date: Fri, 2 Jul 2010 12:18:31 +0100
From: marta rufino 
To: morphmet_modera...@morphometrics.org



Dear Louis,

Did you managed to reach similar results?
I am also trying to reproduce the CVA in R, so I was wondering about it.

Thank you very much,
Best wishes,
M

<>

RE: CVA in MorphoJ vs LDA in R

2010-07-15 Thread morphmet



 Original Message 
Subject:RE: CVA in MorphoJ vs LDA in R
Date:   Fri, 2 Jul 2010 12:18:31 +0100
From:   marta rufino 
To: morphmet_modera...@morphometrics.org



Dear Louis,

Did you managed to reach similar results?
I am also trying to reproduce the CVA in R, so I was wondering about it.

Thank you very much,
Best wishes,
M



morphometric functions for R users

2010-07-15 Thread Dennis E. Slice


Subject: morphometric functions for R users
From: marta rufino 
Date: Thu, 15 Jul 2010 08:56:37 -0700 (PDT)
To: morphmet_test_000 

Dear list members,

I have been following and enjoying Claude's book outline's part
(morphometrics with R), which is great (at least for me... I am an R
fan).
Thus, I have been creating some functions to help me in some tasks. I
though that maybe there are more pleople, working on this subject,
that might be interested. Thus, I am sharing them here. The code is
not the best one (I am not a programer - for example, the 'for' should
be 'apply', etc.), but it is working :) when I have time, I can try to
improve it.
Feel free to use it and improve it :)

:)
Cheers,
M

##3
##3
# functions to do morphometric analysis
##3
# functions done after Claude's book. 'Morphometrics with R'
# Marta M. Rufino
# 15-7-2010
##3
##3
##3
##3

open.tps.outline=function(fil){
  # to test: fil="D:\\MARTA\\Pos Doc\\navalha\\navalha\
\nav_outline2_no path.tps"
  # fil is the file name, with respective extension and path
  # note the file is better to not include the path for each image.
  # X and Y are outline coordinates, ind is the individual number and
facto the fcator (i.e. image name)
  # note that facto should then be arranged accordingly

# open the file
kk=scan(fil, what="char", quote="",sep="\n", strip.white=T,
quiet=T)
kk=casefold(kk, upper=F)

#detect outlines, number of points, etc.
sp=grep("points=",kk) # outline points
n=length(sp) # number of configurations
p=as.numeric(sub("points=","",kk[sp])) #number of outline points
in each animal
sp.start=sp+1 #starting location of the
sp.end=sp+p #ending position of each curve
im=kk[grep("image=", kk)]#list of images
im=sub("image=","",im)
im=sub(".tif","",im); im=sub(".jpg","",im)

  # extract outline coordinates
  # this would be much better, if done with a apply function... :(
  newd=array(NA, c(1,4))
  colnames(newd)= c("X","Y","ind","facto")
  for(ii in 1:n){

kk1=data.frame(X=as.numeric(unlist(strsplit(kk[sp.start[ii]:sp.end[ii]],
" ")))[seq(1,p[ii]*2,2)],

Y=as.numeric(unlist(strsplit(kk[sp.start[ii]:sp.end[ii]], " ")))
[seq(2,p[ii]*2,2)],
   ind=ii, facto=im[ii])
newd=rbind(newd, kk1)
}
newd=newd[-1,]
  # plot(Y~X, newd[newd$N==1,], typ="o", asp=1) #Check plotting
  xyplot(Y~X, newd, groups=facto, typ="l", aspect="iso") #Check
plotting
  newd
#  if(scale){
#  for(ii in 1:length(table(newd$ind))){
#kk=scale(newd[newd$ind==ii,1:2], center=T, scale=F)
#kk=kk/max(kk)
#newd[newd$ind==ii,1:2]= kk
#}}
  }



vharmonics=function(dat){
  # vharmonics goes for visualize harmonics
  # function to plot original contour (on grey) vs. NEF and
efourier fitted contour, with varying number of harmonics (5-15).
  # dat= data file of the original contour coordinates, X,Y
  # note that your 'dat' should be scaled and centered (this bit,
I have some doubts
  names(dat)=c("X","Y")
  par(mar=c(2,2,2,2), mfrow=c(1,1))
  plot(dat, typ="l", main="Harmonics reconstruction of outline:
EFA",
  asp=1, axes=F, ylim=c(min(dat$Y), max(dat
$Y+3)), xlim=range(dat$X))
  box(col="grey90")
  for(jj in 1:11){
ii=seq(0,3,.3)[jj]; kk=c(5:16)[jj]
# Using efourier
f1=efourier(dat, n=kk)
f2=iefourier(f1$an, f1$bn, f1$cn, f1$dn, k=kk, n=100)
polygon(dat$X, dat$Y+ii, col="grey80", border=0)
lines(f2$x, f2$y+ii, col=2)
text(dat$X[1], c(dat$Y+ii)[1], paste(kk,"harm."), col=2,
pos=4, cex=.7)
# Using NEF instead
f1=NEF(dat, n=kk)
f2=iefourier(f1$A, f1$B, f1$C, f1$D, k=kk, n=100)
lines(f2$x, f2$y+ii, col=4)
legend("topleft", c("efourier","NEF"), text.col=c(2,4), cex=.
7, box.col=0)
}}



nharmonics=function(dat, P){
  # nharmonics goes for Number of harmonics. Function to plot and
estimate the power and variance explained according to the number of
harmonics
  # dat is a data frame with all outline's coordinates: i.e. dat=newd[,
1:2] # X and Y coordinates of all outlines
  # P=100 # number of points in each outline.

  # Store first 20 harmonics in a file
  harm=matrix(NA,N,20*4)
  for(ii in 1:N){
N= dim(dat)[1]/P #total number of individuals
kk=rep(1:N,e=P)
Ne=efourier(dat[kk==ii,], n=20) #taut[,,ii] are the xy coordinates
of the points.
   # When we do the NEF, we obtain 50 harmonic
coefficients of each type (A, B, C and D).

new publication

2010-07-15 Thread morphmet

Also added to the Library page at http://www.morphometrics.org.

-the morphmet mod (dslice)


 Original Message 
Subject:new publication
Date:   Fri, 2 Jul 2010 11:43:12 +0100
From:   marta rufino 
To: morphmet_modera...@morphometrics.org



Dear Dennis,

Here are my publications,about this subject, in case you want to add to
the list.

Lombarte, A., M. M. Rufino, and P. Sánchez. 2006. Statolith identication
of Mediterranean Octopodidae, Sepiidae, Loliginidae, Ommastrephidae and
Enoploteuthidae based on warp analyses. Journal of the Marine Biological
Association of UK 86:1-8. Reprints available by request from
marta.m.rufino(at)gmail(dot)com
Rufino, M. M., P. Abelló, and A. B. Yule. 2004. The effect of alcohol
and freezing preservation on carapace size and shape in Liocarcinus
depurator (Crustacea, Brachyura). P.^Pp. 45-53 in
Morphometrics-Applications in Biology and Paleontology, A. M. T. Elewa,
ed. Springer Verlag, Berlin.
Rufino, M. M., P. Abelló, and A. B. Yule. 2006. Geographic and gender
shape differences in the carapace of Liocarcinus depurator (Brachyura:
Portunidae) using geometric morphometrics and the influence of a
digitizing method. Journal of Zoology 269:458-465. Reprints available by
request from marta.m.rufino(at)gmail(dot)com
Rufino, M. M., M. B. Gaspar, A. M. Pereira, and P. Vasconcelos. 2007.
The use of shape to distinguish Chamelea gallina and Chamelea striatula
(Bivalvia: Veneridae): linear and geometric morphometric methods.
Journal of Morphology 267:1433–1440. Reprints available by request from
marta.m.rufino(at)gmail(dot)com
Sousa, R., R. Freire, Rufino M. M., Méndez J., Gaspar M., Antunes C.,
and G. L. 2007. Genetic and shell morphological variability of the
invasive bivalve Corbicula fluminea (Müller, 1774) in two Portuguese
estuaries. Estuarine, Coastal and Shelf Science 74:166-174. Reprints
available by request from marta.m.rufino(at)gmail(dot)com

All the best,
Marta



new publication

2010-07-15 Thread morphmet

Also added to the Library page at http://www.morphometrics.org.

-the morphmet mod (dslice)


 Original Message 
Subject:new publication
Date:   Sun, 27 Jun 2010 00:16:46 -0700 (PDT)
From:   Saber Sadeghi 
To: morphmet_modera...@morphometrics.org



Dear Morphometricians

excuse me for delaying,

Sadeghi, S., Adriaens, D., Dumont, H.J. (2009). Geometric morphometric
analysis of wing shape variation in ten European populations of
/Calopteryx splendens/ Harris (1782) (Zygoptera: Odonata).
/Odonatologica/. 38 (4): 343-360.

Reprint is available by request from ssade...@shirazu.ac.ir


Best Wishes

Saber Sadeghi




New Publication: floral morphometrics

2010-07-15 Thread morphmet

Also added to the Library page at http://www.morphometrics.org.

-the morphmet mod (dslice)

 Original Message 
Subject: floral morphometrics
Date: Fri, 25 Jun 2010 22:50:52 +0200
From: Christoph P. E. Zollikofer 
To: morphmet_modera...@morphometrics.org

Dear Dennis,
This might be of interest to the morphometrics community:

Timotheüs van der Niet, Christoph P.E. Zollikofer, Marcia S. Ponce de
León, Steven D. Johnson, H. Peter Linder (in press):
Three-dimensional geometric morphometrics for studying floral shape
variation
http://dx.doi.org/10.1016/j.tplants.2010.05.005

Best,
Christoph

-
Prof. Dr. Christoph P. E. Zollikofer
Anthropological Institute
University of Zurich
Winterthurerstrasse 190
CH-8057 Zurich
Tel. +41 44 635 5427
Fax. +41 44 635 6886
www.aim.uzh.ch
zo...@aim.uzh.ch
-