% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/NormalizeData.R
\name{NormalizeData}
\alias{NormalizeData}
\title{Normalise the absolute data to relative data by using Total Sum Scaling
and Geometric Mean of Pairwise Ratios (GMPR)}
\usage{
NormalizeData(CrcBiomeScreenObject = NULL, method = NULL, level = NULL)
}
\arguments{
\item{CrcBiomeScreenObject}{From the CreateCrcBiomeScreenObject()}

\item{method}{"TSS" or "GMPR"}

\item{level}{Taxonomic level for normalization, e.g., "Genus"}
}
\value{
A A \code{CrcBiomeScreen} object. with the updated NormalizedData.
}
\description{
Normalise the absolute data to relative data by using Total Sum Scaling
and Geometric Mean of Pairwise Ratios (GMPR)
}
\examples{
# Minimal runnable example for NormalizeData

# Toy taxa in a simplified MetaPhlAn-like hierarchical format
toy_taxa <- data.frame(
  Taxa = c(
    "D_0__Bacteria|D_1__Firmicutes|D_2__Clostridia|D_3__OrderX|D_4__FamilyX|D_5__GenusA",
    "D_0__Bacteria|D_1__Firmicutes|D_2__Clostridia|D_3__OrderY|D_4__FamilyY|D_5__GenusB"
  ),
  stringsAsFactors = FALSE
)

# Toy abundance matrix (2 taxa, 2 samples)
toy_abs <- data.frame(
  S1 = c(10, 5),
  S2 = c(20, 15)
)
rownames(toy_abs) <- toy_taxa$Taxa

# Dummy sample metadata
toy_sample <- data.frame(
  sample_id = c("S1", "S2")
)

# Construct minimal CrcBiomeScreen object
toy_obj <- new(
  "CrcBiomeScreen",
  AbsoluteAbundance   = toy_abs,
  RelativeAbundance   = data.frame(),
  TaxaData            = toy_taxa,
  SampleData          = toy_sample,
  TaxaLevelData       = NULL,
  NormalizedData      = NULL,
  OriginalNormalizedData = NULL,
  ValidationData      = NULL,
  ModelData           = NULL,
  ModelResult         = NULL,
  EvaluateResult      = list(),
  PredictResult       = NULL
)

# Apply taxonomy splitting + keep genus level
toy_obj <- SplitTaxas(toy_obj)
toy_obj <- KeepTaxonomicLevel(toy_obj, level = "Genus")
toy_obj <- NormalizeData(toy_obj, method = "TSS", level = "Genus")
# Inspect normalized results
head(getNormalizedData(toy_obj))

}
