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

Error in seq_len #53

Closed susheelbhanu closed 2 years ago

susheelbhanu commented 2 years ago

Hi,

I'm trying to run ab_from_text on a list of drugs and am getting the following error:

> ab_from_text(drugs_wo_empty$CRF_concomitant_medication_which, type = "drug",
+              thorough_search = TRUE, info = TRUE)
[======>--------------------------------------------------------------------------------------------------------------------------]   6% (17/20)Error in seq_len(length(v) - 1) : 
  argument must be coercible to non-negative integer

The list of drugs looks like this

> drugs_wo_empty$CRF_concomitant_medication_which
  [1] "L-Thyroxin 175µg [175µg Levothyroxin natrium, (170,2µg Levothyroxin)] 1x1 => Hyperthyreose seit 1999"                                                                                                                                                                                                                                                                                                                                                                                                      
  [2] "Mirtazapin 15mg 1x0,25 => Hypoxie/Schlafstörung seit 03.2012"                                                                                                                                                                                                                                                                                                                                                                                                                                              
  [3] "Magnesium Dragees [(keine Wirkstoff-Angaben)] 1x1 => Obstipation seit 01.2014"                                                                                                                                                                                                                                                                                                                                                                                                                             
  [4] "Marcumar 3mg [3mg Phenprocoumon] nach INR 1x0,25 => Vorhoffflimmern seit 30.11.2010"                                                                                                                                                                                                                                                                                                                                                                                                                       
  [5] "MetoHEXAL 50mg [50mg Metoprololtartrat (Ph.Eur.) (39mg Metoprolol)]  im Wechsel 1er Tag: 1x1 + 2ter Tag: 1x0,5 => Hypertonie seit 03.2013"                                                                                                                                                                                                                                                                                                                                                                 
  [6] "Propafenon 300 [300mg Propafenon-HCl (271mg Propafenon)] im Wechsel 1er Tag: 1x1,5 + 2ter Tag: 1x2 => Vorhoffflimmern seit 03.2013"                                                                                                                                                                                                                                                                                                                                                                        
  [7] "Bedarfsmedikation: MOVICOL Pulv. [13,13g Macrogol 3350, 0,35g Natriumchlorid, (0,138g Natrium), 0,18g Natriumhydrogencarbonat, 0,05g Kaliumchlorid] 1 Btl. => bei Obstipation seit 03.2013"                                                                                                                                                                                                                                                                                                                
  [8] "Dominal forte 40mg [40mg Prothipendyl hydrochlorid-1-Wasser, (33,6mg Prothipendyl)] 1x bei Hypoxie/Schlafstörung seit 07.2012"                                                                                                                                                                                                                                                                                                                                                                             
  [9] "Twynsta 40mg/10mg [40mg Telmisartan, 13,9mg Amlodipinbesilat (10mg Amlodipin)] 1x  => bei Bedarf - Hypertonie seit 04.2012"                                                                                                                                                                                                                                                                                                                                                                                
 [10] "dispatim 0,5%Augentropfen [6,83mg/1ml Timolol hydrogenmaleat, (5mg/1ml Timolol)] 1x in jedes Auge 1 Tr. => Glaukom seit 1992"                                                                                                                                                                                                                                                                                                                                                                              
 [11] "Bedarfsmedikation: Ibuprofen 600mg 1x1 bei Rückenschmerzen seit 08.2012"                                                                                                                                                                                                                                                                                                                                                                                                                                   
 [12] "Bisoprolol 2,5mg [2,5 mg Bisoprololfumarat (2:1) (2,12 mg Bisoprolol)] 1x1 => Hypertonie seit 12.2013"                                                                                                                                                                                                                                                                                                                                                                                                     
 [13] "Ramipril 5mg 1x1 => Hypertonie seit 12.2013"                                                                                                                                                                                                                                                                                                                                                                                                                                                               
 [14] "Fungazol 200mg 1xWoche => Nagelpilz seit 06.2013"                                                                                                                                                                                                                                                                                                                                                                                                                                                          
 [15] "Allopurinol 300mg 1x1 => Hyperurikämie seit 1980"                                                                                                                                                                                                                                                                                                                                                                                                                                                          
 [16] "Aprovel 300mg [300mg Irbesartan] 1x0,5 => Hypertonie seit 08.2012"                                                                                                                                                                                                                                                                                                                                                                                                                                         
 [17] "Euthyrox 150µg [150µg Levothyroxin natrium, (145,88µg Levothyroxin)] 1x1 => Hypothyreose seit 1980"                                                                                                                                                                                                                                                                                                                                                                                                        
 [18] "LisiHEXAL 10mg [10,89mg Lisinopril 2H2O, (10mg Lisinopril)] 1x1 => Hypertonie seit 15.08.2014"                                                                                                                                                                                                                                                                                                                                                                                                             
 [19] "Kalinor 1,56g Kalium/2,5g Citrat Brausetabl. [2,17g Kaliumcitrat 1H2O, (0,78g Kalium), 2g Kaliumhydrogencarbonat]  alle 2Tage => Wadenkrämpfe seit 15.08.2014"                                                                                                                                                                                                                                                                                                                                             
 [20] "Hyaluronsäure 1x2 => LWS-Bandscheibenschäden seit 05.2014"

Could you please help with this?

Thank you, Susheel

msberends commented 2 years ago

Hi! Yes, sure. It seems to be a bug, I’ll look into it!

susheelbhanu commented 2 years ago

Thank you

msberends commented 2 years ago

It was indeed a bug, I'll push a fix to this repo today.

But even fixed, the text used as input might not be very suitable for retrieving antibiotic codes - in what you posted there are almost no antibiotics to be found if I manually scan through them with my own knowledge about antibiotic/antifungal drugs.

This also leads to many false-positives. For example, the problematic one that led to the error was nr 17:

[17] "Euthyrox 150µg [150µg Levothyroxin natrium, (145,88µg Levothyroxin)] 1x1 => Hypothyreose seit 1980"

Without the bug, this would be the result:

ab_from_text(x[17], type = "drug", thorough_search = TRUE)
#> [[1]]
#> Class <ab>
#> [1] INH AKF AKF AKF CPO

So that's a list of isoniazid, 3 times amikacin/fosfomycin, and cefpirome. Not very helpful I guess... The ab_from_text() function can only retrieve antibiotic/antifungal drugs, not other drugs.

Does this clarify things a bit?

susheelbhanu commented 2 years ago

Dear @msberends,

Thank you very much for pushing this fix.

And indeed what you say makes sense. I have a list of 300 unique drugs, and was using the package to reduce my workload of manually validating which ones are antibiotics and which are not 😉 . It was the first step of my screening process, or else I'd have to look through entire list manually and confirm via a Google search.

Any (false)-positives that we get from this analyses, we will manually verify to make sure they are indeed antibiotics/antifungals, so this is already helpful.

I am assuming though, that if it doesn't find any matches, it'll simply report a NA - is that correct?

And thanks again for fixing it so quickly.

msberends commented 2 years ago

That’s a fine workflow!

Indeed, when no results are found it will return NA.

susheelbhanu commented 2 years ago

Awesome, thank you. It is a nice workflow indeed 🙂.