quantile_normalize {TidyDensity}R Documentation

Perform quantile normalization on a numeric matrix/data.frame

Description

This function will perform quantile normalization on two or more distributions of equal length. Quantile normalization is a technique used to make the distribution of values across different samples more similar. It ensures that the distributions of values for each sample have the same quantiles. This function takes a numeric matrix as input and returns a quantile-normalized matrix.

Usage

quantile_normalize(.data, .return_tibble = FALSE)

Arguments

.data

A numeric matrix where each column represents a sample.

.return_tibble

A logical value that determines if the output should be a tibble. Default is 'FALSE'.

Details

This function performs quantile normalization on a numeric matrix by following these steps:

  1. Sort each column of the input matrix.

  2. Calculate the mean of each row across the sorted columns.

  3. Replace each column's sorted values with the row means.

  4. Unsort the columns to their original order.

Value

A list object that has the following:

  1. A numeric matrix that has been quantile normalized.

  2. The row means of the quantile normalized matrix.

  3. The sorted data

  4. The ranked indices

Author(s)

Steven P. Sanderson II, MPH

See Also

rowMeans: Calculate row means.

apply: Apply a function over the margins of an array.

order: Order the elements of a vector.

Other Utility: check_duplicate_rows(), convert_to_ts(), tidy_mcmc_sampling(), util_beta_aic(), util_binomial_aic(), util_cauchy_aic(), util_chisq_aic(), util_exponential_aic(), util_f_aic(), util_gamma_aic(), util_generalized_beta_aic(), util_generalized_pareto_aic(), util_geometric_aic(), util_hypergeometric_aic(), util_inverse_burr_aic(), util_inverse_pareto_aic(), util_inverse_weibull_aic(), util_logistic_aic(), util_lognormal_aic(), util_negative_binomial_aic(), util_normal_aic(), util_paralogistic_aic(), util_pareto1_aic(), util_pareto_aic(), util_poisson_aic(), util_t_aic(), util_triangular_aic(), util_uniform_aic(), util_weibull_aic(), util_zero_truncated_binomial_aic(), util_zero_truncated_geometric_aic(), util_zero_truncated_negative_binomial_aic(), util_zero_truncated_poisson_aic()

Examples

# Create a sample numeric matrix
data <- matrix(rnorm(20), ncol = 4)

# Perform quantile normalization
normalized_data <- quantile_normalize(data)
normalized_data

as.data.frame(normalized_data$normalized_data) |>
  sapply(function(x) quantile(x, probs = seq(0, 1, 1 / 4)))

quantile_normalize(
data.frame(rnorm(30),
           rnorm(30)),
           .return_tibble = TRUE)


[Package TidyDensity version 1.5.0 Index]