openpharma / clinsight

ClinSight - An application for medical monitoring within clinical trials
https://openpharma.github.io/clinsight/
Other
3 stars 0 forks source link

`Study data` tab: Allow continuous & categorical data to live in harmony #117

Open aclark02-arcus opened 1 month ago

aclark02-arcus commented 1 month ago

So, we have some urinalysis labs that have both categorical & continuous data in the form. Specifically:

Continuous

Categorical

If the code is left AS-IS

if all item_groups == "continuous", the plots generate as expected for the continuous variables, but all the categorical variables generate a bunch of empty plots (see below). On the table side of things, a the categorical variables have a ton of NA's (see below).

image

image

Now, if I change to item_type = 'other' for all the categorical variables, the table looks excellent but none of the plot generate, because of this line of code that requires all item_types be 'continuous': https://github.com/openpharma/clinsight/blob/a4d88ba4bf2ff54ef7e698973a23f1d5198f0b37/R/fct_appdata.R#L251

Proposal

Amend the code so that only 'continuous' variables be processed for plotting and 'other' (categorical) vars be untouched for display in the table.

LDSamson commented 3 weeks ago

It is intentional behavior that only the table is shown and not the figures with mixed data. If not done so, a monitor might review all data on a form with mixed data while never seeing the categorical data, which I think is a safety risk that should be avoided.

Although not ideal, you can always make two tabs for urinalysis, one with categorical and one with continuous data. Another way to avoid this is to ensure that 1) the user is made aware that there is more data in the table, and 2) the form cannot be reviewed unless the table is viewed as well.

However, I think the best non-temporary way to address this is to show different figures based on data type (continuous, categorical, dichotomous). There are already several figure functions in this package for doing so. But, in order to show mixed data, we need to stray away from facet_wrap within ggplot and build a faceted figure ourselves. This would have several other advantages, but will take some development time to do it right.

aclark02-arcus commented 3 weeks ago

Understood. I understand the reason behind that design decision.

We do have another use case to consider (besides the Urinanlysis use case) for the redesign... in our vital signs data, we have some measurements gathered at different timepoints... for example: measuring blood pressure after lying down, standing, and standing for 5 mins (etc). Because of that, are converting that column to an item_type = 'other' and that's forcing the whole tab to only display a table. If we mark it as 'continuous', the plot will have several points plotted on the same day. I envision this use case being an enhancement to the plots more than anything. But in order to avoid facet_wrap(), timepoint would probably have to be a filter on the right hand side. Or perhaps give users the option to aggregate the measurements into a mean plotted over time? OR you could adapt the legend and to make each measurement a different shape? Definitely a lot of ways to go.

This is really a separate issue, so I moved it to here: #121