Creates the M2 matrix from a given m1_inclusion_matrix and eventdata with intelligent memory management. Automatically detects when the operation would exceed memory limits and switches to a batched sparse matrix approach.
Usage
make_m2(
m1_inclusion_matrix,
eventdata,
batch_size = 5000,
memory_threshold = 2e+09,
force_fast = FALSE,
n_threads = 1,
use_cpp = TRUE,
verbose = FALSE
)Arguments
- m1_inclusion_matrix
A sparse matrix to be modified and used for creating the M2 matrix.
- eventdata
A data.table containing event information with at least
group_idand an index column.- batch_size
An integer specifying the number of groups to process per batch (default: 5000). Only used when batched processing is triggered.
- memory_threshold
A numeric value representing the maximum number of rows allowed in the summary before switching to batched processing (default: 2e9, which is ~93% of 2^31).
- force_fast
A logical flag to force fast processing regardless of size estimates (default: FALSE). WARNING: This may cause memory errors on large datasets.
- n_threads
Number of threads for parallel processing (default: 1). Used for C++ implementation and batched R processing. Values > 1 require parallel package for batched mode.
- use_cpp
Logical flag to use fast C++ implementation (default: TRUE). Falls back to R implementation if FALSE.
- verbose
A logical flag for detailed progress reporting (default: FALSE).
Examples
junction_abundance_object <- load_toy_SJ_object()
m1_obj <- make_m1(junction_ab_object = junction_abundance_object)
# obtaining the m1 and eventdata
m1 <- m1_obj$m1_inclusion_matrix
eventdata <- m1_obj$event_data
m2 <- make_m2(m1_inclusion_matrix = m1, eventdata = eventdata)
