def define_outfile_cols_expand(samp_grps, ontology, mode):
    """
    define columns for writing the expand output file

    :param samp_grps: SampleGroups object
    :param ontology: functional ontology. only required for 'f' or 'ft' modes
    :param mode: f, t, or ft
    :return: a list of relevant columns in the correct order
    """
    int_cols = []
    int_cols += samp_grps.mean_names + samp_grps.all_intcols
    node_cols = []
    if ontology != "cog":
        node_cols += samp_grps.n_peptide_names_flat
        # ft doesn't have samp_children
        if mode != 'ft':
            node_cols += samp_grps.samp_children_names_flat
    quant_cols = int_cols + node_cols
    if mode == 'f':
        if ontology == 'go':
            cols = ['id', 'name', 'namespace'] + quant_cols
        elif ontology == 'cog':
            cols = ['id', 'description'] + quant_cols
        elif ontology == 'ec':
            cols = ['id', 'description'] + quant_cols
        else:
            raise ValueError("Invalid ontology. Expected one of: %s" % ['go', 'cog', 'ec'])
    elif mode == 't':
        cols = ['id', 'taxon_name', 'rank'] + quant_cols
    elif mode == 'ft':
        cols = ['go_id', 'name', 'namespace', 'tax_id', 'taxon_name', 'rank'] + quant_cols
    else:
        raise ValueError("Invalid mode. Expected one of: %s" % ['f', 't', 'ft'])
    return cols