STATcubeR icon indicating copy to clipboard operation
STATcubeR copied to clipboard

re-implement annotatons

Open GregorDeCillia opened this issue 2 years ago • 0 comments

In early versions, STATcubeR used to include annotations in the output of as.dataframe.sc_table(). This was dropped when support for OGD Datasets was introduced in #11 . Back then, the annotations were included using separate columns.

It is planned to re-implement this feature in a slightly different manner using {tibble} and {vctrs} by providing a custom vector class that acts as a "annotated numeric". The result of printing those values should look something like this

image

Annotations should either replace the values while printing or use color coding to reference a specific annotation

image

The "annotation legend" (which color corresponds to which annotation) can then be included in the footer of the tibble. Some technical details

  • [ ] In order to keep things backwards compatible, the default behavior of sc_tabulate() and as.data.frame.sc_table() should be to return simple tibbles that only include columns of type numeric and factor. Adding annotations should be "opt-in"
  • [x] Annotated cell values containing a zero can usually be interpreted as not available. Therefore, it makes sense to show the annotation code instead of the zero value (first screenshot). For annotated non-zero values, the values will be color-coded based on the annotation (second screnshot)
  • [x] The "annotated numeric" class used to represent the columns will have a as.numeric() method which drops the annotations and returns a canonical double-type
  • [ ] Aggregating annotations will not be pursued. If a sc_tabulate() is called in a way where aggregation via rowsums() is necessary and annotations is set to TRUE, an error will be thrown.
  • [x] Color-coding values with multiple annotations will not be pursued. Instead, one of the annotations will be selected for the color.

GregorDeCillia avatar Feb 20 '23 16:02 GregorDeCillia