trouble with procD.pgls function

18 views
Skip to first unread message

Omar Mejía

unread,
Jun 30, 2025, 9:54:19 AMJun 30
to geomorph R package
Hi , I have trouble with procD.pgls function:

This is my code

landmarks=readland.tps("test.tps",specID="ID")
Procrustes=gpagen(landmarks)

phy=read.tree("Oscar.tre")

habitat=read.csv("habitat.csv", row.names=1)

species=read.csv("species.csv", row.names=1)

name.check(Procrustes,phy)

> name.check(Procrustes,phy)
[1] "OK"

gdf2 <- geomorph.data.frame(Procrustes, species = species,
                            habitat =habitat,phy=phy)
attributes(gdf2)

$names
[1] "species.x" "habitat.x" "coords"    "Csize"    
[5] "phy"      

$class
[1] "geomorph.data.frame"

fit1 <- procD.lm(coords ~ species.x,
                 data = gdf2, iter = 999, turbo = TRUE,
                 RRPP = FALSE, print.progress = FALSE) # randomize raw values

summary(fit1)

Analysis of Variance, using Residual Randomization
Permutation procedure: Randomization of raw values (residuals of mean)
Number of permutations: 1000
Estimation method: Ordinary Least Squares
Sums of Squares and Cross-products: Type I
Effect sizes (Z) based on F distributions

Df       SS        MS Rsq   F  Z
species.x 20 0.046158 0.0023079   1 NaN  0
Total     20 0.046158                    
Pr(>F)    
species.x < 2.2e-16 ***
  Total                  
---
  Signif. codes:  
  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

####Here appears the trouble###
sp.pgls <- procD.pgls(coords ~ Csize, phy = phy, data = gdf2)
Sums of Squares calculations: 1000 permutations.
|==========================================| 100%
Error in h(simpleError(msg, call)) :
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': una dimensión es cero

I read in another message that the trouble arise with RRPP library, I am using version 2.1.2 updated directly from github

If I create the dataframe taking out the species and habitat classifiers its the same case

I have no problem running the plethspecies example 

KIndly appreciate any help

Best regards


Adams, Dean [EEOB]

unread,
Jun 30, 2025, 3:18:59 PMJun 30
to geomorph R package
Omar,

An analysis of Shape ~ Species does not make sense to perform, because there is no replication. Every species is found only once in the dataset, so the NaN is all that can be observed for certain components of the linear model.

As to the second issue (the error), please read previous posts on this google group. There was a bug that was fixed in RRPP and should likely resolve your issue also. Please re-install geomorph and RRPP from their Github repositories (not CRAN).

Dean
--
Dr. Dean C. Adams
Distinguished Professor
Department of Ecology, Evolution, and Organismal Biology
Iowa State University

From: geomorph-...@googlegroups.com <geomorph-...@googlegroups.com> on behalf of Omar Mejía <posgradobio...@gmail.com>
Sent: Monday, June 30, 2025 8:54 AM
To: geomorph R package <geomorph-...@googlegroups.com>
Subject: [geomorph-r-package] trouble with procD.pgls function
 
--
You received this message because you are subscribed to the Google Groups "geomorph R package" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geomorph-r-pack...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/geomorph-r-package/356657e5-8c95-49e7-acf6-99e484d49b85n%40googlegroups.com.

Omar Mejía

unread,
Jul 1, 2025, 9:46:31 AMJul 1
to geomorph-...@googlegroups.com
Dear Dean,

