Skip to content

Profile

Phenotype profile reports for pre-GWAS QA.

phenotype_profile()

python
phenofhy.profile.phenotype_profile(df, phenotype, *, sex_col="derived.sex",
	age_col="derived.age_at_registration", bmi_col="derived.bmi",
	height_col="clinic_measurements.height", metadata_dir="./metadata",
	age_bin_width=2, body_bin_width=1, min_n_per_bin=30, output=None)

Generate a phenotype profile figure and summary metadata.

Parameters

  df: pandas.DataFrame
    Input dataframe.
  phenotype: str
    Phenotype column name to profile.
  sex_col: str
    Sex column for stratified plots.
  age_col: str
    Age column for age trend plot.
  bmi_col: str | None
    BMI column for body trend plot.
  height_col: str | None
    Height column for body trend plot.
  metadata_dir: str
    Directory containing metadata dictionary files.
  age_bin_width: int
    Age bin width in years.
  body_bin_width: int
    Bin width for BMI/height trends.
  min_n_per_bin: int
    Minimum count required per bin to plot.
  output: str | None
    Optional output PDF path.

Returns

  out: tuple[matplotlib.figure.Figure, dict]
    Figure and metadata summary.

Raises

  KeyError: Exception
    If the phenotype column is missing.

Example

python
from phenofhy import profile

report = profile.phenotype_profile(
    df,
    phenotype="derived.age_at_registration",
    output="outputs/reports/age_profile.pdf",
)