def grouped_correlation_row_generator(bt, pmf, category, gc_to_samples):
 data = array([i for i in bt.iter_data(axis='observation')])
 category_values = gc_to_samples.keys()
 samples = gc_to_samples.values()
 sample_inds = [[bt.index(i, axis='sample') for i in group] for group in samples]
 try:
  md_vals = []
  for grp in samples:
   md_vals.append(array([pmf[s][category] for s in grp], dtype=float))
 except ValueError:
  raise ValueError("Couldn't convert sample metadata to float.")
 otu_vals = [data.take(inds, 1) for inds in sample_inds]
 return (category_values, md_vals, otu_vals)

def grouped_correlation_row_generator ( bt , pmf , category , gc_to_samples ) : data = array ( [ i for i in bt . iter_data ( axis = 'observation' ) ] ) category_values = gc_to_samples . keys ( ) samples = gc_to_samples . values ( ) sample_inds = [ [ bt . index ( i , axis = 'sample' ) for i in group ] for group in samples ] try : md_vals = [ ] for grp in samples : md_vals . append ( array ( [ pmf [ s ] [ category ] for s in grp ] , dtype = float ) ) except ValueError : raise ValueError ( "Couldn't convert sample metadata to float." ) otu_vals = [ data . take ( inds , 1 ) for inds in sample_inds ] return ( category_values , md_vals , otu_vals )
create generator for grouped correlation tests .