msberends / AMR

Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by using evidence-based methods, as described in https://doi.org/10.18637/jss.v104.i03.
https://msberends.github.io/AMR/
Other
83 stars 12 forks source link

Add denominators to each antibiotic in antibiogram #153

Open andrewjmc opened 3 months ago

andrewjmc commented 3 months ago

I have another suggestion. Sometimes one might wish to add raw denominator (and/or numerator) data to an antibiogram for each result. It might be verbose, but could be used for some downstream processing.

I tested a small hard-coded modification to the antibiogram code, with success except for the use of the digits parameter (I must have misunderstood some context). It would be little addition to have a parameter like raw_n with default NA and possible values of "N/D" and "D".

I'll be interested in your thoughts!

function (x, antibiotics = where(is.sir), mo_transform = "shortname", ab_transform = NULL, syndromic_group = NULL, add_total_n = TRUE, only_all_tested = FALSE, digits = 0, col_mo = NULL, language = get_AMR_locale(), minimum = 30, combine_SI = TRUE, sep = " + ", info = interactive()) { ... out <- out %pm>% pm_summarise(SI = paste0(round(numerator * 100/total, digits = digits), "% (", total, ")")) ... long_to_wide <- function(object, digs) {

object$SI <- round(object$SI * 100, digits = digs)

... }

msberends commented 3 months ago

Yes, that's a nice idea. They are 'kind of' added already at the moment, where I for the implementation followed this table from a recent paper to present the data. It's also shown in our manual:

image

The first column contains the denominators, but that can of course be different per antibiotic. That's not optimal. Where would you want to present the D or N/D then? Perhaps instead of the %SI?

andrewjmc commented 3 months ago

Thanks, I had noted the ability to provide in aggregate. In the example I gave I have presented by appending to the %SI, e.g. 6 becomes 6% (6/100). But it could be implemented with flexibility to provide denominators only, e.g. 6% (100). Alternative approaches could duplicate columns (e.g. AMK % and AMK n/d) or rows (e.g. CoNS % and CoNS n/d).

For me, I'm thinking of it more for downstream processing than for presentation - i.e. could be included as a hover detail in a plotly chart. There are use cases for presentation. If it is provided in a structured way, users can post-process to present richly-formatted tables (e.g. present the denominator in a small font size, different colour).