This function computes the ratio of values above a minimum value for each feature.
See the Details section below for further information.
Arguments
- x
matrix
ordata.frame
, where rows are features and columns are observations.- g
(optional) vector or factor object giving the group for the corresponding elements of
x
.- min.expr
numerical value indicating the minimum expression required for
min.prop
samples.
Value
A vector
of length nrow(x)
containing the computed ratios.
If g
is provided, a matrix
with ratios for each class as column
vectors is returned.
Details
For each feature, the above-minimum frequency ratio (AMFR) is computed as:
$$Above-Minimum Frequency Ratio (AMFR) = \frac{Number of samples where expression is greater than provided minimum}{Total number of observations}$$
If g
is provided, the above-minimum frequency ratio (\(AMFR_{ij}\)) is
computed for each group \(j\) as:
$$AMFR_{ij} = \frac{Number of samples in j-th class where expression is greater than provided minimum}{Total number of observations in j-th class}$$
Examples
#Seed
set.seed(1010)
#Define row/col size
nr = 5
nc = 10
#Data
x = matrix(
data = sample.int(n = 100, size = nr*nc, replace = TRUE),
nrow = nr,
ncol = nc,
dimnames = list(
paste0("f",seq(nr)),
paste0("S",seq(nc))
)
)
#Grouping variable
g = c(rep("a", nc/2), rep("b", nc/2))
#AMFR
rowAboveMinFreqRatio(x)
#> f1 f2 f3 f4 f5
#> 1 1 1 1 1
#AMFR by group
rowAboveMinFreqRatio(x = x, g = g)
#> a b
#> f1 1 1
#> f2 1 1
#> f3 1 1
#> f4 1 1
#> f5 1 1