Re: [MORPHMET] Re: Trouble with 2-D morphomeric analysis in geomorph

2018-08-13 Thread Carmelo Fruciano

Hard to tell why it is not working for you.
Assuming that you have the specimens "stacked" one on top of each other, 
each of them with 30 landmarks in 2D, it should work changing the 
relevant parameters.
My suggestion to you would be to carefully check what these two lines 
are doing


data$specimen=as.factor(unlist(lapply(seq_len(landmarks), function(x) 
rep(seq_len(landmarks)[x],30

data$landmark=as.factor(rep(1:30,30))

As they comprise various nested calls, you might find it useful to try 
on the nested part first and then run the whole call.
If checking data$specimen and data$landmark you get indeed the right 
number of rows and the right names, I don't see why the reshaping 
shouldn't work.


I hope this helps.
Carmelo


On 12/08/2018 22:33, Ian F wrote:
im sorry to ask so many questions. How would I reformat the script you 
have provided to convert 2686 observations of 2 variables (x and y 
coordinates) into wide format? when i try to alter it i end up with 
millions of rows.


On Thursday, August 2, 2018 at 1:32:02 PM UTC-4, Ian F wrote:

I am trying to do an analysis of three specimens. I am using
semi-landmarks and having trouble. perhaps someone can point out mt
error? these are my results

Generalized Procrustes Analysis
with Partial Procrustes Superimposition

-4 fixed landmarks
12 semilandmarks (sliders)
2-dimensional landmarks
6 GPA iterations to converge
Minimized Bending Energy used


Consensus (mean) Configuration

                X           Y
[1,]  0.51447153 -0.03794928
[2,]  0.36957021  0.11431610
[3,] -0.11602250  0.19898458
[4,] -0.40489951  0.11095030
[5,] -0.43738229 -0.09965594
[6,] -0.20913543 -0.09698422
[7,]  0.04257626 -0.09131803
[8,]  0.29799009 -0.04811314

it should be three individuals with 4 landmarks and 4 sliders each.
i want to perform PCA on the procrustes coordinates. my code and
data are below. Im new to R and its probably an easy fix im just
really confused. any help is greatly appreciated.






Code:    Y <- arrayspecs(coordsrformat, k=2, p= ncol(coordsrformat)/2)

slidermatrix

Y.gpa <- gpagen(Y,curves=slidermatrix)
summary(Y.gpa)
plot(Y.gpa)

Y.gpa <- gpagen(Y,curves=slidermatrix,ProcD=FALSE )
summary(Y.gpa)
plot(Y.gpa)
a<-(Y.gpa$coords)
plotTangentSpace(a)




slider matrix:

beforeslide after
567
781
123
345
187
765
543
321
123
345
567
781


coordsrformat:


163018271530   15491198
13459081557  8331840
102718951223   19071417 1887
276710812633   15812139
204716931753   15351159
184110672151   10092437 1071
29569282936  16922112
236013001784   13041016
17008882084  8322480 872



--
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
---
You received this message because you are subscribed to the Google 
Groups "MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to morphmet+unsubscr...@morphometrics.org 
.


--


==
Carmelo Fruciano
Institute of Biology
Ecole Normale Superieure - Paris
CNRS
http://www.fruciano.it/research/

--
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
--- 
You received this message because you are subscribed to the Google Groups "MORPHMET" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to morphmet+unsubscr...@morphometrics.org.


[MORPHMET] Re: Trouble with 2-D morphomeric analysis in geomorph

2018-08-12 Thread Ian F
im sorry to ask so many questions. How would I reformat the script you have 
provided to convert 2686 observations of 2 variables (x and y coordinates) 
into wide format? when i try to alter it i end up with millions of rows. 

On Thursday, August 2, 2018 at 1:32:02 PM UTC-4, Ian F wrote:
>
> I am trying to do an analysis of three specimens. I am using 
> semi-landmarks and having trouble. perhaps someone can point out mt error? 
> these are my results 
>
> Generalized Procrustes Analysis 
> with Partial Procrustes Superimposition 
>
> -4 fixed landmarks 
> 12 semilandmarks (sliders) 
> 2-dimensional landmarks 
> 6 GPA iterations to converge 
> Minimized Bending Energy used 
>
>
> Consensus (mean) Configuration 
>
>X   Y 
> [1,]  0.51447153 -0.03794928 
> [2,]  0.36957021  0.11431610 
> [3,] -0.11602250  0.19898458 
> [4,] -0.40489951  0.11095030 
> [5,] -0.43738229 -0.09965594 
> [6,] -0.20913543 -0.09698422 
> [7,]  0.04257626 -0.09131803 
> [8,]  0.29799009 -0.04811314 
>
> it should be three individuals with 4 landmarks and 4 sliders each. i want 
> to perform PCA on the procrustes coordinates. my code and data are below. 
> Im new to R and its probably an easy fix im just really confused. any help 
> is greatly appreciated.   
>
>
>
>
>
>
> Code:Y <- arrayspecs(coordsrformat, k=2, p= ncol(coordsrformat)/2) 
>
> slidermatrix 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix)   
> summary(Y.gpa) 
> plot(Y.gpa) 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix,ProcD=FALSE )   
> summary(Y.gpa) 
> plot(Y.gpa) 
> a<-(Y.gpa$coords) 
> plotTangentSpace(a) 
>
>
>
>
> slider matrix:   
>
> beforeslideafter 
> 567 
> 781 
> 123 
> 345 
> 187 
> 765 
> 543 
> 321 
> 123 
> 345 
> 567 
> 781 
>
>
> coordsrformat: 
>
>
> 163018271530154911981345908   
>  15578331840102718951223
> 190714171887 
>
> 2767108126331581213920471693  
>   175315351159184110672151
> 100924371071 
>
> 295692829361692211223601300   
>  17841304101617008882084
> 8322480872 
>
>
>
>
>

-- 
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
--- 
You received this message because you are subscribed to the Google Groups 
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to morphmet+unsubscr...@morphometrics.org.


[MORPHMET] Re: Trouble with 2-D morphomeric analysis in geomorph

2018-08-10 Thread Ian F
Thank you very much Carmelo. You have been immensely helpful.

On Thursday, August 2, 2018 at 1:32:02 PM UTC-4, Ian F wrote:
>
> I am trying to do an analysis of three specimens. I am using 
> semi-landmarks and having trouble. perhaps someone can point out mt error? 
> these are my results 
>
> Generalized Procrustes Analysis 
> with Partial Procrustes Superimposition 
>
> -4 fixed landmarks 
> 12 semilandmarks (sliders) 
> 2-dimensional landmarks 
> 6 GPA iterations to converge 
> Minimized Bending Energy used 
>
>
> Consensus (mean) Configuration 
>
>X   Y 
> [1,]  0.51447153 -0.03794928 
> [2,]  0.36957021  0.11431610 
> [3,] -0.11602250  0.19898458 
> [4,] -0.40489951  0.11095030 
> [5,] -0.43738229 -0.09965594 
> [6,] -0.20913543 -0.09698422 
> [7,]  0.04257626 -0.09131803 
> [8,]  0.29799009 -0.04811314 
>
> it should be three individuals with 4 landmarks and 4 sliders each. i want 
> to perform PCA on the procrustes coordinates. my code and data are below. 
> Im new to R and its probably an easy fix im just really confused. any help 
> is greatly appreciated.   
>
>
>
>
>
>
> Code:Y <- arrayspecs(coordsrformat, k=2, p= ncol(coordsrformat)/2) 
>
> slidermatrix 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix)   
> summary(Y.gpa) 
> plot(Y.gpa) 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix,ProcD=FALSE )   
> summary(Y.gpa) 
> plot(Y.gpa) 
> a<-(Y.gpa$coords) 
> plotTangentSpace(a) 
>
>
>
>
> slider matrix:   
>
> beforeslideafter 
> 567 
> 781 
> 123 
> 345 
> 187 
> 765 
> 543 
> 321 
> 123 
> 345 
> 567 
> 781 
>
>
> coordsrformat: 
>
>
> 163018271530154911981345908   
>  15578331840102718951223
> 190714171887 
>
> 2767108126331581213920471693  
>   175315351159184110672151
> 100924371071 
>
> 295692829361692211223601300   
>  17841304101617008882084
> 8322480872 
>
>
>
>
>

