def construct_formula(label, rel_cols, label_side='l'):
    """
    Constructs a generic formula string from column names and a label name.
    label ~ Col1+Col2+...+ColN

    :param label: Label or class which should be regressed for. (case/control, treatment/untreated etc.)
    :param rel_cols: Relevant columns for the formula
    :return: formula string
    """
    cols = rel_cols[:]
    if label in rel_cols:
        cols.remove(label)
    if label_side == 'left' or label_side == 'l':
        formula = label + ' ~ ' + '+'.join(cols)
    elif label_side == 'right' or label_side == 'r':
        formula = '+'.join(cols) + ' ~ ' + label
    return formula
