def get_rare_data(otu_table, seqs_per_sample, include_small_samples=False, subsample_f=subsample):
 with errstate(empty='raise'):
  if (not include_small_samples):
   otu_table = filter_samples_from_otu_table(otu_table, otu_table.ids(), seqs_per_sample, inf)
  def func(x, s_id, s_md):
   if (x.sum() < seqs_per_sample):
    return x
   else:
    return subsample_f(x.astype(int), seqs_per_sample)
  subsampled_otu_table = otu_table.transform(func, axis='sample')
  return subsampled_otu_table

def get_rare_data ( otu_table , seqs_per_sample , include_small_samples = False , subsample_f = subsample ) : with errstate ( empty = 'raise' ) : if ( not include_small_samples ) : otu_table = filter_samples_from_otu_table ( otu_table , otu_table . ids ( ) , seqs_per_sample , inf ) def func ( x , s_id , s_md ) : if ( x . sum ( ) < seqs_per_sample ) : return x else : return subsample_f ( x . astype ( int ) , seqs_per_sample ) subsampled_otu_table = otu_table . transform ( func , axis = 'sample' ) return subsampled_otu_table
filter otu table to keep only desired sample sizes .