ete3 toolkit usage

65 views
Skip to first unread message

McVeigh, Richard (NIH/NLM/NCBI) [C]

unread,
Feb 23, 2021, 12:18:25 PM2/23/21
to eteto...@googlegroups.com
Hi
I am trying to use the ete3 toolkit to populate ncbi tax lineage from a pandas dataframe and ultimately add the lineage into the dataframe. I have a dataframe with thousands of taxid where I want to obtain the lineages.

I am trying

orgtable = pd.read_csv(data_table, sep='\t', index_col=None, low_memory=False, usecols=[2,3,7], header=None, skiprows=1, names=["orgname", "taxid", "accession"]) taxid = [] for index, row in orgtable.iterrows():
taxid = orgtable['taxid'].astype(int)
lineage = ncbi.get_lineage(taxid)
print(lineage)


but getting I get ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
It's clearly unhappy with lineage = ncbi.get_lineage(taxid)

Any idea what I am doing wrong?

Thank you
Rich

Alexandros Pittis

unread,
Feb 23, 2021, 12:30:07 PM2/23/21
to eteto...@googlegroups.com
Hi Rich,

Few rows of the data_table would be helpful. The "get_lineage" function takes a single taxid (integer or string) as argument, you seem to be providing a pandas Series there. That should be it.

Alexandros

--
You received this message because you are subscribed to the Google Groups "The ETE toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etetoolkit+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/etetoolkit/DM8PR09MB677510402D8F21862E335943D7809%40DM8PR09MB6775.namprd09.prod.outlook.com.

L Thiberio Rangel

unread,
Feb 23, 2021, 12:46:18 PM2/23/21
to The ETE toolkit
Hi Rich,

here is a short example of the code I use to do this kind of work: https://gist.github.com/lthiberiol/a3dae750d1b64135490097c0eb4da66f

L. Thibério Rangel, Ph.D.
Postdoctoral Associate
Department of Earth, Atmospheric & Planetary Sciences
Massachusetts Institute of Technology
77 Massachusetts Ave
Cambridge, MA 02139


Reply all
Reply to author
Forward
0 new messages