def average_node_annotation(graph: BELGraph,<EOL>key: str,<EOL>annotation: str = '<STR_LIT>',<EOL>aggregator: Optional[Callable[[Iterable[X]], X]] = None,<EOL>) -> Mapping[str, X]:
if aggregator is None:<EOL><INDENT>def aggregator(x):<EOL><INDENT>"""<STR_LIT>"""<EOL>return sum(x) / len(x)<EOL><DEDENT><DEDENT>result = {}<EOL>for subgraph, nodes in group_nodes_by_annotation(graph, annotation).items():<EOL><INDENT>values = [graph.nodes[node][key] for node in nodes if key in graph.nodes[node]]<EOL>result[subgraph] = aggregator(values)<EOL><DEDENT>return result<EOL>
Groups graph into subgraphs and assigns each subgraph a score based on the average of all nodes values
    for the given node key

    :param pybel.BELGraph graph: A BEL graph
    :param key: The key in the node data dictionary representing the experimental data
    :param annotation: A BEL annotation to use to group nodes
    :param aggregator: A function from list of values -> aggregate value. Defaults to taking the average of a list of
                       floats.
    :type aggregator: lambda