Skip to content

Commit 709b79f

Browse files
committed
Vignette Rewrite
1 parent 3b46be2 commit 709b79f

11 files changed

Lines changed: 435 additions & 262 deletions

README.Rmd

Lines changed: 113 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ knitr::opts_chunk$set(
1919
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
2020
<!-- badges: end -->
2121

22-
**amRviz** is an interactive Shiny dashboard for exploring antimicrobial resistance (AMR) data and machine learning model results.
22+
**amRviz** is an interactive Shiny dashboard for exploring antimicrobial resistance (AMR) data and machine learning model results generated by [amRml](https://github.com/JRaviLab/amRml).
2323

2424
This is the final package in the **AMR package suite**, [JRaviLab/amR](https://github.com/jravilab/amR):
2525

@@ -29,27 +29,22 @@ This is the final package in the **AMR package suite**, [JRaviLab/amR](https://g
2929

3030
## Features
3131

32-
- **Metadata exploration**: Geographic distribution, temporal trends, host analysis
32+
- **Metadata exploration**: Geographic distribution, temporal trends, host and isolation-source analysis
3333
- **Model performance**: Compare ML models across species, drugs, and molecular scales (genes, proteins, domains, structures)
34-
- **Feature importance**: Identify key predictive features with interactive heatmaps
34+
- **Feature importance**: Identify key predictive features with interactive plots, annotation tables, and networks
3535
- **Cross-model analysis**: Compare models trained on different stratifications (country, year)
36-
- **Publication-quality exports**: Download plots and tables
37-
- **Modular design**: Extensible UI components
36+
- **Dynamic species selection**: Dropdowns automatically populate from loaded data — no hardcoded species lists
37+
- **Demo mode**: Ships with example *Shigella flexneri* data; swap in your own amRml output with one argument
3838

3939
## Installation
4040

41-
### Current (development version)
42-
4341
The package is currently available via GitHub and will be submitted to Bioconductor.
4442

45-
```r
43+
```{r, eval = FALSE}
4644
# Install BiocManager if needed
4745
if (!requireNamespace("BiocManager", quietly = TRUE))
4846
install.packages("BiocManager")
4947
50-
# Install Bioconductor dependencies
51-
BiocManager::install("ComplexHeatmap")
52-
5348
# Install amRviz from GitHub
5449
if (!requireNamespace("devtools", quietly = TRUE))
5550
install.packages("devtools")
@@ -59,88 +54,107 @@ devtools::install_github("JRaviLab/amRviz")
5954

6055
## Quick start
6156

62-
```r
57+
```{r, eval = FALSE}
6358
library(amRviz)
6459
65-
# Launch the dashboard
66-
launch_dashboard()
60+
# Launch with built-in Shigella flexneri demo data
61+
launchAMRDashboard()
62+
63+
# Launch with your own amRml output
64+
launchAMRDashboard(results_root = "/path/to/your/amRml/results")
6765
```
6866

69-
The dashboard will open in your default web browser.
67+
The dashboard will open in your default web browser. Species dropdowns will populate automatically from whichever data is loaded.
7068

7169
## Usage
7270

7371
### Dashboard navigation
7472

75-
The dashboard includes several tabs:
73+
The dashboard is organized into tabs:
7674

77-
1. **Home**: Overview and project information
78-
2. **Metadata**: Explore geographic, temporal, and host metadata
79-
- Interactive maps and treemaps
80-
- Temporal trends
81-
- Host distribution
75+
1. **Home**: Overview, suite workflow, and project information
76+
2. **Metadata**: Explore geographic, temporal, host, and isolation-source metadata
77+
- Summary statistics (genomes, drugs, drug classes, resistant/susceptible tests)
78+
- Phenotype distribution by drug, geographic map, and temporal trends
79+
- Host and isolation-source breakdown, plus a phenotype → drug → country → source Sankey
8280
3. **Model performance**: Compare ML model metrics
83-
- Filter by species, drug, molecular scale
84-
- View confusion matrices
85-
- Compare performance across models
86-
4. **Feature importance**: Analyze predictive features
87-
- Top features by importance
88-
- Cross-species/drug comparisons
89-
- Heatmaps and bar plots
90-
5. **Cross-model comparison**: Compare models across stratifications
91-
- Country-based models
92-
- Year-based models
93-
- Performance and feature consistency
94-
6. **Query data**: Custom data queries
95-
- Filter by multiple criteria
96-
- Export filtered results
97-
98-
### Example: Exploring model performance
99-
100-
```r
101-
launchAMRDashboard()
102-
103-
# In the dashboard:
104-
# 1. Navigate to "Model Performance" tab
105-
# 2. Select species: "Shigella flexneri"
106-
# 3. Select drug: "ampicillin"
107-
# 4. Select molecular scale: "genes"
108-
# 5. View performance metrics and confusion matrix
109-
```
81+
- Filter by species, drug/drug class, molecular scale, and data encoding
82+
- Per-model metric distributions, plus a Performance overview (nMCC strip plot and drug-class heatmaps)
83+
4. **Bug/Drug feature comparison**: Analyze predictive features
84+
- Top features across species or across drugs
85+
- Annotated feature tables (COG/ARG), category barplots, and ego networks
86+
5. **Model holdouts**: Compare models across stratifications
87+
- Country-holdout and year-interval models
88+
- Accuracy distributions, performance heatmaps, and feature consistency
89+
6. **Network**: Interactive force-directed drug → feature graph, with optional cluster/COG nodes
90+
7. **Query data**: Browse and export the raw performance-metric and top-feature tables as CSV
11091

11192
### Data requirements
11293

113-
The dashboard works with pre-computed data files located in `inst/app/data/`:
94+
amRviz reads the parquet files produced by **amRml**. Files must be organized into per-species subdirectories:
11495

115-
- `all_performances.tsv`: Model performance metrics
116-
- `drug_class_map.tsv`: Drug classification mapping
117-
- `metadata/`: Species-specific metadata files
118-
119-
To use your own data, structure files following the same schema.
120-
121-
## Data Schema
122-
123-
### Performance metrics
124-
Required columns:
125-
- `bug`: Species code
126-
- `antibiotic`: Drug name
127-
- `scale`: Molecular scale (gene, protein, domain, struct)
128-
- `type`: Count or binary features
129-
- `bal_acc`: Balanced accuracy
130-
- `f1`: F1 score
131-
- `mcc`: Matthews correlation coefficient
132-
- `nmcc`: Normalized Matthews correlation coefficient
133-
- Additional columns for other metrics
134-
135-
### Metadata files
136-
Location: `inst/app/data/metadata/{species}.parquet`
96+
```
97+
results/
98+
├── Shigella_flexneri/
99+
│ ├── Sfl_ML_perf.parquet
100+
│ ├── Sfl_country_ML_perf.parquet
101+
│ ├── Sfl_year_ML_perf.parquet
102+
│ ├── Sfl_cross_ML_perf.parquet
103+
│ ├── Sfl_ML_top_features.parquet
104+
│ ├── Sfl_country_ML_top_features.parquet
105+
│ ├── Sfl_year_ML_top_features.parquet
106+
│ └── Sfl_metadata.parquet
107+
├── Klebsiella_pneumoniae/
108+
│ ├── Kpn_ML_perf.parquet
109+
│ └── ...
110+
└── ...
111+
```
137112

138-
Required columns:
139-
- `genome_id`: Unique genome identifier
140-
- `genome.isolation_country`: Country of isolation
141-
- `genome.collection_year`: Collection year
142-
- `genome.host_name`: Host organism
143-
- Additional metadata columns as needed
113+
- The **subdirectory name** (e.g. `Shigella_flexneri`) is used as the display label throughout the dashboard.
114+
- The **species code** (e.g. `Sfl`) inside each parquet is used for internal filtering.
115+
- Pass `results_root = "/path/to/results"` to `launchAMRDashboard()` to load your own data. Without this argument the dashboard loads the bundled demo data.
116+
117+
## Data schema
118+
119+
### Performance metrics (`*_ML_perf.parquet`)
120+
121+
| Column | Description |
122+
|---|---|
123+
| `species` | Species code (e.g. `"Sfl"`) |
124+
| `drug_or_class` | Drug or drug class abbreviation |
125+
| `drug_label` | `"drug"` or `"drug_class"` |
126+
| `feature_type` | Molecular scale: `genes`, `proteins`, `domains`, `struct` |
127+
| `feature_subtype` | Data encoding: `binary`, `counts` |
128+
| `strat_label` | Stratification: blank (baseline), `"country"`, or `"year"` |
129+
| `strat_value` / `strat_value_test` | Trained-on / tested-on country or year (stratified/cross models) |
130+
| `nmcc`, `bal_acc`, `f1`, `sens`, `spec` | Performance metrics |
131+
132+
### Top features (`*_ML_top_features.parquet`)
133+
134+
| Column | Description |
135+
|---|---|
136+
| `species` | Species code |
137+
| `drug_or_class` | Drug or drug class abbreviation |
138+
| `feature_type` | Molecular scale |
139+
| `feature_subtype` | Data encoding |
140+
| `strat_label` | Stratification (blank for baseline) |
141+
| `Variable` | Feature identifier (gene/protein/domain ID) |
142+
| `Importance` | Feature importance score |
143+
| `Sign` | Direction of effect |
144+
145+
### Metadata (`*_metadata.parquet`)
146+
147+
| Column | Description |
148+
|---|---|
149+
| `genome_drug.genome_id` | Unique genome identifier |
150+
| `genome_drug.antibiotic` | Antibiotic tested |
151+
| `genome_drug.resistant_phenotype` | `"Resistant"` or `"Susceptible"` |
152+
| `genome.isolation_country` | Country of isolation |
153+
| `genome.collection_year` | Collection year |
154+
| `genome.host_common_name` | Host organism |
155+
| `genome.isolation_source` | Isolation source |
156+
| `drug_class` | Drug class |
157+
| `resistant_classes` | All resistant drug classes for this isolate |
144158

145159
## Development
146160

@@ -149,15 +163,21 @@ Required columns:
149163
```
150164
amRviz/
151165
├── R/
152-
│ └── launch_dashboard.R # Main launch function
166+
│ ├── app.R # Main Shiny app (ui + server)
167+
│ ├── utils.R # File loading and plot functions
168+
│ ├── globals.R # Global variable declarations
169+
│ ├── metadataUI.R # Metadata tab UI
170+
│ ├── modelPerfUI.R # Model performance tab UI
171+
│ ├── featureImportanceUI.R # Bug/Drug feature comparison tab UI
172+
│ ├── crossModelComparisonUI.R # Model holdouts tab UI
173+
│ ├── networkUI.R # Network tab UI
174+
│ └── queryDataUI.R # Query data tab UI
153175
├── inst/
154-
│ └── app/
155-
│ ├── app.R # Main Shiny app
156-
│ ├── utils.R # Utility functions
157-
│ ├── modules/ # UI modules
158-
│ ├── data/ # Dashboard data files
159-
│ └── www/ # Static assets (CSS, images)
160-
├── man/ # Documentation
176+
│ ├── app/www/ # Static assets (CSS, images)
177+
│ └── extdata/
178+
│ └── Shigella_flexneri/ # Demo data (amRml output)
179+
├── man/ # Documentation
180+
├── vignettes/ # Usage vignette and figures
161181
└── DESCRIPTION
162182
```
163183

@@ -176,19 +196,18 @@ https://github.com/JRaviLab/amR
176196

177197
This package is being prepared for Bioconductor submission. It includes:
178198

179-
- **biocViews**: GUI, MicrobialGenomics, Pathogen, Visualization
180-
- **Bioconductor dependencies**: ComplexHeatmap
181-
- **R version requirement**: R >= 4.1.0
182-
- **Documentation**: Comprehensive function documentation with examples
183-
- **Data**: Pre-computed AMR model results included in `inst/app/data/`
199+
- **biocViews**: AMR, GUI, MicrobialGenomics, Pathogen, Visualization
200+
- **R version requirement**: R >= 4.5.0
201+
- **Documentation**: Function documentation with examples, plus a usage vignette
202+
- **Data**: Pre-computed amRml results for *Shigella flexneri* included in `inst/extdata/`
184203

185204
## Contributing
186205

187206
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
188207

189-
### Reporting Issues
208+
### Reporting issues
190209

191-
Report bugs and request features at: https://github.com/JRaviLab/amRviz/issues
210+
Report bugs and request features at: <https://github.com/JRaviLab/amRviz/issues>
192211

193212
## Related projects
194213

@@ -206,6 +225,6 @@ BSD 3-Clause License. See [LICENSE](LICENSE) for details.
206225

207226
## Contact
208227

209-
**Corresponding author**: Janani Ravi (janani.ravi@cuanschutz.edu)
228+
**Corresponding author**: Janani Ravi (<janani.ravi@cuanschutz.edu>)
210229

211-
**JRaviLab**: https://jravilab.github.io
230+
**JRaviLab**: <https://jravilab.github.io>

0 commit comments

Comments
 (0)