percentileofscore: Percentile score

View source: R/managing_batch_effects.R

percentileofscoreR Documentation

Percentile score

Description

This function converts the relative abundance of microbial variables (i.e. bacterial taxa) in case (i.e. disease) samples to percentiles of the equivalent variables in control (i.e. healthy) samples. It is a built-in function of percentile_norm.

Usage

percentileofscore(df, control.index)

Arguments

df

A data frame that contains the microbial variables and required to be converted into percentile scores. Samples as rows and variables as columns.

control.index

A numeric vector that contains the indexes of control samples.

Value

A data frame of percentile scores for each microbial variable and each sample.

References

\insertRef

gibbons2018correctingPLSDAbatch

Examples

# A built-in function of percentile_norm, not separately used.
# Not run
library(TreeSummarizedExperiment)
data('AD_data')

ad.clr <- assays(AD_data$EgData)$Clr_value
ad.batch <- rowData(AD_data$EgData)$Y.bat
ad.trt <- rowData(AD_data$EgData)$Y.trt
names(ad.batch) <- names(ad.trt) <- rownames(AD_data$EgData)
trt.first.b <- ad.trt[ad.batch == '09/04/2015']
ad.first.b.pn <- percentileofscore(ad.clr[ad.batch == '09/04/2015', ],
                                    which(trt.first.b == '0-0.5'))



EvaYiwenWang/PLSDAbatch documentation built on Sept. 25, 2024, 8:54 p.m.