Shrink a numeric matrix across groups of rows, by applying a summary function.
Arguments
- x
numericmatrix- groupBy
characterorfactorvector of group labels, whose length equalsnrow(x). These values will become rownames in the output data.- shrink_func
functionthat takes vector input and returns single value output. The vector class can be checked, in order to call a function on numeric or character data separately, as needed.- return_class
characterstring indicating the return data type."data.frame"returns adata.framewhose first column contains entries fromgroups."matrix"returns a numeric matrix whose rownames are entries fromgroups.
- verbose
logical indicating whether to print verbose output.
- ...
additional arguments are ignored.
Details
This function is mainly a wrapper to use the amazingly fast
data.table package, with the ability to
provide a custom function to shrink row values.
The default function uses mean(x, na.rm=TRUE) so that NA
values are ignored where possible.
This function applies the same shrink_func to all columns, and
it optimal for numeric values. For more control over which
function to apply to specific columns, see shrinkDataFrame().
Trivia:
This function is identical to splicejam::shrinkDataFrame() except
that the default shrink_func includes na.rm=TRUE and no
longer calls an internal function, since that is not
permitted by CRAN package guidelines.
See also
Other jamses utilities:
choose_annotation_colnames(),
combine_sestats(),
contrast2comp_dev(),
fold_to_log2fold(),
intercalate(),
list2im_opt(),
list2im_value_internal(),
list_to_sestats(),
log2fold_to_fold(),
make_block_arrow_polygon(),
mark_stat_hits(),
matrix_normalize(),
merge_statdf_all_test(),
point_handedness(),
point_slope_intercept(),
shortest_unique_abbreviation(),
shrinkDataFrame(),
shrink_df(),
sort_samples(),
strsplitOrdered(),
sub_split_vector(),
update_function_params(),
update_list_elements()