Note
Go to the end to download the full example code
Multiple Resistance (MARI
)
Warning
What visualisation could we use?
Create further examples with temporal visualization.
Add parameters to choose antimicrobials that are consistent in time and have enough number of isolates to give an accurate measurement.
Determination of the Multiple Antimicrobial Resistance Index or MARI
follows the procedure
described by (5), in which the number of antimicrobials an isolate is resistant to (R) is divided by the
total number of the antimicrobials used in the study (T). Thus, the calculating formula for a single
isolate is shown below and it provides a value within the range [0,1] where values close to one indicate
high multi-drug resistance.
In more general scenarios, the antimicrobials to which the pathogens are tested vary among health care
centres and time, and therefore the comparison and analysis of MARI
evolution in time is not straight
forward. At the moment, for simplicity, it is recommended to check that the antimicrobials selected are
available in the whole study period before applying the index.
Note
Please, ensure that all isolates contains records for all antimicrobials.
For more information see: pyamr.core.mari.MARI
For the sample data created below, the overall MARI
for each isolate is
Date |
SPECIMEN |
MICROORGANISM |
LAB_NUMBER |
MARI |
---|---|---|---|---|
2021-01-01 |
BLDCUL |
ECOL |
lab1 |
4/10 = 0.400000 |
2021-01-01 |
BLDCUL |
ECOL |
lab2 |
0.800000 |
2021-01-02 |
BLDCUL |
ECOL |
lab3 |
0.700000 |
2021-01-03 |
BLDCUL |
ECOL |
lab4 |
0.909091 |
Similarly, the rolling window MARIs
for <BLDCUL, ECOL> are …
Date |
MARI (1D1) |
MARI (1D2) |
MARI Wrong! |
---|---|---|---|
2021-01-01 |
(0.4+0.8)/2 = 0.6 |
(0.4+0.8)/2 = 0.60 |
(0.4+0.8)/2 = 0.6 |
2021-01-02 |
0.7 = 0.7 |
(0.4+0.8+0.7)/3 = 0.63 |
(0.6+0.7)/2 = 0.65 |
2021-01-03 |
0.909091 = 0.9 |
(0.7+0.9)/2 = 0.80 |
(0.7+0.9)/2 = 0.8 |
56 # Import libraries
57 import warnings
58 import pandas as pd
59 import matplotlib as mpl
60
61 # Import specific libraries
62 from pyamr.core.mari import MARI
63 from pyamr.datasets.load import fixture
64
65 # Filter user warning
66 warnings.filterwarnings("ignore", category=UserWarning)
67
68 # Set matplotlib
69 mpl.rcParams['xtick.labelsize'] = 9
70 mpl.rcParams['ytick.labelsize'] = 9
71 mpl.rcParams['axes.titlesize'] = 11
72 mpl.rcParams['legend.fontsize'] = 9
73
74 # ---------------------
75 # Create data
76 # ---------------------
77 # Load data
78 data = fixture(name='fixture_05.csv')
79
80
81 # ---------------------
82 # Compute MARI
83 # ---------------------
84 # Create MARI instance
85 mari = MARI(groupby=['SPECIMEN',
86 'MICROORGANISM',
87 'LAB_NUMBER',
88 'SENSITIVITY'])
89
90 # Compute MARI overall
91 mari_overall, isolates = mari.compute(data,
92 return_frequencies=True,
93 return_isolates=True)
94
95 # Compute MARI temporal (ITI)
96 mari_iti = mari.compute(data, shift='1D',
97 period='1D', cdate='DATE',
98 return_isolates=False)
99
100 # Compute MARI temporal (OTI)
101 mari_oti = mari.compute(data, shift='1D',
102 period='2D', cdate='DATE',
103 return_isolates=False)
104
105 # Show
106 print("\nIsolates:")
107 print(isolates)
108 print("\n\n\nMARI (overall):")
109 print(mari_overall)
110 print("\n\n\nMARI (iti):")
111 print(mari_iti)
112 print("\n\n\nMARI (oti):")
113 print(mari_oti)
Isolates:
Empty DataFrame
Columns: []
Index: []
MARI (overall):
intermediate resistant sensitive n_records n_samples total mari
SPECIMEN MICROORGANISM
BLDCUL CNS 1.0 15.0 4.0 20.0 2 1.6000 0.8000
ECOL 4.0 25.0 12.0 41.0 4 2.8091 0.7023
URICUL ECOL 0.0 18.0 2.0 20.0 2 1.8000 0.9000
MARI (iti):
intermediate resistant sensitive n_records n_samples total mari
SPECIMEN MICROORGANISM DATE
BLDCUL CNS 2021-01-01 1.0 6.0 3.0 10.0 1.0 0.7000 0.7000
2021-02-01 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
ECOL 2021-01-01 4.0 8.0 8.0 20.0 2.0 1.2000 0.6000
2021-01-02 0.0 7.0 3.0 10.0 1.0 0.7000 0.7000
2021-01-03 0.0 10.0 1.0 11.0 1.0 0.9091 0.9091
URICUL ECOL 2021-02-01 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
2021-02-04 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
MARI (oti):
intermediate resistant sensitive n_records n_samples total mari
SPECIMEN MICROORGANISM DATE
BLDCUL CNS 2021-01-01 1.0 6.0 3.0 10.0 1.0 0.7000 0.7000
2021-02-01 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
ECOL 2021-01-01 4.0 8.0 8.0 20.0 2.0 1.2000 0.6000
2021-01-02 4.0 15.0 11.0 30.0 3.0 1.9000 0.6333
2021-01-03 0.0 17.0 4.0 21.0 2.0 1.6091 0.8045
URICUL ECOL 2021-02-01 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
2021-02-04 0.0 9.0 1.0 10.0 1.0 0.9000 0.9000
Lets see the susceptibility test records.
118 data.head(15)
Let’s display the overall_hard
resistance.
123 mari_overall
Let’s display the resistance time-series using independent
time intervals (ITI)
129 mari_iti
Let’s display the resistance time-series using overlapping
time intervals (OTI)
135 mari_oti
Let’s display the information graphically
Total running time of the script: ( 0 minutes 0.080 seconds)