compare_habitat_features

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

compare_habitat_features(data: HabitatFeaturePanel | FeatureTable | DataFrame, *, habitats: Sequence[int] | None = None, features: Sequence[str] | None = None, paired: bool = True, effect: str = 'cliffs_delta', subject_id: str | None = None) → HabitatFeatureComparison[source]

Contrast features across habitats for one subject or a cohort.

Cohort (the intended reviewer figure): each subject contributes a paired observation per habitat pair. Default test is Wilcoxon signed-rank; default effect is paired Cliff’s delta (dominance of habitat A over B). p-values are Benjamini-Hochberg adjusted across all feature x pair tests. A missing habitat in a subject drops that pair for that subject – it is not imputed.

Single subject: the same summary and pairwise mean differences are returned; p / q / effect-size columns that need a sample are NaN.

Parameters:
  • data – Panel, wide each_habitat FeatureTable, or long/wide DataFrame.

  • habitats – Habitat ids to include. Default: all present.

  • features – Feature names to include. Default: all present.

  • paired – If True (default), pair on subject. If False, treat habitat groups as independent (unpaired Cliff’s delta / Mann-Whitney).

  • effect – cliffs_delta (default) or cohens_d.

  • subject_id – If set, restrict the panel to that subject first.

Returns:

HabitatFeatureComparison with summary and pairwise frames.

Raises:

HABITAPIError – If effect is unknown or fewer than two habitats remain.