def writeMatrix(file,
                matrix,
                separator="\t",
                headers=[],
                format="%f"):
    """write a matrix to file.

    if headers are given, add them to columns and rows.
    """

    if headers:
        file.write("\t" + string.join(headers, "\t") + "\n")

    nrows, ncols = matrix.shape

    for x in range(nrows):
        if headers:
            file.write(headers[x] + "\t")
        file.write(
            string.join(map(lambda x: x % format, matrix[x]), "\t") + "\n")
dataset/ETHPy150Open CGATOxford/cgat/scripts/r_table2scatter.py/writeMatrix/swapped operands of `%`