% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/15_auto_geo_group.R
\name{auto_geo_group}
\alias{auto_geo_group}
\title{auto_geo_group}
\usage{
auto_geo_group(
  x,
  group_col = "title",
  choice = NULL,
  min_group_size = 2L,
  max_groups = 20L,
  min_coverage = 0.8,
  search_other_cols = TRUE,
  stopwords = .tinyarray_geo_stopwords(),
  levels = NULL,
  ref = NULL,
  verbose = TRUE
)
}
\arguments{
\item{x}{A GEO result list with a `pd` data frame, or a phenotype data frame.}

\item{group_col}{Column name to try first. The default is `title`.}

\item{choice}{Candidate index to select. Use `0` to cancel. If `NULL`, the
function returns the candidate table without selecting.}

\item{min_group_size}{Minimum number of samples required for a split label.}

\item{max_groups}{Maximum number of group labels allowed in one column.}

\item{min_coverage}{Minimum fraction of samples that must be assigned a label.}

\item{search_other_cols}{Whether to search other columns when `group_col` and
`title` fail.}

\item{stopwords}{Character vector of generic words to ignore during tokenization.}

\item{levels}{Optional character vector giving the desired factor level order.}

\item{ref}{Optional reference level to place first.}

\item{verbose}{Whether to print messages and candidate tables.}
}
\value{
A list with `group_list`, `source_col`, `selected_index`,
  `candidate_table`, `candidates`, and `pdata`.
}
\description{
Infer sample groups from GEO phenotype metadata.
}
\details{
The function first tries the user-specified `group_col`, then `title`. If no
stable grouping is found, it scans the remaining columns and returns a table
of candidate groupings for manual selection. Both binary and multigroup
factors are supported. Rare groups are left as `NA` rather than being
relabeled as another group.

Labels that differ only in capitalization are merged, retaining their most
common spelling. Shared affixes and trailing sample identifiers are removed
when they can be identified consistently.
}
\examples{
pd <- data.frame(
  title = c("Control sample", "Control sample", "Treat sample", "Treat sample"),
  stringsAsFactors = FALSE
)
rownames(pd) <- paste0("s", 1:4)
res <- auto_geo_group(
  pd,
  choice = 1,
  levels = c("Control", "Treat"),
  ref = "Control",
  verbose = FALSE
)
res$source_col
levels(res$group_list)
table(res$group_list)
}
