def write_diversity_metrics(data, sample_ids, fp=None):
if fp is None:<EOL><INDENT>fp = "<STR_LIT>"<EOL><DEDENT>with open(fp, "<STR_LIT:w>") as outf:<EOL><INDENT>out = csv.writer(outf, delimiter="<STR_LIT:\t>")<EOL>out.writerow(["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"])<EOL>for group, d in data.items():<EOL><INDENT>for sid, value in d.items():<EOL><INDENT>out.writerow([sid, group, value])<EOL><DEDENT><DEDENT><DEDENT>
Given a dictionary of diversity calculations (keyed by method)
write out the data to a file.