:py:mod:`biotaphy.analyses.anc_dp` ================================== .. py:module:: biotaphy.analyses.anc_dp .. autoapi-nested-parse:: Module containing code for calculating ancestral states. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: biotaphy.analyses.anc_dp._get_node_label biotaphy.analyses.anc_dp.calculate_ancestral_distributions biotaphy.analyses.anc_dp.calculate_continuous_ancestral_states .. py:function:: _get_node_label(node) Returns the node label or taxon label if node is a tip. :param node: A tree node to get the label for. :type node: Node :returns: The node label or taxon label. :rtype: str .. py:function:: calculate_ancestral_distributions(tree, char_mtx) Calculates ancestral distributions. :param tree: A dendropy tree or TreeWrapper object. :type tree: Tree :param char_mtx: A Matrix object with character information. Each row should represent a tip in the tree and each column should be a bin to calculate ancestral distribution. :type char_mtx: Matrix :returns: * rows: nodes / tips in the tree * columns: character variables * depth: first is the calculated value, second layer is standard error if desired :rtype: A matrix of character data with the following dimensions .. py:function:: calculate_continuous_ancestral_states(tree, char_mtx, sum_to_one=False, calc_std_err=False) Calculates the continuous ancestral states for the nodes in a tree. :param tree: A dendropy tree or TreeWrapper object. :type tree: Tree :param char_mtx: A Matrix object with character information. Each row should represent a tip in the tree and each column should be a variable to calculate ancestral state for. :type char_mtx: Matrix :param calc_std_err: If True, calculate standard error for each variable. Defaults to False. :type calc_std_err: :obj:`bool`, optional :param sum_to_one: If True, standardize the character matrix so that the values in a row sum to one. Defaults to False. :type sum_to_one: :obj:`bool`, optional :raises ValueError: Raised if none of the tree tips were found in the character data. :returns: * rows: nodes / tips in the tree * columns: character variables * depth: first is the calculated value, second layer is standard error if desired :rtype: A matrix of character data with the following dimensions .. todo:: * Add function for consistent label handling.