geomorphR/geomorph

Phylomorphospace troubles

StanleeKol opened this issue · 15 comments

Hi, while in old version 3.xx it works without issues, in 4.xx I am getting errors:
"Error in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'as.matrix': subscript out of bounds"

The trouble is my tree data. Please, I was wondering how the "plethspecies" was generated as it includes both landmarks and tree data but still work "data(plethspecies)" function. I understand that it is not geomorph data frame. Then what is it? I wanted to create something similar with my Y.gpa$coords and mytree.nex (tree data). Or any other suggestions what could help to resolve this issue?
Thank you.

Stan

Thank you Dean.

And please, should I use these commands?

install.packages("devtools")
devtools::install_github("geomorphR/geomorph", ref = "Stable", build_vignettes = TRUE)

AND

devtools::install_github("FinYang/RRRR")

My apologies, second was:
devtools::install_github("mlcollyer/RRPP")

I did that and it still has the same results.
Pipeline is:
classifier <- read.csv("ClassifierAll.csv", header=T, row.names=1)
filelist <- list.files(pattern = ".nts")
mydata <- readmulti.nts(filelist)
readmulti.nts(filelist)
dim(mydata)
data(mydata)

Y.gpa<-gpagen(mydata)

plot(gm.prcomp(Y.gpa$coords))
PCA <- gm.prcomp(Y.gpa$coords)
tree <- read.tree("Tree_Ischnocera.nex")

#prune tips
species.to.keep <-read.csv("ClassifierAll.csv", header = TRUE)
pruned.tree<-drop.tip(tree,tree$tip.label[-na.omit(match(species.to.keep[,1],tree$tip.label))])
write.tree(pruned.tree, file = "pruned_tree.phy")
mytree <- read.tree("pruned_tree.phy")
name.check(mytree, classifier)

PCA.w.phylo <- gm.prcomp(Y.gpa$coords, phy = mytree). ---->>this part doesn't work
summary(PCA.w.phylo)
summary(PCA.w.phylo)

Stan,

Do the names in Y.gpa$coords match those in mytree?

Dean

name.check(mytree, classifier)
[1] "OK"

name.check(mytree, Y.gpa$coords)
$tree_not_data
[1] "Alcedoecus" "Alcedoffula" "Anaticola" "Anatoecus"
[5] "Aquanirmus" "Ardeicola" "Austrogoniodes" "Austrophilopterus"
[9] "Brueelia" "Campanulotes" "Chelopistes" "Colilipeurus"
[13] "Columbicola" "Craspedonirmus" "Craspedorrhynchus" "Cuculoecus"
[17] "Degeeriella" "Docophoroides" "Epicolinus" "Esthiopterum"
[21] "Fulicoffula" "Goniodes" "Halipeurus" "Ibidoecus"
[25] "Lipeurus" "Megaginus" "Meropoecus" "Meropsiella"
[29] "Neopsittaconirmus" "Osculotes" "Oxylipeurus" "Pectinopygus"
[33] "Penenirmus" "Pessoaiella" "Philopterus" "Pseudolipeurus"
[37] "Psittoecus" "Quadraceps" "Rallicola" "Saemundssonia"
[41] "Splendoroffula" "Strongylocotes" "Sturnidoecus" "Tinamotaecola"
[45] "Vernoniella"

$data_not_tree
[1] "1" "10" "11" "12" "13" "14" "2" "3" "4" "5" "6" "7" "8" "9"

I checked it manually and it is the same. Only difference is that all Y.gpa$coords names have extension like "Alcedoecus.nts_1"
But the same data worked well in 3.xx R version with function "plotGMPhyloMorphoSpace"

match(mytree$tip.labels, dimnames(Y.gpa$coords)[3])
integer(0)
match(mytree$tip.labels, dimnames(Y.gpa$coords))
integer(0)

match(mytree$tip.label, dimnames(Y.gpa$coords)[3])
[1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[33] NA NA NA NA NA NA NA NA NA NA NA NA NA

Yes, the same results. Please, what do you suggest me to do? How to remove in Y.gpa$coords that ".nts_1"?
Thank you very much.

Stan

I tried this:

dimnames(Y.gpa$coords)[[3]] = gsub(pattern = ".nts_1", replacement = "", x = dimnames(Y.gpa$coords)[[3]])
match(mytree$tip.label,dimnames(Y.gpa$coords)[[3]])
[1] 34 30 39 36 44 26 42 10 22 15 16 35 1 33 40 38 2 45 12 27 28 43 9 37 29 8 17 25 31 11 41 19 3 20 5 4
[37] 21 24 32 23 18 6 7 14 13

It worked, thanks! Also one name was misspelled.