spac.phenotyping.generate_phenotypes_dict(data_df, phenotypes_df, prefix='', suffix='')[source]

Generate a dictionary of phenotype names to their corresponding decoding rules.

Parameters:
  • data_df (pandas.DataFrame) – The DataFrame containing the columns that will be used to decode the phenotypes.

  • phenotypes_df (pandas.DataFrame) –

    A DataFrame containing phenotype definitions with columns: - “phenotype_name” : str

    The name of the phenotype.

    • ”phenotype_code”str

      The code used to decode the phenotype.

  • prefix (str, optional) – Prefix to be added to the column names. Default is ‘’.

  • suffix (str, optional) – Suffix to be added to the column names. Default is ‘’.

Returns:

A dictionary where the keys are phenotype names and the values are dictionaries mapping column names to values.

Return type:

dict

Notes

The function iterates over each row in the phenotypes_df DataFrame and decodes the phenotype using the decode_phenotype function.