Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uti argument in as.sir not working as expected #141

Closed
samueljpearce opened this issue Mar 12, 2024 · 10 comments
Closed

uti argument in as.sir not working as expected #141

samueljpearce opened this issue Mar 12, 2024 · 10 comments
Labels
bug Something isn't working, labelled wrong or otherwise erroneous

Comments

@samueljpearce
Copy link

samueljpearce commented Mar 12, 2024

This is for veterinary data using CLSI 2023 guidelines. I have a dataframe with a list of MICs for a variety of antimicrobials and a column labelled "specimen" which has the body site, including some "urine" samples.

I am having several issues with the uti argument as follows:

  • When I do not specify the argument, urine isolates are not interpreted with different breakpoints and therefore are being returned as resistant (a particular issue for AMP and AMC).
  • When I specify uti = TRUE, all are interpreted with urine breakpoints regardless of the site specified.
  • If I create a specific column of logicals for urine samples (e.g. a TRUE/FALSE column called "urine") and point the uti argument to it (e.g. dataset %>% mutate_if(is.mic, as.sir, guideline = "CLSI", breakpoint_type = "animal", host = "host", col_mo = "organism_name", uti = "urine")), like the example given on the as.sir documentation (https://msberends.github.io/AMR/reference/as.sir.html), I get this error argument uti must be TRUE or FALSE, i.e. not be a text string
@samueljpearce
Copy link
Author

I think my issue was using as.sir within mutate_if. However, using it outside of a mutate function results in a different problem where as.sir tries to interpret non-mic columns. For example, running as.sir(guideline = "CLSI", breakpoint_type = "animal", host = "host", uti = "urine"), on a dataframe consisting of "mo", "host", "urine" and a series of antimicrobial MIC columns gives this error: Warning: in as.sir(): 171 results in column 'mo' truncated (100%) that were invalid antimicrobial interpretations: "Dog" OK.

@msberends
Copy link
Owner

Definitely something to improve! I was just working on it the other week. Which version of the package did you use?

@msberends msberends added the bug Something isn't working, labelled wrong or otherwise erroneous label Mar 12, 2024
@samueljpearce
Copy link
Author

I updated to v2.1.1 today so it should be latest release!

@msberends
Copy link
Owner

It is, but you might be interested in our latest beta version that is all about veterinary medicine :)

Please read this: https://msberends.github.io/AMR/news/index.html

You can now set animal species! Supports 20 languages.

I’m curious if this solves your problem with uti as well.

You can try the latest version using:

install.packages("AMR", repos = "https://msberends.r-universe.dev/")

Would be awesome if you could let me know if this revamped approach works for you!

@samueljpearce
Copy link
Author

Oh I missed that v2.1.1.9015 wasn't on CRAN yet. Thanks for letting me know - I will try it out!

@samueljpearce
Copy link
Author

I’m curious if this solves your problem with uti as well.

Yes and no. As I thought, the mutate_if(x, is.mic, as.sir) method doesn't seem to work (the same happens with the new "host" column). I'm no expert with R but I would think this is because it is mutating at the specified point (i.e. columns that match is.mic) and therefore the function does not have the scope to access the specimen and host columns. Does it work for you?

When using as.sir(data, ...) it does still seem to try and interpret other columns, but at least it doesn't seem to affect the output as far as I can tell.

@samueljpearce
Copy link
Author

The more I use this argument, the harder I find it is to get consistent behaviour from it but I think I may have found the problem. I've created a minimal example dataset attached.

minimal_reproducible_example.csv

With this minimal example, if you run as.sir(data, guideline = "CLSI", breakpoint_type = "animal", uti = "uti", host = "host") on the whole dataset, it incorrectly identifies many E. coli isolates as resistant to AMP. However, if you run only say, the first 30 samples, it correctly identifies them as sensitive or resistant.

It seems to be that the breakpoints do not get applied correctly to each host if there are multiple. For example, using this dataset, the above as.sir function will correctly identify dog urine isolates as S or R. Once you include isolate 33 which is a cat, they all seem to become resistant.

The canine and feline breakpoints should be the same for AMP and E. coli, so I did some digging into the clinical_breakpoints dataset and it does not actually have the feline uncomplicated UTI breakpoint for AMP, even though it is in the CLSI VET01 2023 guidelines.

Therefore, I think it is blanket applying the soft tissue breakpoint for cats, to both the cat and dog isolates, rendering them all resistant.

@msberends
Copy link
Owner

Wow, thanks so much for your time!

Consistent behaviour is the most important thing, so some bits must be changed in the functions, no doubt about that.

The canine and feline breakpoints should be the same for AMP and E. coli, so I did some digging into the clinical_breakpoints dataset and it does not actually have the feline uncomplicated UTI breakpoint for AMP, even though it is in the CLSI VET01 2023 guidelines.

This is also a very important thing, I need to check why this is the case. Are you not getting notes that dogs breakpoints are being used?

@samueljpearce
Copy link
Author

It does, but it seems to default to the soft tissue breakpoints, rendering urine cultures resistant.

@samueljpearce
Copy link
Author

Closing as part of wider issue in #142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, labelled wrong or otherwise erroneous
Projects
None yet
Development

No branches or pull requests

2 participants