Description Usage Arguments Value Author(s) Examples
apply_per_group
: Apply a function to each group which is a subset of
samples and binders stratified by the variables in @sinfo
and
@binder
. The variable names are given by the argument by_s
and
by_b
.
1 2 3 4 5 6 7 8 9 10 11 | apply_per_group(baf, FUN, ..., by_s = NULL, by_b = NULL, passBAf = FALSE)
sapply_per_group(
baf,
FUN,
...,
by_s = NULL,
by_b = NULL,
b_simplify = T,
s_simplify = b_simplify
)
|
baf |
an object of |
FUN |
the function |
... |
the arguments that will be passed to FUN |
by_s, by_b |
by which the samples (by_s) or binders (by_b)
are grouped. The FUN is applied to each group and the results are
combined. This can be given by 1) a |
passBAf |
if BAf object instead of matrix in @.Data is passed when applying the FUN. |
b_simplify |
if the output should be simplified like |
s_simplify |
if the output within stratified group by the |
an object of BAf-class
Mun-Gwan Hong <mun-gwan.hong@scilifelab.se>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | data(sba)
summary(sba)
# mean per plate and assay
apply_per_group(sba, mean, by_s= "plate", by_b= "assay")
# calculate median after stratifying samples by "plate" and "sex"
apply_per_group(sba, median, na.rm= TRUE, by_s= c("plate", "sex"))
# verify the first median computed by above line
median(sba@.Data[with(sba@sinfo, plate == "1" & !is.na(sex) & sex == "female"), ])
# compute coefficients of variation (CV) of \code{MIX_1} wells
apply_per_group(sba[sba@sinfo$cohort == "MIX_1", 1:5], FUN= function(j) {
apply(j, 2, function(k) sd(k, na.rm= TRUE)/mean(k, na.rm= TRUE))
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.