Skip to contents

Executes a single parameter combination from the parameter grid. This function is called by PBS array job workers.

Usage

run_single_task(
  task_id,
  param_grid_file,
  output_dir,
  sweep_type = c("modelsel", "baselines"),
  methods = c("MFA", "MPCA"),
  strategies = c("grid", "twostage"),
  K_candidates = 1:5,
  r_candidates = 1:5,
  mode = c("modelsel", "oracle_r", "oracle_Kr"),
  criterion = c("ICL", "BIC"),
  icl_temperature = 2,
  max_iter = 50,
  tol = 0.001,
  n_init = 1,
  use_kmeans_init = TRUE,
  align_basis = TRUE,
  refine_assignments = TRUE,
  verbose = TRUE
)

Arguments

task_id

Integer. The task ID corresponding to run_id in the parameter grid.

param_grid_file

Character. Path to the RDS file containing the parameter grid.

output_dir

Character. Directory to save results.

sweep_type

Character. Type of sweep: "modelsel" or "baselines".

methods

Character vector. Methods to evaluate (e.g., c("MFA", "MPCA")).

strategies

Character vector. Selection strategies (e.g., c("grid", "twostage")).

K_candidates

Integer vector. Candidate K values for model selection.

r_candidates

Integer vector. Candidate r values for model selection.

mode

Character. Selection mode: "modelsel", "oracle_r", or "oracle_Kr".

criterion

Character. Model selection criterion: "ICL" or "BIC".

icl_temperature

Numeric. Temperature parameter for ICL entropy scaling.

max_iter

Integer. Maximum EM iterations.

tol

Numeric. Convergence tolerance.

n_init

Integer. Number of random initializations.

use_kmeans_init

Logical. Whether to use k-means initialization.

align_basis

Logical. For baselines sweep: whether to align basis vectors.

refine_assignments

Logical. For baselines sweep: whether to refine cluster assignments.

verbose

Logical. Whether to print progress.

Value

Invisibly returns TRUE on success.

Details

This function reads the parameter grid from a file, extracts the row corresponding to the given task_id, runs the computation, and saves the result to a separate file. This enables PBS array jobs where each task processes one parameter combination independently.

Examples

if (FALSE) { # \dontrun{
# Called from PBS script:
# Rscript -e "synergyMixR::run_single_task(
#   task_id = as.integer(Sys.getenv('PBS_ARRAY_INDEX')),
#   param_grid_file = 'results/param_grid.rds',
#   output_dir = 'results'
# )"
} # }