def run_grouped_correlation(md_vals, otu_arrays, test, test_choices, pval_assignment_method, permutations=None):
 test_fn = test_choices[test]
 sample_sizes = map(len, md_vals)
 def _rho(otu_vals, md_vals):
  return test_fn(otu_vals, md_vals)
 rhos = []
 for i in range(len(md_vals)):
  rhos.append(apply_along_axis(_rho, 1, otu_arrays[i], md_vals[i]))
 pvals = []
 for (i, group_rhos) in enumerate(rhos):
  pvals_i = zeros(len(group_rhos))
  for (j, rho) in enumerate(group_rhos):
   pvals_i[j] = assign_correlation_pval(rho, sample_sizes[i], pval_assignment_method, permutations, test_fn, otu_arrays[i][j], md_vals[i])
  pvals.append(array(pvals_i))
 fisher_pvals = apply_along_axis(fisher, 0, array(pvals))
 fisher_rho_and_h = apply_along_axis(fisher_population_correlation, 0, array(rhos), sample_sizes)
 return (rhos, pvals, fisher_pvals, fisher_rho_and_h[0], fisher_rho_and_h[1])

def run_grouped_correlation ( md_vals , otu_arrays , test , test_choices , pval_assignment_method , permutations = None ) : test_fn = test_choices [ test ] sample_sizes = map ( len , md_vals ) def _rho ( otu_vals , md_vals ) : return test_fn ( otu_vals , md_vals ) rhos = [ ] for i in range ( len ( md_vals ) ) : rhos . append ( apply_along_axis ( _rho , 1 , otu_arrays [ i ] , md_vals [ i ] ) ) pvals = [ ] for ( i , group_rhos ) in enumerate ( rhos ) : pvals_i = zeros ( len ( group_rhos ) ) for ( j , rho ) in enumerate ( group_rhos ) : pvals_i [ j ] = assign_correlation_pval ( rho , sample_sizes [ i ] , pval_assignment_method , permutations , test_fn , otu_arrays [ i ] [ j ] , md_vals [ i ] ) pvals . append ( array ( pvals_i ) ) fisher_pvals = apply_along_axis ( fisher , 0 , array ( pvals ) ) fisher_rho_and_h = apply_along_axis ( fisher_population_correlation , 0 , array ( rhos ) , sample_sizes ) return ( rhos , pvals , fisher_pvals , fisher_rho_and_h [ 0 ] , fisher_rho_and_h [ 1 ] )
run grouped correlation test this function runs the grouped correlation test .