code: def df_to_tsv(df, tsvfile, suffix):
      
      tsvfile += suffix
      columns = ["SampleKey"] + sorted(x for x in df.columns
                                       if x.endswith(suffix))
      tf = df.reindex_axis(columns, axis='columns')
      tf.sort_values("SampleKey")
      tf.to_csv(tsvfile, sep='\t', index=False, float_format='%.4g', na_rep="na")
      print("TSV output written to `{}` (# samples={})"\
                  .format(tsvfile, tf.shape[0]), file=sys.stderr)
docs: Serialize the dataframe as a tsv