This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Error reading nexus(.nex) file in R

Hi, I am looking to import .nexus file in R to analyze it but am facing errors in the import step itself. I tried the following commands and obtained the following error messages.

> file<-read.nexus("hominoid.nex")
Error in start:end : NA/NaN argument
>tree<-read.tree("hominoid_apriori.tre")
Error in if (tp[3] != "") obj$node.label <- tp[3] : 
  missing value where TRUE/FALSE needed
> file2<-read.nexus("testmodel.nex")
Error in X[sb] <- gsub(".*\\]", "", X[sb]) : 
  NAs are not allowed in subscripted assignments
In addition: Warning messages:
1: In grep("\\[", X) : input string 26 is invalid in this locale
2: In grep("\\[", X) : input string 231 is invalid in this locale
3: In grep("\\]", X) : input string 26 is invalid in this locale
4: In grep("\\]", X) : input string 231 is invalid in this locale
5: In LEFT == RIGHT :
  longer object length is not a multiple of shorter object length

The file link,

https://www.dropbox.com/sh/kqo8bwi9s7ispcx/AADDEsRuDfLCpKbZeGgU81nha?dl=0

I will be glad to provide necessary details, kindly advice.

PS: I am able to read the file using read.csv command but not able to perform any operations with it.

BR, M

phylogenetics ape r nexus

Thank you for your clarification and suggestion. I understand the files are PAUP files, but my orders are specific to analyze them using R and PhyML.

I am able to import to the file into R-studio but can you help me understand what it means and how I should proceed. I tried to outgroup "Lemur_catta" but I get the message stating

object "phy" is not of class "phylo".

I had used the root command from http://svitsrv25.epfl.ch/R-doc/library/ape/html/root.html

Can you guide me on this, I appreciate any help you could provide me with.

BR, M

I want to make sure that different questions made up as new posts so other people who need help don't have to dig through things. Could you submit this as a new question and provide a bit more detail (i.e., which file you are trying to load, what exactly you want to do, etc.)? I'm guessing you want to get a ML tree and analyze it in some fashion.

Edit: you could provide a link to the question as a comment or tag it with 'Phylogenetics' - either way I'll be able to find it.

1 answer

In ape, read.nexus() reads in a treefile formatted in NEXUS format. read.tree() reads a treefile formatted in Newick (or parenthetical) format.

You want read.nexus.data(file=hominoid.nex) for the data and read.nexus("hominoid_apriori.tre").

testmodel.nex is just a PAUP* block and not a properly formatted NEXUS data file. This is appended to a NEXUS data file and then executed. If you want to do model selection, may I suggest Minin et al.'s decision-theroetic approach, DT-ModSel? Append the block, execute the NEXUS file, then run the perl script.

Please respond if things aren't working.

Log in to answer this question.