def remove_rare_taxa(taxdata, nkeep=(-1)):
 if ((nkeep <= 0) or (nkeep > len(taxdata['prevalence']))):
  nkeep = len(taxdata['prevalence'])
 ixs = argsort(taxdata['prevalence'])
 ixs = ixs[::(-1)][:nkeep]
 taxdata['coord'] = taxdata['coord'][ixs, :]
 taxdata['counts'] = taxdata['counts'][ixs, :]
 tmp = [taxdata['lineages'][idx] for idx in ixs]
 taxdata['lineages'] = tmp
 taxdata['prevalence'] = taxdata['prevalence'][ixs]

def remove_rare_taxa ( taxdata , nkeep = ( - 1 ) ) : if ( ( nkeep <= 0 ) or ( nkeep > len ( taxdata [ 'prevalence' ] ) ) ) : nkeep = len ( taxdata [ 'prevalence' ] ) ixs = argsort ( taxdata [ 'prevalence' ] ) ixs = ixs [ : : ( - 1 ) ] [ : nkeep ] taxdata [ 'coord' ] = taxdata [ 'coord' ] [ ixs , : ] taxdata [ 'counts' ] = taxdata [ 'counts' ] [ ixs , : ] tmp = [ taxdata [ 'lineages' ] [ idx ] for idx in ixs ] taxdata [ 'lineages' ] = tmp taxdata [ 'prevalence' ] = taxdata [ 'prevalence' ] [ ixs ]
keeps only requested number of taxa .