Skip to contents

Concatenate Cluster Summary Matrices Across Runs (Generic)

Usage

matrix_concat(experiment, run_indices = NULL, ...)

# S4 method for class 'H5ClusterExperiment'
matrix_concat(experiment, run_indices = NULL)

Arguments

experiment

The experiment object (typically H5ClusterExperiment-class).

run_indices

Optional: A numeric or character vector specifying which runs to include. If NULL, uses all runs that are of summary type or can produce a summary matrix.

...

Additional arguments for methods.

Value

A concatenated matrix (typically time x clusters).

Methods (by class)

  • matrix_concat(H5ClusterExperiment): Concatenate summary matrices for H5ClusterExperiment

Examples

if (FALSE) { # \dontrun{
if (!is.null(fmristore:::create_minimal_h5_for_H5ClusterExperiment)) {
  temp_exp_file <- NULL
  exp_obj <- NULL
  tryCatch({
    temp_exp_file <- fmristore:::create_minimal_h5_for_H5ClusterExperiment(
      n_time_run2 = 6L # Shorter time series for Run2_Summary
    )
    exp_obj <- fmristore::H5ClusterExperiment(file_path = temp_exp_file)

    # Note: matrix_concat typically works on runs with summary data (H5ClusterRunSummary)
    # The helper creates "Run2_Summary".
    # concatenated_matrix <- matrix_concat(exp_obj, run_indices = "Run2_Summary")
    # print(dim(concatenated_matrix))
    # Should be n_time_run2 x n_master_clusters (e.g., 6x3 if num_master_clusters is 3)
    # print(head(concatenated_matrix))

    # The method should correctly identify and use the summary run.
    # If only one summary run is present, run_indices can often be omitted.
    conc_matrix <- matrix_concat(exp_obj, run_indices = "Run2_Summary")
    print(paste("Dimensions of concatenated matrix from Run2_Summary:",
                paste(dim(conc_matrix), collapse="x")))

    # Example with all compatible runs (should pick up Run2_Summary)
    # conc_matrix_all <- matrix_concat(exp_obj)
    # print(paste("Dimensions of concatenated matrix from all compatible runs:",
    #             paste(dim(conc_matrix_all), collapse="x")))

  }, error = function(e) {
    message("matrix_concat example failed: ", e$message)
  }, finally = {
    if (!is.null(exp_obj)) try(close(exp_obj), silent = TRUE)
    if (!is.null(temp_exp_file) && file.exists(temp_exp_file)) {
      unlink(temp_exp_file)
    }
  })
} else {
  message("Skipping matrix_concat example: helper not available.")
}
} # }