///|
fn main {
  println("=== BEclear Demo ===")

  let m = @src.beclear_sample_matrix()
  println(
    "\n1. Input matrix: " +
    m.n_rows().to_string() +
    " genes x " +
    m.n_cols().to_string() +
    " samples",
  )
  for i in 0..
        println("   " + m.col_names[j] + " -> batch " + batch_id.to_string())
      None => println("   " + m.col_names[j] + " -> unassigned")
    }
  }

  println("\n3. Batch effect detection (threshold=0.05)")
  let summaries = @src.detect_batch_effect(m, threshold=0.05)
  for s in summaries {
    println(
      "   " +
      s.row_name +
      ": max_dev=" +
      s.max_deviation.to_string() +
      ", affected=" +
      s.affected.to_string(),
    )
  }

  println("\n4. Affected blocks")
  let blocks = @src.beclear_affected_blocks(m, threshold=0.05)
  for b in blocks {
    println("   row " + b.0.to_string() + ", batch " + b.1.to_string())
  }

  println("\n5. Corrected matrix")
  let corrected = @src.beclear(m, threshold=0.05)
  for i in 0..