-- 
MORPHMET may be accessed via its webpage at http://www.morphometrics.org
--- 
You received this message because you are subscribed to the Google Groups 
"MORPHMET" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to morphmet+unsubscr...@morphometrics.org.


Re: [MORPHMET] Re: Trouble with 2-D morphomeric analysis in geomorph

2018-08-09 Thread Carmelo Fruciano

Dear Ian,
it sounds more like an R data manipulation issue (which admittedly can 
be a pain) than a morphometric issue.
Basically you want to convert from a "long" format to a "wide" format. 
You can read about this in multiple places on the internet, such as

http://www.cookbook-r.com/Manipulating_data/Converting_data_between_wide_and_long_format/
https://www.statmethods.net/management/reshape.html

I have tried my hand on your data, see code below. I'm sure there are 
1000 other ways you can do this, including in a more elegant fashion...
But in general what I did is to create some indexing variables for 
specimen and landmark and used them to restructure the data.


I hope this helps,
Carmelo


--


==
Carmelo Fruciano
Institute of Biology
Ecole Normale Superieure - Paris
CNRS
http://www.fruciano.it/research/




##
##

data <- read.table("Trial2rawcoords.txt", header=TRUE)
# Import data

landmarks=30
# Number of landmarks

data$specimen=as.factor(unlist(lapply(seq_len(landmarks), function(x) 
rep(seq_len(landmarks)[x],30

data$landmark=as.factor(rep(1:30,30))
# Create two factors to index the various x,y coordinates

library(reshape)
data_wide=reshape(data,
   idvar = "specimen",
   timevar = "landmark",
   direction = "wide")
# Use reshape to convert from long to wide format

landmarknames=unlist(lapply(seq_len(landmarks), function(x) 
c(paste("x.",x,sep=""),paste("y.",x,sep=""

# Create ad hoc names to use for indexing

data_wide=cbind(data_wide$specimen,data_wide$genus.1,data_wide[,landmarknames])
# Get only the useful columns

##
##




On 09/08/2018 01:53, Ian F wrote:
I figured out what the issue was. thank you for your help. regrettably I 
have encountered another issue, any insight  would be much appreciated. 
I am trying to reformat a spreadsheet so that each individual is a row 
and each column represents an x or y coordinate. my data set consists of 
30 specimens each with 30 landmarks. I keep getting the error code  
Error in `[<-`(`*tmp*`, j, 1, value = sub.data[1, 1]) :

   subscript out of bounds.

My data is in the link and my code is as follows.


# reformat data from imageJ into R compatible format.

data <- read.table(Trial2rawcoords.txt, header=TRUE)

len <- length(data$X)
overall.table <- matrix(nrow=len/30, ncol=(30*2)+1)
overall.length <- len/30
for(j in c(1:overall.length)) {
print(j)

sub.data <- as.matrix(data[ (1+30*(j-1)):((1+30*(j-1))+29), 2:4])

overall.table[j,1] <- sub.data[1, 1]
overall.table[j,2:3] <- sub.data[1, 2:3]
overall.table[j,4:5] <- sub.data[2, 2:3]
overall.table[j,6:7] <- sub.data[3, 2:3]
overall.table[j,8:9] <- sub.data[4, 2:3]
overall.table[j,10:11] <- sub.data[5, 2:3]
overall.table[j,12:13] <- sub.data[6, 2:3]
overall.table[j,14:15] <- sub.data[7, 2:3]
overall.table[j,16:17] <- sub.data[8, 2:3]
overall.table[j,18:19] <- sub.data[9, 2:3]
overall.table[j,20:21] <- sub.data[10, 2:3]
overall.table[j,22:23] <- sub.data[11, 2:3]
overall.table[j,24:25] <- sub.data[12, 2:3]
overall.table[j,26:27] <- sub.data[13, 2:3]
overall.table[j,28:29] <- sub.data[14, 2:3]
overall.table[j,30:31] <- sub.data[15, 2:3]
overall.table[j,32:33] <- sub.data[16, 2:3]
overall.table[j,34:35] <- sub.data[17, 2:3]
overall.table[j,36:37] <- sub.data[18, 2:3]
overall.table[j,38:39] <- sub.data[19, 2:3]
overall.table[j,40:41] <- sub.data[20, 2:3]
overall.table[j,42:43] <- sub.data[21, 2:3]
overall.table[j,44:45] <- sub.data[22, 2:3]
overall.table[j,46:47] <- sub.data[23, 2:3]
overall.table[j,48:49] <- sub.data[24, 2:3]
overall.table[j,50:51] <- sub.data[25, 2:3]
overall.table[j,52:53] <- sub.data[26, 2:3]
overall.table[j,54:55] <- sub.data[27, 2:3]
overall.table[j,56:57] <- sub.data[28, 2:3]
overall.table[j,58:59] <- sub.data[29, 2:3]
overall.table[j,60:61] <- sub.data[30, 2:3]
   }
# Confirm the above loop worked.

head(overall.table)
tail(overall.table)
# Assign the new table column names and write out the reformatted table 
to the working directory.


colnames(overall.table) <- c("number", "genus", "x1", "y1", "x2", "y2", 
"x3", "y3", "x4", "y4", "x5", "y5", "x6", "y6", "x7", "y7", "x8", "y8", 
"x9", "y9", "x10", "y10", "x11", "y11", "x12", "y12", "x13", "y13", 
"x14", "y14", "x15", "y15", "x16", "y16", "x17", 
"y17","x18","Y18","X19","Y19","X20","Y20","X21","Y21","X22","Y22","X23","Y23","X24","Y24","X25","Y25","X26","Y26","X27","Y27","X28","Y28","X29","Y29","X30","Y30")

write.table(overall.table, "reformat.txt")



On Thursday, August 2, 2018 at 1:32:02 PM UTC-4, Ian F wrote:

I am trying to do an analysis of three specimens. I am using
semi-landmarks and having trouble. perhaps someone can point out mt
error? these are my results

Generalized Procrustes Analysis
with Partial Procrustes Superimposition

-4 fixed landmarks
12 semilandmarks (sliders)
2-dimensional landmarks
6 GPA iterations to converge
Minimized Be

[MORPHMET] Re: Trouble with 2-D morphomeric analysis in geomorph

2018-08-08 Thread Ian F
I figured out what the issue was. thank you for your help. regrettably I 
have encountered another issue, any insight  would be much appreciated. I 
am trying to reformat a spreadsheet so that each individual is a row and 
each column represents an x or y coordinate. my data set consists of 30 
specimens each with 30 landmarks. I keep getting the error code  Error in 
`[<-`(`*tmp*`, j, 1, value = sub.data[1, 1]) : 
  subscript out of bounds. 

My data is in the link and my code is as follows.


# reformat data from imageJ into R compatible format. 

data <- read.table(Trial2rawcoords.txt, header=TRUE)

len <- length(data$X)
  
overall.table <- matrix(nrow=len/30, ncol=(30*2)+1)
  
overall.length <- len/30
  
for(j in c(1:overall.length)) {
  
print(j)

sub.data <- as.matrix(data[ (1+30*(j-1)):((1+30*(j-1))+29), 2:4])

overall.table[j,1] <- sub.data[1, 1]
overall.table[j,2:3] <- sub.data[1, 2:3]
overall.table[j,4:5] <- sub.data[2, 2:3]
overall.table[j,6:7] <- sub.data[3, 2:3]
overall.table[j,8:9] <- sub.data[4, 2:3]
overall.table[j,10:11] <- sub.data[5, 2:3]
overall.table[j,12:13] <- sub.data[6, 2:3]
overall.table[j,14:15] <- sub.data[7, 2:3]
overall.table[j,16:17] <- sub.data[8, 2:3]
overall.table[j,18:19] <- sub.data[9, 2:3]
overall.table[j,20:21] <- sub.data[10, 2:3]
overall.table[j,22:23] <- sub.data[11, 2:3]
overall.table[j,24:25] <- sub.data[12, 2:3]
overall.table[j,26:27] <- sub.data[13, 2:3]
overall.table[j,28:29] <- sub.data[14, 2:3]
overall.table[j,30:31] <- sub.data[15, 2:3]
overall.table[j,32:33] <- sub.data[16, 2:3]
overall.table[j,34:35] <- sub.data[17, 2:3]
overall.table[j,36:37] <- sub.data[18, 2:3]
overall.table[j,38:39] <- sub.data[19, 2:3]
overall.table[j,40:41] <- sub.data[20, 2:3]
overall.table[j,42:43] <- sub.data[21, 2:3]
overall.table[j,44:45] <- sub.data[22, 2:3]
overall.table[j,46:47] <- sub.data[23, 2:3]
overall.table[j,48:49] <- sub.data[24, 2:3]
overall.table[j,50:51] <- sub.data[25, 2:3]
overall.table[j,52:53] <- sub.data[26, 2:3]
overall.table[j,54:55] <- sub.data[27, 2:3]
overall.table[j,56:57] <- sub.data[28, 2:3]
overall.table[j,58:59] <- sub.data[29, 2:3]
overall.table[j,60:61] <- sub.data[30, 2:3]
  }

# Confirm the above loop worked.

head(overall.table)
tail(overall.table)

# Assign the new table column names and write out the reformatted table to 
the working directory.

colnames(overall.table) <- c("number", "genus", "x1", "y1", "x2", "y2", 
"x3", "y3", "x4", "y4", "x5", "y5", "x6", "y6", "x7", "y7", "x8", "y8", 
"x9", "y9", "x10", "y10", "x11", "y11", "x12", "y12", "x13", "y13", "x14", 
"y14", "x15", "y15", "x16", "y16", "x17", 
"y17","x18","Y18","X19","Y19","X20","Y20","X21","Y21","X22","Y22","X23","Y23","X24","Y24","X25","Y25","X26","Y26","X27","Y27","X28","Y28","X29","Y29","X30","Y30")

write.table(overall.table, "reformat.txt")



On Thursday, August 2, 2018 at 1:32:02 PM UTC-4, Ian F wrote:
>
> I am trying to do an analysis of three specimens. I am using 
> semi-landmarks and having trouble. perhaps someone can point out mt error? 
> these are my results 
>
> Generalized Procrustes Analysis 
> with Partial Procrustes Superimposition 
>
> -4 fixed landmarks 
> 12 semilandmarks (sliders) 
> 2-dimensional landmarks 
> 6 GPA iterations to converge 
> Minimized Bending Energy used 
>
>
> Consensus (mean) Configuration 
>
>X   Y 
> [1,]  0.51447153 -0.03794928 
> [2,]  0.36957021  0.11431610 
> [3,] -0.11602250  0.19898458 
> [4,] -0.40489951  0.11095030 
> [5,] -0.43738229 -0.09965594 
> [6,] -0.20913543 -0.09698422 
> [7,]  0.04257626 -0.09131803 
> [8,]  0.29799009 -0.04811314 
>
> it should be three individuals with 4 landmarks and 4 sliders each. i want 
> to perform PCA on the procrustes coordinates. my code and data are below. 
> Im new to R and its probably an easy fix im just really confused. any help 
> is greatly appreciated.   
>
>
>
>
>
>
> Code:Y <- arrayspecs(coordsrformat, k=2, p= ncol(coordsrformat)/2) 
>
> slidermatrix 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix)   
> summary(Y.gpa) 
> plot(Y.gpa) 
>
> Y.gpa <- gpagen(Y,curves=slidermatrix,ProcD=FALSE )   
> summary(Y.gpa) 
> plot(Y.gpa) 
> a<-(Y.gpa$coords) 
> plotTangentSpace(a) 
>
>
>
>
> slider matrix:   
>
> beforeslideafter 
> 567 
> 781 
> 123 
> 345 
> 187 
> 765 
> 543 
> 321 
> 123 
> 345 
> 567 
> 781 
>
>
> coordsrformat: 
>
>
> 163018271530154911981345908   
>  15578331840102718951223
> 190714171887 
>
> 2767108126331581213920471693  
>   175315351159184110672151
> 10092437