-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
211 lines (154 loc) · 6.14 KB
/
README.Rmd
File metadata and controls
211 lines (154 loc) · 6.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# amRshiny
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
**amRshiny** is an interactive Shiny dashboard for exploring antimicrobial resistance (AMR) data and machine learning model results.
This is the final package in the **AMR package suite**, [JRaviLab/amR](https://github.com/jravilab/amR):
- **amRdata**: Data (and metadata) preparation from BV-BRC
- **amRml**: ML modeling and analysis
- **amRshiny**: Interactive visualization (this package)
## Features
- **Metadata exploration**: Geographic distribution, temporal trends, host analysis
- **Model performance**: Compare ML models across species, drugs, and molecular scales (genes, proteins, domains, structures)
- **Feature importance**: Identify key predictive features with interactive heatmaps
- **Cross-model analysis**: Compare models trained on different stratifications (country, year)
- **Publication-quality exports**: Download plots and tables
- **Modular design**: Extensible UI components
## Installation
### Current (development version)
The package is currently available via GitHub and will be submitted to Bioconductor.
```r
# Install BiocManager if needed
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
# Install Bioconductor dependencies
BiocManager::install("ComplexHeatmap")
# Install amRshiny from GitHub
if (!requireNamespace("devtools", quietly = TRUE))
install.packages("devtools")
devtools::install_github("JRaviLab/amRshiny")
```
## Quick start
```r
library(amRshiny)
# Launch the dashboard
launch_dashboard()
```
The dashboard will open in your default web browser.
## Usage
### Dashboard navigation
The dashboard includes several tabs:
1. **Home**: Overview and project information
2. **Metadata**: Explore geographic, temporal, and host metadata
- Interactive maps and treemaps
- Temporal trends
- Host distribution
3. **Model performance**: Compare ML model metrics
- Filter by species, drug, molecular scale
- View confusion matrices
- Compare performance across models
4. **Feature importance**: Analyze predictive features
- Top features by importance
- Cross-species/drug comparisons
- Heatmaps and bar plots
5. **Cross-model comparison**: Compare models across stratifications
- Country-based models
- Year-based models
- Performance and feature consistency
6. **Query data**: Custom data queries
- Filter by multiple criteria
- Export filtered results
### Example: Exploring model performance
```r
launchAMRDashboard()
# In the dashboard:
# 1. Navigate to "Model Performance" tab
# 2. Select species: "Shigella flexneri"
# 3. Select drug: "ampicillin"
# 4. Select molecular scale: "genes"
# 5. View performance metrics and confusion matrix
```
### Data requirements
The dashboard works with pre-computed data files located in `inst/app/data/`:
- `amr_filtered_tbls.db`: DuckDB database with AMR data
- `all_performances.tsv`: Model performance metrics
- `drug_class_map.tsv`: Drug classification mapping
- `metadata/`: Species-specific metadata files
To use your own data, structure files following the same schema.
## Data Schema
### Performance metrics
Required columns:
- `bug`: Species code
- `antibiotic`: Drug name
- `scale`: Molecular scale (gene, protein, domain, struct)
- `type`: Count or binary features
- `bal_acc`: Balanced accuracy
- `f1`: F1 score
- `nmcc`: Normalized Matthews correlation coefficient
- Additional columns for other metrics
### Metadata files
Location: `inst/app/data/metadata/{species}.parquet`
Required columns:
- `genome_id`: Unique genome identifier
- `genome.isolation_country`: Country of isolation
- `genome.collection_year`: Collection year
- `genome.host_name`: Host organism
- Additional metadata columns as needed
## Development
### Package structure
```
amRshiny/
├── R/
│ └── launch_dashboard.R # Main launch function
├── inst/
│ └── app/
│ ├── app.R # Main Shiny app
│ ├── utils.R # Utility functions
│ ├── modules/ # UI modules
│ ├── data/ # Dashboard data files
│ └── www/ # Static assets (CSS, images)
├── man/ # Documentation
└── DESCRIPTION
```
## Citation
If you use `amRshiny` in your research, please cite:
```
Brenner E, Ghosh A, Wolfe E, Boyer E, Vang C, Lesiyon R, Mayer D, Ravi J. (2026).
amR: an R package suite to predict antimicrobial resistance in bacterial pathogens.
R package version 0.99.0.
https://github.com/JRaviLab/amR
```
## For Bioconductor submission
This package is being prepared for Bioconductor submission. It includes:
- **biocViews**: GUI, MicrobialGenomics, Pathogen, Visualization
- **Bioconductor dependencies**: ComplexHeatmap
- **R version requirement**: R >= 4.1.0
- **Documentation**: Comprehensive function documentation with examples
- **Data**: Pre-computed AMR model results included in `inst/app/data/`
## Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
### Reporting Issues
Report bugs and request features at: https://github.com/JRaviLab/amRshiny/issues
## Related projects
- [amRdata](https://github.com/JRaviLab/amRdata): Data preparation for AMR prediction
- [amRml](https://github.com/JRaviLab/amRml): ML modeling framework
- [BV-BRC](https://www.bv-brc.org/): Bacterial and Viral Bioinformatics Resource Center
## Code of conduct
Please note that the amRshiny project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.
## License
BSD 3-Clause License. See [LICENSE](LICENSE) for details.
## Contact
**Corresponding author**: Janani Ravi (janani.ravi@cuanschutz.edu)
**JRaviLab**: https://jravilab.github.io