propr: The propr Package

View source: R/1-propr.R

propr-classR Documentation

The propr Package

Description

Welcome to the propr package!

To learn more about calculating proportionality, see Details.

To learn more about differential proportionality, see propd.

To learn more about compositional data analysis, see citation("propr").

Usage

## S4 method for signature 'propr'
show(object)

propr(
  counts,
  metric = c("rho", "phi", "phs", "cor", "vlr", "pcor", "pcor.shrink", "pcor.bshrink"),
  ivar = "clr",
  select = NA,
  symmetrize = FALSE,
  alpha = NA,
  p = 0,
  fixseed = FALSE,
  ...
)

Arguments

object

A propr object.

counts

A data matrix representing counts. It is assumed that the matrix contains numerical values only.

metric

A character vector indicating the metric used for computing the association matrix. It can take the following values: - "rho": Propr matrix based on the rho coefficient. - "phi": Propr matrix based on the phi coefficient. - "phs": Propr matrix based on the symmetric phi coefficient. - "cor": Propr matrix based on the simple Pearson correlation coefficient. - "vlr": Propr matrix based on the variance of log-ratio (VLR). - "pcor": Propr matrix based on the partial correlation coefficient (using ppcor package). - "pcor.shrink": Propr matrix based on the shrinkage-estimated partial correlation coefficient (using corpcor package). - "pcor.bshrink": Propr matrix based on the partial correlation coefficient with basis shrinkage (ivar argument must be 'clr' or 'alr').

ivar

An indicator specifying the method for log-ratio transformation. It can take the following values: - "clr" (default): Centered log-ratio transformation. - "alr": Additive log-ratio transformation ("pcor.bshrink" metric only). - "iqlr": Inter-quartile log-ratio transformation from ALDEx2. - The explicit name(s) of variable(s) to use as a reference. Use NA to skip log-ratio transformation.

select

A numeric vector representing the indices of features to be used for computing the Propr matrix. This argument is optional. If provided, it reduces the data size by using only the selected features.

symmetrize

A logical value indicating whether to force symmetry in the output Propr matrix when the metric is "phi". If 'TRUE', the function will symmetrize the matrix; otherwise, it will return the original matrix.

alpha

The alpha parameter used in the alpha log-ratio transformation.

p

The number of permutations to perform for calculating the false discovery rate (FDR). The default is 0.

fixseed

A logical value indicating whether to fix the random seed for generating the pemurations. If 'TRUE', the function will fix the random The default is 'FALSE'.

...

Additional arguments passed to corpcor::pcor.shrink, if "pcor.shrink" metric is selected.

Details

The function performs log-ratio transformation and computes a Propr matrix using different measures of association.

Value

A propr object containing the Propr matrix, associated log-ratio transformation, and other calculated statistics.

Slots

counts

A data.frame. Stores the original "count matrix" input.

alpha

A double. Stores the alpha value used for transformation.

metric

A character string. The metric used to calculate proportionality.

ivar

A vector. The reference used to calculate proportionality.

logratio

A data.frame. Stores the transformed "count matrix".

matrix

A matrix. Stores the proportionality matrix.

pairs

A vector. Indexes the proportional pairs of interest.

results

A data.frame. Stores the pairwise propr measurements.

permutes

A list. Stores the shuffled transformed "count matrix" instances, used to reproduce permutations of propr.

fdr

A data.frame. Stores the FDR cutoffs for propr.

Methods (by generic)

show: Method to show propr object.

Examples

# Sample input count data
data <- matrix(c(10, 5, 15, 20, 30, 25), nrow = 2, byrow = TRUE)

# Calculate Propr matrix using correlation coefficient
result_cor <- propr(data, metric = "cor", ivar = "clr")

# Calculate Propr matrix using variance of log-ratio (VLR)
result_vlr <- propr(data, metric = "vlr", ivar = "clr")

# Calculate Propr matrix using partial correlation coefficient
result_pcor <- propr(data, metric = "pcor", ivar = "clr")


tpq/propr documentation built on April 21, 2024, 12:50 p.m.