def writeMatrix(outfile, matrix, row_headers, col_headers, row_header=""):

    outfile.write("%s\t%s\n" % (row_header, "\t".join(col_headers)))
    for x, row in enumerate(matrix):
        assert len(row) == len(col_headers)
        outfile.write("%s\t%s\n" % (row_headers[x], "\t".join(map(str, row))))
write a numpy matrix to outfile.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/IOTools.py/writeMatrix