Parameter heatmap component of WFPHM
wfphm_hmpar.RdParameter heatmap component of WFPHM
Usage
wfphm_hmpar_UI(id, tr_choices)
wfphm_hmpar_server(
id,
dataset,
cat_var,
par_var,
visit_var,
subjid_var,
value_vars,
sorted_x,
tr_mapper,
margin,
show_x_ticks
)Arguments
- id
Shiny ID
[character(1)]- dataset
[shiny::reactive(data.frame) | shinymeta::metaReactive(data.frame)]It expects the following format:
it contains, at least, the columns specified in the parameters:
cat_var,par_var,value_vars,visit_varandsubjid_varcat_var,par_var,visit_varandsubjid_varcolumns are factorsvalue_varsmust be numeric
- cat_var, par_var, visit_var, subjid_var
[character(1)]- value_vars
[character(1+)]possible colum values. If column is labelled, label will be displayed in the value menu
- tr_mapper
[function(1+)]named list containing a set of unary functions to transform the data. The name is the string shown in a selector and the value is the function to be applied according to details section.
- margin
[numeric(4) | shiny::reactive(numeric(4)) | shinymeta::metaReactive(numeric(4))]margin to be used on each of the sides. It must contain four entries named
top,bottom,leftandright- show_x_ticks
[logical(1)]show x ticks in the parameter heatmap
Details
Data subsetting:
Allows selecting several values from the
cat_varcolumn, from now on cat_selection and several values from thepar_varcolumn from the subset of rows wherepar_catis equal to cat_selection from now on par_selection.Menu labelled: Category and Parameter
Allows selecting between the columns defined in
value_varsfrom now on value_selection.Menu labelled: Value
Allows selecting a value from
visit_varcolumn, from now on visit_selection.Menu labelled: Visit
Subsets the dataset rows where:
visit_varequal to visit_selectionpar_varequal to par_selection
Subsets the dataset to
par_var,subj_varand the value_selection.If more than one row have the same combination
subj_varandpar_varan informative error indicating the plot cannot be created is shown.
Then the dataset is prepared to be passed to heatmap_D3:
subj_varbecomesxcolumnthe label attribute of
xcolumn isSubject IDpar_varbecomesycolumnvalue_selectionbecomeszcolumnzbecomeslabelcolumn
Completing the dataset:
Subset dataset will be completed in the following way. All non-present combination of the original levels of
xand 'y' is are added with rows where:xandyare equal to the missing combinationzis NA
Data outliers:
Allows setting two limits upper and lower for
yvalue, values above or below in the subsetted dataset will be considered outliers. Rows considered outliers will have the column:labelreplaced by "x"colorequal to "fill: white; font-weight: bold;"
Rows not considered outliers will have the column:
colorequal to NA
Data transformation:
Allows selecting between a set of functions as defined in
tr_mapperfrom now on transformation_function.Menu labelled: Transformation
This transformation is applied to the subset dataset grouped by the
ycolumn. i.e. each row of the heatmap is transformed independently.The function must be unary, and the unique argument will be the numerical values of a given row of the hetamap.
X axis ordering
xlevels are ordered according tosorted_x
Then a call to heatmap_D3 is done with the following arguments:
data=subset dataset(as described above)x_axis=Sy_axis=Wz_axis=Emarginis the parameter passed to this same functionpaletteis hardcoded toRColorBrewer::brewer.pal(n = 8, name = "Set2")after 8 categories colors are repeatedmsg_func= NULLquiet= TRUE