% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/panoramic_prepare.R
\name{panoramic_prepare}
\alias{panoramic_prepare}
\title{Prepare PANORAMIC inputs from a list of SpatialExperiment objects}
\usage{
panoramic_prepare(
  spe_list,
  design,
  cell_type = "cell_type",
  min_cells = 5,
  concavity = 50,
  window = c("concave", "convex", "rect"),
  BPPARAM = BiocParallel::SerialParam()
)
}
\arguments{
\item{spe_list}{Named or unnamed list of SpatialExperiment (one per sample)}

\item{design}{data.frame with at least columns \code{sample}, \code{group} to map samples for meta-analysis. If only one group is used, give all the same group label.}

\item{cell_type}{Character; name of SpatialExperiment colData column holding cell type labels}

\item{min_cells}{Integer. Cell types with fewer than this count (per sample) are dropped.}

\item{concavity}{Numeric passed to concaveman::concaveman(). Controls level of hull detail. 1 is highly detailed, \code{Inf} is a convex hull.}

\item{window}{one of "concave","convex","rect". Typically use concave.}

\item{BPPARAM}{BiocParallel param for optional parallel processing.}
}
\value{
List of SpatialExperiment objects with metadata slot \code{panoramic} containing \code{ppp}, cell-type table, spatial window, group/sample info.
}
\description{
Creates SpatialExperiment objects ready for PANORAMIC spatial analyses.
Cell type labels are harmonized, rare cell types (fewer than \code{min_cells}) are dropped per sample,
and a spatial window is computed. Cached spatstat objects are stored within each SpatialExperiment's metadata.
}
\details{
This step computes per-sample spatial windows to exclude background, filters
rare cell types separately per sample, builds consistent cell-type factor levels,
and caches spatstat objects and type tables for PANORAMIC's spatial statistics.
}
\examples{
spe_list <- list(
  sample1 = panoramic_simulate_spe(
    n_cells = 60,
    sample_id = "sample1",
    scenario = "random",
    seed = 1
  )
)

# Design with a single group ----------------------------------------
design <- data.frame(
  sample = "sample1",
  group  = "group1",
  stringsAsFactors = FALSE
)

# Run panoramic_prepare ---------------------------------------------
prepped <- panoramic_prepare(
  spe_list,
  design      = design,
  cell_type   = "cell_type",
  min_cells   = 3,
  concavity   = 50,
  window      = "concave",
  BPPARAM     = BiocParallel::SerialParam()
)

# Inspect cached spatstat objects in metadata
names(S4Vectors::metadata(prepped[[1]])$panoramic)

}
