Loads a numpy array from a Dade matrix instance,
    e.g.: A matrix containing the following (or equivalent in numpy)

    [['RST','chr1~0','chr1~10','chr2~0','chr2~30'],
    ['chr1~0','5', '10', '11', '2'],
    ['chr1~10',   '8', '3', '5'],
    ['chr2~0',         '3', '5'],
    ['chr2~30',             '5']]

    [['5', '10', '11', '2'],
    ['10', '8', '3', '5'],
    [11', '3', '3', '5'],
    ['2', '5', '5', '5']], [chr1~0','chr1~10','chr2~0','chr2~30']

    Header data processing is delegated downstream.

    See https://github.com/scovit/DADE for more details about Dade.

def from_dade_matrix(filename, header=False):
    """ Loads a numpy array from a Dade matrix instance,
    e.g.: A matrix containing the following (or equivalent in numpy)

    [['RST','chr1~0','chr1~10','chr2~0','chr2~30'],
    ['chr1~0','5', '10', '11', '2'],
    ['chr1~10',   '8', '3', '5'],
    ['chr2~0',         '3', '5'],
    ['chr2~30',             '5']]

    [['5', '10', '11', '2'],
    ['10', '8', '3', '5'],
    [11', '3', '3', '5'],
    ['2', '5', '5', '5']], [chr1~0','chr1~10','chr2~0','chr2~30']

    Header data processing is delegated downstream.

    See https://github.com/scovit/DADE for more details about Dade.
    """

    A = np.genfromtxt(filename, delimiter="\t", dtype=None, filling_values=0)
    M, headers = np.array(A[1:, 1:], dtype=np.float64), A[0]
    matrix = M + M.T - np.diag(np.diag(M))
    parsed_header = list(
        zip(*[str(h)[:-1].strip('"').strip("'").split("~")
            for h in headers[1:]]))
    if header:
        return matrix, parsed_header
    else:
        return matrix