Format list of hit vectors into summary counts
Usage
format_hits(hits, style = c("text", "integer", "vector"), ...)Arguments
- hits
list,array, orvectorwith valuesc(-1, 1)indicating hits down, or hits up, respectively. When any vector contains onlyNAvalues, thenNAis also returned. This distinction is as follows:NAvalues indicate the statistical contrast was not performed, which happens whense_contrast_stats()arguments for interaction contrasts differ from pairwise contrasts, for exampleint_adjp_cutoff,int_p_cutoff, orint_fold_cutoff.length==0indicates the statistical contrast was performed, and there were no statistical hits for the given cutoffs.
- style
characterstring indicating the output format:"text":characterstring with"hits(hits up, hits down)"."integer":integernumber of hits, orNAwhen the test was not performed."vector":integervector with names("hit", "up", "down").
- ...
additional arguments are ignored.
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 withhit_arraydata fromse_contrast_stats()list: when used on a particular subset ofhit_arraydatanumeric: when used with a single contrast
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"whenstyle="text", for example:"623 hits (267 up, 379 down)"integer count of statistical hits when
style="integer", for example:623.vectorof integer counts forc("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.
See also
Other jamses stats:
ebayes2dfs(),
handle_na_values(),
hit_array_to_list(),
process_sestats_to_hitim(),
run_limma_replicate(),
save_sestats(),
se_contrast_stats(),
sestats_to_dfs(),
sestats_to_df(),
voom_jam()
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")
#> $`groupA-groupB`
#> [1] "25 hits (10 up, 15 down)"
#>
#> $`groupA-groupC`
#> [1] "50 hits (18 up, 32 down)"
#>
format_hits(hitlist, style="integer")
#> $`groupA-groupB`
#> [1] 25
#>
#> $`groupA-groupC`
#> [1] 50
#>