Kindly appreciate  your message, I follow your suggestion, uninstall both libraries, geomorph and RRPP, and then install directly from github using devtools and the problem persists. I spent several hours trying to solve the problem without success :(

This is what I am doing:

landmarks=readland.tps("test.tps",specID="None")
Procrustes=gpagen(landmarks)
phy=read.tree("Oscar.tre")


gdf2 <- geomorph.data.frame(Procrustes,phy=phy)
attributes(gdf2)




sp.pgls <- procD.pgls(coords ~ Csize, phy = phy, data = gdf2)

Preliminary Model Fit...
Error: Data names and covariance matrix names do not match.

#### I check the names in both, my tps and phylogeny and apparently match###

name.check(Procrustes,phy)
[1] "OK"

##but i found errors with this function###
match(rownames(Procrustes),phy$tip.labels)
integer(0)

obj<-name.check(phy,landmarks)
obj

$tree_not_data
[1] "Chuco_intermedium"          "Chuco_microphthalmus"      
[3] "Cincelichthys_pearsei"      "Kihnichthys_ufermanni"    
[5] "Maskaheros_argenteus"       "Maskaheros_regani"        
[7] "Oscura_heterospila"         "Paraneetroplus_bulleri"    
[9] "Paraneetroplus_nebuliferus" "Rheoheros_lentiginosus"    
[11] "Theraps_irregularis"        "Trichromis_salvini"        
[13] "Vieja_bifasciata"           "Vieja_breidohri"          
[15] "Vieja_fenestrata"           "Vieja_guttulata"          
[17] "Vieja_hartwegi"             "Vieja_maculicauda"        
[19] "Vieja_melanurus"            "Vieja_zonata"              
[21] "Wajpamheros_nourissati"    

$data_not_tree
NULL

######  I see that my coords have not name###

dim(Procrustes$coords)
[1] 44  2 21

dimnames(Procrustes$coords)
[[3]]
[1] "1"  "2"  "3"  "4"  "5"  "6"  "7"  "8"  "9"  "10" "11" "12" "13" "14" "15"
[16] "16" "17" "18" "19" "20" "21"

### I follow suggestions and assign names  ####

newnames=c("Paraneetroplus_nebuliferus","Chuco_intermedium","Chuco_microphtalmus","Cincelichthys_pearsei","Kihnichthys_uefermanni","Maskaheros_argenteus","Maskaheros_regani","Oscura_heterospila","Paraneetroplus_bulleri","Rheoheros_lentiginosus","Theraps_irregularis","Thrichromis_salvini","Vieja_bifasciata","Vieja_breidhori","Vieja_fenestrata","Vieja_gutttulata","Vieja_hartwegii","Vieja_maculicauda","Vieja_melanurus","Vieja_zonata","Wajpamheros_nourisatti")
dimnames(Procrustes$coords)[[3]]=newnames
dimnames(Procrustes$coords)


### Now my coords have a name  ###


[[3]]
[1] "Paraneetroplus_nebuliferus" "Chuco_intermedium"        
[3] "Chuco_microphtalmus"        "Cincelichthys_pearsei"    
[5] "Kihnichthys_uefermanni"     "Maskaheros_argenteus"      
[7] "Maskaheros_regani"          "Oscura_heterospila"        
[9] "Paraneetroplus_bulleri"     "Rheoheros_lentiginosus"    
[11] "Theraps_irregularis"        "Thrichromis_salvini"      
[13] "Vieja_bifasciata"           "Vieja_breidhori"          
[15] "Vieja_fenestrata"           "Vieja_gutttulata"          
[17] "Vieja_hartwegii"            "Vieja_maculicauda"        
[19] "Vieja_melanurus"            "Vieja_zonata"              
[21] "Wajpamheros_nourisatti"    

## names apparently are ok ###
name.check(Procrustes,phy)
[1] "OK"

### but not   ###

match(rownames(Procrustes),phy$tip.labels)
integer(0)

obj<-name.check(phy,landmarks)
obj

$tree_not_data
[1] "Chuco_intermedium"          "Chuco_microphthalmus"      
[3] "Cincelichthys_pearsei"      "Kihnichthys_ufermanni"    
[5] "Maskaheros_argenteus"       "Maskaheros_regani"        
[7] "Oscura_heterospila"         "Paraneetroplus_bulleri"    
[9] "Paraneetroplus_nebuliferus" "Rheoheros_lentiginosus"    
[11] "Theraps_irregularis"        "Trichromis_salvini"        
[13] "Vieja_bifasciata"           "Vieja_breidohri"          
[15] "Vieja_fenestrata"           "Vieja_guttulata"          
[17] "Vieja_hartwegi"             "Vieja_maculicauda"        
[19] "Vieja_melanurus"            "Vieja_zonata"              
[21] "Wajpamheros_nourissati"    

$data_not_tree
NULL

#### I compare the order of the names in both, Procrustes$coords and tiplabels,
I assume that R needs that the names must be in the same position to match###

dimnames(Procrustes$coords)
[[3]]
[1] "Paraneetroplus_nebuliferus" "Chuco_intermedium"        
[3] "Chuco_microphtalmus"        "Cincelichthys_pearsei"    
[5] "Kihnichthys_uefermanni"     "Maskaheros_argenteus"      
[7] "Maskaheros_regani"          "Oscura_heterospila"        
[9] "Paraneetroplus_bulleri"     "Rheoheros_lentiginosus"    
[11] "Theraps_irregularis"        "Thrichromis_salvini"      
[13] "Vieja_bifasciata"           "Vieja_breidhori"          
[15] "Vieja_fenestrata"           "Vieja_gutttulata"          
[17] "Vieja_hartwegii"            "Vieja_maculicauda"        
[19] "Vieja_melanurus"            "Vieja_zonata"              
[21] "Wajpamheros_nourisatti"    


phy$tip.label
[1] "Chuco_microphthalmus"       "Chuco_intermedium"        
[3] "Cincelichthys_pearsei"      "Kihnichthys_ufermanni"    
[5] "Theraps_irregularis"        "Wajpamheros_nourissati"    
[7] "Rheoheros_lentiginosus"     "Oscura_heterospila"        
[9] "Maskaheros_argenteus"       "Maskaheros_regani"        
[11] "Paraneetroplus_bulleri"     "Paraneetroplus_nebuliferus"
[13] "Vieja_bifasciata"           "Vieja_breidohri"          
[15] "Vieja_hartwegi"             "Vieja_fenestrata"          
[17] "Vieja_guttulata"            "Vieja_zonata"              
[19] "Vieja_maculicauda"          "Vieja_melanurus"          
[21] "Trichromis_salvini"  

###  I cannot change my phylogeny topology, so, I change the order of
the species in my tps file and set names according to phy tip labels ##

newnames2=c("Chuco_microphtalmus","Chuco_intermedium","Cincelichthys_pearsei","Kihnichthys_uefermanni","Theraps_irregularis", "Wajpamheros_nourisatti",  "Rheoheros_lentiginosus", "Oscura_heterospila","Maskaheros_argenteus","Maskaheros_regani","Paraneetroplus_bulleri","Paraneetroplus_nebuliferus","Vieja_bifasciata","Vieja_breidhori","Vieja_hartwegii","Vieja_fenestrata","Vieja_gutttulata","Vieja_zonata","Vieja_maculicauda","Vieja_melanurus","Thrichromis_salvini")
dimnames(Procrustes$coords)[[3]]=newnames2
dimnames(Procrustes$coords)

[[3]]
[1] "Chuco_microphtalmus"        "Chuco_intermedium"        
[3] "Cincelichthys_pearsei"      "Kihnichthys_uefermanni"    
[5] "Theraps_irregularis"        "Wajpamheros_nourisatti"    
[7] "Rheoheros_lentiginosus"     "Oscura_heterospila"        
[9] "Maskaheros_argenteus"       "Maskaheros_regani"        
[11] "Paraneetroplus_bulleri"     "Paraneetroplus_nebuliferus"
[13] "Vieja_bifasciata"           "Vieja_breidhori"          
[15] "Vieja_hartwegii"            "Vieja_fenestrata"          
[17] "Vieja_gutttulata"           "Vieja_zonata"              
[19] "Vieja_maculicauda"          "Vieja_melanurus"          
[21] "Thrichromis_salvini"      

phy$tip.label
[1] "Chuco_microphthalmus"       "Chuco_intermedium"        
[3] "Cincelichthys_pearsei"      "Kihnichthys_ufermanni"    
[5] "Theraps_irregularis"        "Wajpamheros_nourissati"    
[7] "Rheoheros_lentiginosus"     "Oscura_heterospila"        
[9] "Maskaheros_argenteus"       "Maskaheros_regani"        
[11] "Paraneetroplus_bulleri"     "Paraneetroplus_nebuliferus"
[13] "Vieja_bifasciata"           "Vieja_breidohri"          
[15] "Vieja_hartwegi"             "Vieja_fenestrata"          
[17] "Vieja_guttulata"            "Vieja_zonata"              
[19] "Vieja_maculicauda"          "Vieja_melanurus"          
[21] "Trichromis_salvini"  

##Now the names are identical and in the same position, but the trouble persists##


name.check(Procrustes,phy)
[1] "OK

match(rownames(Procrustes),phy$tip.labels)
integer(0)

obj<-name.check(phy,landmarks)
obj
$tree_not_data
 [1] "Chuco_intermedium"          "Chuco_microphthalmus"      
 [3] "Cincelichthys_pearsei"      "Kihnichthys_ufermanni"    
 [5] "Maskaheros_argenteus"       "Maskaheros_regani"        
 [7] "Oscura_heterospila"         "Paraneetroplus_bulleri"    
 [9] "Paraneetroplus_nebuliferus" "Rheoheros_lentiginosus"    
[11] "Theraps_irregularis"        "Trichromis_salvini"        
[13] "Vieja_bifasciata"           "Vieja_breidohri"          
[15] "Vieja_fenestrata"           "Vieja_guttulata"          
[17] "Vieja_hartwegi"             "Vieja_maculicauda"        
[19] "Vieja_melanurus"            "Vieja_zonata"              
[21] "Wajpamheros_nourissati"    

$data_not_tree
NULL

##### I update geomorph and RRPP directly from Github and also update Matrix library##

I am using R 4.5.1, geomorph 4.0.10, RRPP 2.1.2 and Matrix 1.7-3


Kindly appreciate any help

Best regards






--
Omar Mejía G
Laboratorio de Variación Biológica y Evolución
Departamento de Zoología
Escuela Nacional de Ciencias Biológicas-IPN

Oscar.tre
test.tps

Adams, Dean [EEOB]

unread,
Jul 1, 2025, 5:43:03 PMJul 1
to geomorph-...@googlegroups.com
Oscar,

There are two problems with your code and what you are trying to do.

First, you did not correctly point readland.tps to your species names, so the function did not find them.  For your file, you need 'specID="ID"' not 'none'.

Second, your Csize values are all exactly = 1.0.  Thus, the regression will not run (as it should not).  

Below is a fix to the code, and some 'fake' CSize data showing that data with variation will actually run.

Dean

####
library(geomorph)
library(ape)

landmarks=readland.tps("test.tps",specID="ID")
Procrustes=gpagen(landmarks)
phy=read.tree("Oscar.tre")

plot(phy)

gdf2 <- geomorph.data.frame(Procrustes,phy=phy)
attributes(gdf2)


sp.pgls <- procD.pgls(coords ~ Csize, phy = phy, data = gdf2)

gdf2$CsizeFake <- rnorm(n = length(gdf2$Csize))

sp.pgls2 <- procD.pgls(coords ~ CsizeFake, phy = phy, data = gdf2)
anova(sp.pgls2)
--
Dr. Dean C. Adams
Distinguished Professor
Department of Ecology, Evolution, and Organismal Biology
Iowa State University
Sent: Tuesday, July 1, 2025 8:46 AM
To: geomorph-...@googlegroups.com <geomorph-...@googlegroups.com>
Subject: Re: [geomorph-r-package] trouble with procD.pgls function
 

Adams, Dean [EEOB]

unread,
Jul 1, 2025, 5:43:17 PMJul 1
to geomorph-...@googlegroups.com
Sorry, Omar (not Oscar)....

Dean
--
Dr. Dean C. Adams
Distinguished Professor
Department of Ecology, Evolution, and Organismal Biology
Iowa State University

Sent: Tuesday, July 1, 2025 8:46 AM
To: geomorph-...@googlegroups.com <geomorph-...@googlegroups.com>
Subject: Re: [geomorph-r-package] trouble with procD.pgls function
 

Omar Mejía

unread,
Jul 1, 2025, 6:39:07 PMJul 1
to geomorph-...@googlegroups.com
Dear Dean,

Kindly appreciate your full explanation, at least now I can explain the editor why we prefer the E-PGLS instead  the suggested test

Best regards 

Omar Mejía G
Laboratorio de Variación Biológica y Evolución
Departamento de Zoología
Escuela Nacional de Ciencias Biológicas-IPN

Reply all
Reply to author
Forward
0 new messages