def combine_sample_dicts(sample_dicts):
 all_otu_ids = []
 for s in sample_dicts:
  all_otu_ids.extend(s.keys())
 all_otu_ids = list(set(all_otu_ids))
 all_otu_ids = natsort(all_otu_ids)
 indices = {}
 for i in range(len(all_otu_ids)):
  indices[all_otu_ids[i]] = i
 otu_mtx = zeros((len(all_otu_ids), len(sample_dicts)), int)
 for (i, sample_dict) in enumerate(sample_dicts):
  for (otu, abund) in sample_dict.items():
   otu_mtx[(indices[otu], i)] = abund
 return (otu_mtx, all_otu_ids)

def combine_sample_dicts ( sample_dicts ) : all_otu_ids = [ ] for s in sample_dicts : all_otu_ids . extend ( s . keys ( ) ) all_otu_ids = list ( set ( all_otu_ids ) ) all_otu_ids = natsort ( all_otu_ids ) indices = { } for i in range ( len ( all_otu_ids ) ) : indices [ all_otu_ids [ i ] ] = i otu_mtx = zeros ( ( len ( all_otu_ids ) , len ( sample_dicts ) ) , int ) for ( i , sample_dict ) in enumerate ( sample_dicts ) : for ( otu , abund ) in sample_dict . items ( ) : otu_mtx [ ( indices [ otu ] , i ) ] = abund return ( otu_mtx , all_otu_ids )
combines a list of sample_dicts into one otu table sample dicts is a list of dicts .