% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/joint_map.R
\name{joint_map}
\alias{joint_map}
\title{Joint Mapping Analysis for Multiple Traits}
\usage{
joint_map(formula, data, skeleton, include, cut_off_list)
}
\arguments{
\item{formula}{A model formula defining the full set of candidate linear-model terms
(for example, factor population effects and marker-by-population interactions).
Term labels from this formula are compared to the selected model in \code{skeleton}.}

\item{data}{A data frame containing all variables used in \code{formula} and in
\code{skeleton$call$formula}.}

\item{skeleton}{A fitted model object (typically the final model from stepwise
selection) that contains \code{skeleton$call$formula}. Commonly produced by
\code{skeletion_build()} using the same \code{formula}, \code{data},
\code{include}, and \code{cut_off_list}.}

\item{include}{Optional character vector of predictor names that should be treated
as grouping variables (coerced to factor when \code{formula} contains \code{:}
interactions). If \code{NULL}, interaction-based inclusion may be inferred from
term labels. Matches the \code{include} argument used when fitting \code{skeleton}.}

\item{cut_off_list}{A list whose component \code{cut_off} includes a named element
\code{"pvalue"} (for example, output from \code{\link{permutation_test}}).
Used upstream with \code{skeletion_build()} to obtain \code{skeleton}; it is
part of the API for a consistent joint-mapping workflow but is not read inside
\code{joint_map()}.}
}
\value{
A list containing pvalue and LOD for each term in the formula:
  \itemize{
    \item \code{pvalue}: P-value for each term
    \item \code{lod}: LOD score for each term
  }
}
\description{
Performs comprehensive joint mapping analysis for multiple traits using either Association Mapping (AM) 
or Linkage Mapping (LM) methods to identify QTL affecting multiple traits simultaneously. This function
implements sophisticated statistical methods for multivariate QTL analysis with comprehensive
cofactor selection and significance testing.
}
\examples{
\donttest{
# Example phenotype data
set.seed(1)
pheno_data <- data.frame(
  Trait1 = rnorm(100, mean = 100, sd = 15),
  Trait2 = rnorm(100, mean = 50, sd = 8),
  Popu = rep(c("Pop1", "Pop2"), each = 50)
)

# Example genotype data
geno_data <- matrix(sample(c(0,1,2), 100*50, replace = TRUE),
                    nrow = 100, ncol = 50)
colnames(geno_data) <- paste0("M", 1:50)

data1 <- cbind(pheno_data,geno_data) 

data1$Popu <- as.factor(data1$Popu)

terms <- c("Popu", paste0(colnames(geno_data),":Popu"))
formula1 <- reformulate(terms, response = "Trait1")

cut_off_list <- permutation_test(formula1, data1, n=10, alpha = 0.1, include="Popu")

skeleton <- skeletion_build(
  formula1, data1, strategy = "bidirection", metric = "SBC",
  cut_off_list = cut_off_list, include="Popu"
)

results <- joint_map(formula1, data1, skeleton, include = "Popu", cut_off_list = cut_off_list)

print(results)


}
}
\references{
Jiang, C. and Zeng, Z.B. (1995). Multiple trait analysis of genetic mapping for 
quantitative trait loci. Genetics, 140(3), 1111-1127.
}
\seealso{
\code{\link{permutation_test}} for permutation thresholds,
  \code{\link{genotype_prob}} for genotype probability calculations
}
