Skip to contents

Checks whether X_raw and Y_raw have the same number of rows, and if not, randomly subsamples both to the smaller of the two sizes so that they can be compared or paired downstream.

Usage

align_sample_sizes(X_raw, Y_raw, seed = 2024)

Arguments

X_raw

A matrix or data frame; rows are samples.

Y_raw

A matrix or data frame; rows are samples.

seed

Integer random seed used when subsampling, for reproducibility. Defaults to 2024.

Value

A list with two elements, X and Y, each a matrix or data frame with matching row counts. If the inputs already had equal row counts, they are returned unchanged.

Examples

X_raw <- matrix(rnorm(30), nrow = 10)
Y_raw <- matrix(rnorm(24), nrow = 8)
aligned <- align_sample_sizes(X_raw, Y_raw)
#> Warning: The sample size of X (10) is inconsistent with that of Y (8), and will be automatically aligned to the smaller value. 
#> Sample size after alignment: 8
nrow(aligned$X)
#> [1] 8
nrow(aligned$Y)
#> [1] 8