alifestd_from_newick
- alifestd_from_newick(newick: str, *, branch_length_dtype: type = <class 'float'>, create_ancestor_list: bool = False, dtype_id: type | None = <class 'numpy.int64'>) DataFrame
Convert a Newick format string to a phylogeny dataframe.
Parses a Newick tree string and returns a pandas DataFrame in alife standard format with columns: id, ancestor_id, taxon_label, origin_time_delta, and branch_length. Optionally includes ancestor_list.
Parameters
- newickstr
A phylogeny in Newick format.
- branch_length_dtypetype, default float
Dtype for branch length values. Use
intto get nullable integer columns (pd.Int64Dtype). Missing branch lengths will bepd.NAfor integer dtypes orNaNfor float dtypes.- create_ancestor_listbool, default False
If True, include an
ancestor_listcolumn in the result.- dtype_idtype or None, default np.int64
Numpy dtype for the
idandancestor_idcolumns. If None, the smallest signed integer dtype is chosen automatically based on the number of commas in the Newick string.
Returns
- pd.DataFrame
Phylogeny dataframe in alife standard format.
See Also
- alifestd_from_newick_polars :
Polars-based implementation.
- alifestd_as_newick_asexual :
Inverse conversion, from alife standard to Newick format.