% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CIBERSORT.R
\name{parallel_doperm}
\alias{parallel_doperm}
\title{Parallel Permutation Test for CIBERSORT}
\usage{
parallel_doperm(
  perm1,
  X1,
  Y1,
  absolute1,
  abs_method1,
  num_cores1 = 2,
  seed = NULL
)
}
\arguments{
\item{perm1}{Integer. Number of permutations to perform (\eqn{\ge}100 recommended).}

\item{X1}{Matrix or data frame. Signature matrix (cell type GEP barcode).}

\item{Y1}{Matrix. Mixture file containing gene expression profiles.}

\item{absolute1}{Logical. Whether to run in absolute mode (default: FALSE).}

\item{abs_method1}{String. Method for absolute mode: 'sig.score' or 'no.sumto1'.}

\item{num_cores1}{Integer. Number of CPU cores for parallel computation (default: 2).}

\item{seed}{Integer. Random seed for reproducibility. If NULL (default),
uses current random state. Set to a specific value (e.g., 123) for
reproducible results across runs.}
}
\value{
List containing:
\describe{
  \item{dist}{Numeric vector of correlation coefficients from permutations,
    representing the empirical null distribution.}
}
}
\description{
Parallel version of doPerm. Performs permutation-based sampling and runs
the CoreAlg function iteratively using multiple CPU cores to accelerate
computation. This function generates an empirical null distribution of
correlation coefficients for p-value calculation in CIBERSORT analysis.
}
\details{
This function utilizes the \code{foreach} and \code{doParallel} packages
to distribute permutation iterations across multiple cores. It automatically
handles cluster setup/teardown via \code{on.exit()} to prevent resource leaks.

Note: Windows users may experience slower performance due to socket-based
parallelization (PSOCK) versus forking on Unix systems.
}
\examples{
# Simulate data
set.seed(123)
X <- matrix(rnorm(1000), nrow = 100)
Y <- matrix(rnorm(500), nrow = 100)
rownames(X) <- rownames(Y) <- paste0("Gene", 1:100)
colnames(X) <- paste0("Cell", 1:10)
colnames(Y) <- paste0("Sample", 1:5)

# Run parallel permutation test
result <- parallel_doperm(
  perm1 = 10, X1 = X, Y1 = Y,
  absolute1 = FALSE, abs_method1 = "sig.score", num_cores1 = 1
)
if (!is.null(result)) str(result$dist)
}
\seealso{
\code{\link{doPerm}} for the sequential version, \code{\link{CoreAlg}}, \code{\link{CIBERSORT}}
}
