Skip to contents

Usage

ihcheterogeneity(
  data,
  wholesection = NULL,
  biopsy1,
  biopsy2 = NULL,
  biopsy3 = NULL,
  biopsy4 = NULL,
  biopsies = NULL,
  spatial_id = NULL,
  compareCompartments = FALSE,
  compartmentTests = FALSE,
  analysis_type = "comprehensive",
  sampling_strategy = "unknown",
  cv_threshold = 20,
  correlation_threshold = 0.8,
  show_variability_plots = FALSE,
  variance_components = FALSE,
  power_analysis = FALSE,
  generate_recommendations = FALSE,
  showSummary = FALSE,
  showGlossary = FALSE
)

Arguments

data

the data as a data frame

wholesection

Optional reference measurement for comparison with regional measurements. Can be whole section average, hotspot area, or overall tumor measurement. Leave empty for inter-regional comparison studies. Example: Ki67 proliferation index (0-100\ PR percentage (0-100\

biopsy1Continuous biomarker measurement from first tissue region or area. Should represent same biomarker as reference measurement for heterogeneity comparison. Example: Ki67 \ from invasive front.

biopsy2Second tissue region biomarker measurement for heterogeneity analysis

biopsy3Third tissue region biomarker measurement

biopsy4Fourth tissue region biomarker measurement

biopsiesadditional simulated biopsy measurements

spatial_ididentifier for spatial regions or tissue areas (e.g., Central/Invasive, Preinvasive/Invasive)

compareCompartmentsPerform statistical comparison of heterogeneity patterns between spatial compartments. Requires spatial_id variable. Compares ICC, CV, and bias across compartments.

compartmentTestsPerform statistical tests to determine if heterogeneity differs significantly between compartments. Uses Levene's test for variance equality and Kruskal-Wallis for distributional differences.

analysis_typeprimary focus of biopsy simulation analysis

sampling_strategybiopsy sampling strategy used

cv_thresholdCoefficient of variation threshold for acceptable sampling variability. Typical clinical values: 15-25\ immunohistochemistry (Ki67, ER, PR), 10-20\ for heterogeneous markers (HER2, PD-L1). Lower values indicate more stringent quality requirements.

correlation_thresholdMinimum Spearman correlation between biopsy and whole section measurements. Clinical guidelines: ≥0.80 excellent agreement, ≥0.70 good agreement, ≥0.60 moderate agreement, <0.60 poor agreement. Higher values indicate better representativeness of biopsy samples.

show_variability_plotsdisplay plots showing sampling variability

variance_componentsperform variance component decomposition

power_analysisperform power analysis for sample size recommendations

generate_recommendationsprovide recommendations for optimal heterogeneity assessment strategy

showSummaryDisplay natural-language summary of heterogeneity analysis results

showGlossaryDisplay definitions of statistical terms (ICC, CV, correlation)

A results object containing:

results$interpretationa html
results$report_sentencesPre-formatted sentences ready for clinical reports and publications
results$assumptionsAnalysis assumptions, data requirements, and methodological considerations
results$summaryNatural-language summary of heterogeneity analysis results
results$glossaryDefinitions of key statistical terms used in the analysis
results$reproducibilitytableCorrelation and reliability metrics
results$samplingbiastableSystematic bias assessment between methods
results$variancetableSources of measurement variability
results$poweranalysistableSample size recommendations and power calculations
results$spatialanalysistableVariability across spatial regions
results$compartmentComparisonStatistical comparison of heterogeneity metrics between compartments
results$compartmentTestsFormal statistical tests comparing heterogeneity across compartments
results$biopsyplotDistribution comparison across regional measurements and reference (if provided)
results$variabilityplotCoefficient of variation by case
results$spatialplotSpatial distribution of biomarker values
Tables can be converted to data frames with asDF or as.data.frame. For example:results$reproducibilitytable$asDFas.data.frame(results$reproducibilitytable) IHC Heterogeneity Analysis