def GetPermutatedMatrix(matrix,
                        map_row_new2old, map_col_new2old,
                        row_headers=None, col_headers=None):

    nrows, ncols = matrix.shape

    result = numpy.zeros((nrows, ncols), matrix.dtype)
    for r in range(0, nrows):
        for c in range(0, ncols):
            result[r, c] = matrix[map_row_new2old[r], map_col_new2old[c]]

    if not row_headers or not col_headers:
        return result

    rows = []
    for x in map_row_new2old:
        rows.append(row_headers[x])

    cols = []
    for x in map_col_new2old:
        cols.append(col_headers[x])

    return result, rows, cols

# ---------------------------------------------------------------------
return a permuted matrix. Note, that currently this is very
dataset/ETHPy150Open CGATOxford/cgat/CGAT/CorrespondenceAnalysis.py/GetPermutatedMatrix