
    5i                     
    d  Z y)c                 b   i }t               }| D ]D  }|j                  |d          |d   |vrd|d   |d   |d   i||d   <   4|d   ||d      |d   <   F t        t        |            }|j	                  dd       t        |j                               }|D ]  }|D ]  }||vsd||<     ||fS )aX  
    list_of_dicts: list of dictionaries, each of the form
    {
        "feature_id":<feature_id>,
        "sample_id":<sample_id>,
        "expression":<expression>
    }
    Additional key:value pairs are possible, but are not included in the transformed output

    How it works:
    First, create a dictionary where each key is a sample id, and the values are the feature_id:expression pairs
    Then, convert it to a list of dictionaries (the format that output handling is expecting)
    Each item in the list is a dictionary containing one "sample_id":sample_id pair, and
    multiple feature_id:expression pairs

    Returns:
    A list of dictionaries, each of the form:
    {
        "sample_id":<sample_id>,
        <feature_id_1>:<expression_1>
        <feature_id_2>:<expression_2>
        ...
        <feature_id_n>:<expression_n>
    }
    
feature_id	sample_id
expression    N)setaddsortedlistinsertvalues)list_of_dictstransformed_dictcolnamesentry	dict_listdict_rowcolnames          /home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/bindings/apollo/data_transformations.pytransform_to_expression_matrixr      s    4  uH \U<()%554?k@RSXYeSfglmygz3{U;/0HMlH[U;/0|1DE\ d8n%HOOAk" %,,./I ) 	)Gh&$(!	))
 h    N)r    r   r   <module>r      s
   7 r   