def filter_table(table, otu_subset=None, sample_subset=None):
    """Filters a table given otu and sample ids

    Parameters
    ----------

    table : biom.Table
        Table to be filtered

    otu_subset : Optional[list[str]]
        List of otu's to keep in table. If None, keep all otu's.

    sample_subset : Optional[list[str]]
        List of samples to keep in table. If None keep all samples.

    Returns
    -------

    biom.Table
        A filtered version of the original table, based on otu and
         sample subsets


    """
    # create a new table then filter this table in place
    new_table = table.copy()
    if otu_subset is not None:
        new_table.filter(ids_to_keep=otu_subset, axis='observation',
                         inplace=True)
    if sample_subset is not None:
        new_table.filter(ids_to_keep=sample_subset, axis='sample',
                         inplace=True)
    return new_table