Question: get species names from newick phylogenetic tree file
gravatar for a.moner
9 weeks ago by
a.moner0 wrote:

Hi I have a newick phylogeny file has more than 1000 species. I want to extract just species name in different file. I appreciate your help

ADD COMMENTlink written 9 weeks ago by a.moner0
gravatar for jrj.healey
9 weeks ago by
United Kingdom
jrj.healey11k wrote:

What have you tried?

Look at the ape package for instance. It'd be as simple as:

> library(ape)
> tree <- read.tree(text = "(((A,B),(C,D)),E);")  # or read.tree(file='path/to/file.tree') if using a file
> tree$tip.label
[1] "A" "B" "C" "D" "E"

A similar approach in python:

python -c 'import sys; from ete3 import Tree; t = Tree(sys.argv[1]);print(t.get_leaf_names());' treefile.nwk
ADD COMMENTlink modified 9 weeks ago • written 9 weeks ago by jrj.healey11k

I tried ape But the problem was importing the phylogenetic file it is too big for copy and paste and made error And I couldn't use it as import data

For python I got this error ete3 command not found

ADD REPLYlink modified 9 weeks ago • written 9 weeks ago by a.moner0

Then don't import it with copy and paste, read the file in directly. What I showed above was just an example of the functionality, you need to adapt it to what you are trying to do.

As for python, yes of course, ETE3 isn't a standard module - you need to install it.

ADD REPLYlink written 9 weeks ago by jrj.healey11k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2111 users visited in the last hour