format_hits: Format list of hit vectors into summary counts

format_hitsR Documentation

Format list of hit vectors into summary counts

Description

Format list of hit vectors into summary counts

Usage

format_hits(hits, style = c("text", "integer", "vector"), ...)

Arguments

hits

list, array, or vector with values c(-1, 1) indicating hits down, or hits up, respectively. When any vector contains only NA values, then NA is also returned. This distinction is as follows:

  • NA values indicate the statistical contrast was not performed, which happens when se_contrast_stats() arguments for interaction contrasts differ from pairwise contrasts, for example int_adjp_cutoff, int_p_cutoff, or int_fold_cutoff.

  • length==0 indicates the statistical contrast was performed, and there were no statistical hits for the given cutoffs.

style

character string indicating the output format:

  • "text": character string with "hits(hits up, hits down)".

  • "integer": integer number of hits, or NA when the test was not performed.

  • "vector": integer vector with names ⁠("hit", "up", "down")⁠.

...

additional arguments are ignored.

Details

This function is used by sestats_to_df(), to summarize hits for each contrast into one of these formats:

  • string summary of statistical hits with "hits,up,down" when style="text", for example: "623 hits (267 up, 379 down)"

  • integer count of statistical hits when style="integer", for example: 623.

  • vector of integer counts for c("hits", "up", "down"), for example: c(hits=623, up=267, down=379).

The function may be useful outside of sestats_to_df() so it is exported as a convenience function.

Value

the same data type as input, where the hit vector is replaced with a single value summarizing the hits. The data types have three expected options:

  • array: when used with hit_array data from se_contrast_stats()

  • list: when used on a particular subset of hit_array data

  • numeric: when used with a single contrast

Examples

set.seed(123)
hitlist <- list(
   `groupA-groupB`=sample(c(-1, 1), size=25, replace=TRUE),
   `groupA-groupC`=sample(c(-1, 1), size=50, replace=TRUE))
format_hits(hitlist, style="text")
format_hits(hitlist, style="integer")


jmw86069/jamses documentation built on May 31, 2024, 1:36 p.m.