A comprehensive JBrowse 2 plugin that provides two complementary views for displaying feature-associated content:
- SelectImageGalleryView: Displays images within feature details with automatic loading and organization
- SelectTextualDescriptionsView: Renders markdown documents for genomic features with cytoscape diagram support
Both views appear automatically when selecting features with the appropriate data attributes.
If you're testing with the jbrowse plugin suite, this would be the right url to visit after you have
yarn start for jbrowse-web, npm run start and npm run browser for this plugin.
http://localhost:3000/?config=http%3A%2F%2Flocalhost%3A9000%2Fjbrowse_config.json
Please make sure you run jbrowse text-index --perTrack --force in the .jbrowse directory after you launch your dev environment.
Option 1: Go to https://github.com/alpapan/jbrowse-plugin-image-gallery/releases download the jbrowse-plugin-rich-annotations-plugin.umd.development.js Option 2: For developers
git clone https://github.com/alpapan/jbrowse-plugin-image-gallery.git
cd jbrowse-plugin-image-gallery
npm install
npm run setup
# this works on windows too:
npx cross-env NODE_ENV=production npm run build
ls -l dist/jbrowse-plugin-image-gallery.umd.production.min.js
# copy to your jb2 directoryAdd to your JBrowse 2 config.json:
{
"plugins": [
{
"name": "RichAnnotationsPlugin",
"url": "./dist/jbrowse-plugin-rich-annotations-plugin.umd.development.js"
}
]
}To develop against JBrowse Web:
- Start a development version of JBrowse Web (see here)
- In this project, run
yarn start(ornpm run start) - Assuming JBrowse Web is being served on port 3000, navigate in your web browser to http://localhost:3000/?config=http://localhost:9000/jbrowse_config.json
- When you make changes to your plugin, it will automatically be re-built. You can then refresh JBrowse Web to see the changes.
This plugin includes the following key dependencies for enhanced functionality:
@mui/material&@mui/icons-material: Material-UI components and iconsreact-markdown&remark-gfm: Markdown rendering with GitHub Flavored Markdownreact-syntax-highlighter: Syntax highlighting for code blockscytoscape: Interactive network visualization and diagramscytoscape-klay: Advanced graph layout algorithms for phylogenetic treesphylojs: Lightweight phylogenetic tree parsing and visualizationmobx&mobx-state-tree: State management
{
"plugins": [
{
"name": "RichAnnotationsPlugin",
"url": "/path/to/plugin.js"
}
],
"assemblies": [
{
"name": "hg38",
"sequence": {
"type": "ReferenceSequenceTrack",
"trackId": "hg38_sequence",
"adapter": {
"type": "BgzipFastaAdapter",
"fastaLocation": { "uri": "hg38.fa.gz" },
"faiLocation": { "uri": "hg38.fa.gz.fai" },
"gziLocation": { "uri": "hg38.fa.gz.gzi" }
}
}
}
],
"tracks": [
{
"type": "FeatureTrack",
"trackId": "genes_with_content",
"name": "Genes with Images and Docs",
"assemblyNames": ["hg38"],
"adapter": {
"type": "Gff3Adapter",
"gffLocation": { "uri": "genes_with_content.gff3" }
}
}
]
}imageorimages: comma-separated list of image URLs (use one or the other)
image_group: comma-separated labels for each image (used as container titles)image_tag: comma-separated types for each image (displayed as chips below images)
markdown_urlsormarkdown_url: comma-separated list of markdown document URLs
descriptionsordescription: comma-separated descriptions for each markdown documentcontent_typeorcontent_types: comma-separated content types (e.g., "tutorial", "analysis", "documentation")
##gff-version 3
##sequence-region chr1 1 248956422
# Single image (SelectImageGalleryView)
chr1 source gene 1000 2000 . + . ID=gene1;image=https://example.com/image.jpg
# Multiple images with labels and types (SelectImageGalleryView)
chr1 source gene 3000 4000 . + . ID=gene2;image=https://example.com/img1.jpg,https://example.com/img2.png;image_group=Microscopy,Western;image_tag=experimental,analysis
# Single markdown document (SelectTextualDescriptionsView)
chr1 source gene 5000 6000 . + . ID=gene3;markdown_urls=https://example.com/gene3_docs.md
# Multiple markdown documents with descriptions (SelectTextualDescriptionsView)
chr1 source gene 7000 8000 . + . ID=gene4;markdown_urls=https://example.com/tutorial.md,https://example.com/analysis.md;descriptions=Tutorial Guide,Functional Analysis;content_type=tutorial,analysis
# Combined: Both images and markdown for the same feature
chr1 source gene 9000 10000 . + . ID=gene5;image=https://example.com/structure.png;image_group=Structure;markdown_urls=https://example.com/gene5_details.md;descriptions=Detailed Analysis
# Real example with images
chr1 MyLab gene 1000 2000 . + . ID=LOC100130531;image=https://upload.wikimedia.org/wikipedia/commons/c/ce/Example_image.png;image_group=test_example2;image_tag=general
# Legacy format for images (still supported)
chr1 source gene 11000 12000 . + . ID=gene6;images=https://example.com/legacy.jpg
- Supported formats: JPG, PNG, GIF, SVG, BMP, WEBP, TIFF, ICO
- URLs must be accessible from the browser
- CORS headers required for cross-domain images
- Standard markdown format with GitHub Flavored Markdown (GFM) extensions
- URLs must be accessible from the browser
- CORS headers required for cross-domain documents
- Supports tables, code blocks, headings, lists, links, etc.
Select any feature with image or markdown data. The appropriate views appear automatically.
- Right-click in view area
- Select "Add" → "Select Image Gallery View" or "Add" → "Select Textual Descriptions View"
- Automatic image display on feature selection
- Lazy loading with intersection observer
- Images grouped by labels in collapsible containers
- Type chips displayed for non-"general" image types
- Fallback placeholder for failed image loads
- Click images to open in new tab
- Markdown Rendering: Full GitHub Flavored Markdown (GFM) support
- Syntax Highlighting: Code blocks with language-specific highlighting
- Tables: Responsive table rendering with proper styling
- Cytoscape Diagrams: Interactive network diagrams embedded in markdown
- Phylogenetic Trees: Interactive evolutionary tree visualization from Newick format
- Multi-document Support: Combines multiple markdown files with separators
- Error Handling: Clear error messages for failed content loading
- Responsive Design: Adapts to different screen sizes
- Headers:
# ## ### #### ##### ###### - Text Formatting: italic, bold,
strikethrough - Lists: Ordered and unordered lists with nesting
- Links:
[text](url)format - Images:
format (embedded within markdown) - Fully Supported - Images are automatically fetched and rendered when URLs are provided in markdown content - Code: Inline
codeand fenced code blocks with syntax highlighting - Tables: Pipe-delimited tables with alignment
- Blockquotes:
> quoted text - Horizontal Rules:
---or*** - Task Lists:
- [ ]and- [x]checkboxes
SelectTextualDescriptionsView supports interactive cytoscape diagrams embedded in markdown using fenced code blocks:
```cytoscape
{
"elements": [
{ "data": { "id": "gene1", "label": "Gene A"} },
{ "data": { "id": "gene2", "label": "Gene B" } },
{ "data": { "id": "protein1", "label": "Protein X" } },
{ "data": { "source": "gene1", "target": "protein1", "id": "edge1" } },
{ "data": { "source": "gene2", "target": "protein1", "id": "edge2" } }
],
"style": [
{
"selector": "node[label*='Gene']",
"style": { "background-color": "#e74c3c", "shape": "ellipse" }
},
{
"selector": "node[label*='protein']",
"style": { "background-color": "#2ecc71", "shape": "rectangle" }
}
]
}Cytoscape diagrams use JSON format with two main sections:
Elements Array: Defines nodes and edges.
- Nodes:
{ "data": { "id": "unique_id", "label": "Display Name" } } - Edges:
{ "data": { "source": "node1_id", "target": "node2_id", "id": "edge_id" } }
Style Array (optional): Defines visual styling
- Selectors: CSS-like selectors to target elements
- Style Objects: Properties like
background-color,shape,width, etc.
# Gene Pathway Analysis
This pathway shows the relationship between genes and their protein products:
```cytoscape
{
{
"elements": [
{ "data": { "id": "brca1", "label": "BRCA1" } },
{ "data": { "id": "brca2", "label": "BRCA2" } },
{ "data": { "id": "p53", "label": "P53" } },
{ "data": { "id": "dna_repair", "label": "DNA Repair Complex" } },
{ "data": { "source": "brca1", "target": "dna_repair", "id": "edge1" } },
{ "data": { "source": "brca2", "target": "dna_repair", "id": "edge2" } },
{ "data": { "source": "p53", "target": "dna_repair", "id": "edge3" } }
],
"style": [
{
"selector": "node",
"style": {
"background-color": "#3498db",
"label": "data(label)",
"text-valign": "center",
"color": "#2c3e50",
"shape": "roundrectangle",
"width": "80px",
"height": "40px"
}
},
{
"selector": "node[label='DNA Repair Complex']",
"style": { "background-color": "#e74c3c", "shape": "ellipse", "width": "120px" }
},
{
"selector": "edge",
"style": { "width": 3, "line-color": "#7f8c8d", "target-arrow-color": "#7f8c8d", "target-arrow-shape": "triangle" }
}
]
}SelectTextualDescriptionsView supports interactive phylogenetic tree visualization from Newick format embedded in markdown using fenced code blocks:
```newick
((Human:0.1,Chimp:0.2):0.3,(Mouse:0.4,Rat:0.5):0.6); [DR1 Gene Evolution - Phylogenetic relationships across species]
```
#### Newick Format Specifications
**Basic Newick Syntax**:
- Parentheses define internal nodes and groupings
- Commas separate sibling nodes
- Semicolon terminates the tree
- Colons precede branch lengths (optional)
- Node labels can be included
**Examples of Valid Newick Formats**:
```
Simple tree: (A,B,C);\n
With branch lengths: (A:0.1,B:0.2,C:0.3);
Nested groups: ((A:0.1,B:0.2):0.5,(C:0.3,D:0.4):0.6);
With internal labels: ((A,B)AB,(C,D)CD)Root;
```
#### Metadata Comments
You can add titles and descriptions using square bracket comments at the end of your Newick string:
**Format Options**:
- `[Title Only]` - Displays just a title
- `[Title - Description]` - Displays title and description separately
**Examples**:
````markdown
```newick
((Human:0.1,Chimp:0.2):0.3,(Mouse:0.4,Rat:0.5):0.6); [Mammalian Evolution]
```
````markdown
```newick
(((A:0.1,B:0.2):0.3,C:0.4):0.5,D:0.6); [Gene Family Tree - Evolutionary relationships of orthologous genes]
```
#### Tree Visualization Features
**Layout and Styling**:
- **Direction**: Left-to-right horizontal layout for easy reading
- **Edge Routing**: Orthogonal (right-angled) connections for clarity
- **Color Scheme**:
- Species/leaf nodes: Pastel blue (`#A8DADC`)
- Internal nodes: Pastel pink (`#F8D7DA`)
- Edges: Gray (`#7F8C8D`)
- **Interactive**: Zoom and pan enabled for large trees
- **Responsive**: Adapts to container size
**Node Display**:
- Leaf nodes show species/sequence names
- Internal nodes appear as small circles
- Branch lengths reflected in layout when provided
- Automatic label wrapping for long names
#### Complete Phylogenetic Tree Example
````markdown
# Evolutionary Analysis
The evolutionary relationships of key model organisms:
```newick
(((Human:0.033,Chimp:0.033):0.014,(Gorilla:0.017,Orangutan:0.022):0.030):0.040,((Mouse:0.084,Rat:0.091):0.271,Rabbit:0.206):0.024); [Model Organisms Phylogeny - Evolutionary distances based on molecular clock analysis]
```
This tree demonstrates:
- **Primate clade**: Close relationship between great apes
- **Rodent clade**: Mouse and rat clustering
- **Branch lengths**: Proportional to evolutionary time
- **Outgroup**: Rabbit as more distant mammalian relative
Complex Trees with Multiple Levels:
```newick
((((A1:0.1,A2:0.15)A:0.2,(B1:0.12,B2:0.08)B:0.25)AB:0.3,((C1:0.09,C2:0.11)C:0.18,(D1:0.13,D2:0.07)D:0.22)CD:0.35)ABCD:0.4,E:0.8); [Complex Gene Family - Multi-level phylogenetic analysis with named internal nodes]
```
Tips for Creating Newick Trees:
- Validate format: Use online Newick validators before embedding
- Branch lengths: Include if available for accurate proportions
- Node names: Keep species names concise for better display
- Metadata: Use descriptive titles and explanations
- Testing: Preview trees before deployment to check layout
| Option | Default | Description |
|---|---|---|
maxImages |
50 | Maximum images to display |
maxImageHeight |
200 | Maximum image height (px) |
maxImageWidth |
300 | Maximum image width (px) |
enableLazyLoading |
true | Use intersection observer |
validateUrls |
true | Validate image URL formats |
| Option | Default | Description |
|---|---|---|
enableGfm |
true | GitHub Flavored Markdown |
enableCytoscape |
true | Cytoscape diagram support |
maxDocumentSize |
1MB | Maximum document size to load |
enableSyntaxHighlighting |
true | Code block syntax highlighting |
- State Model (
SelectImageGalleryView/stateModel.ts): MobX state tree withupdateFeature()andclearFeature()actions - React Component (
SelectImageGalleryView/SelectImageGalleryView.tsx): Material-UI components with lazy loading - Plugin Registration (
index.ts): ViewType registration and autorun session monitoring
- State Model (
SelectTextualDescriptionsView/stateModel.ts): MobX state tree with feature and content management - React Component (
SelectTextualDescriptionsView/components/TextualDescriptionsView.tsx): Markdown rendering with cytoscape integration - Plugin Registration (
index.ts: ViewType registration and automatic view management
- Feature selection triggers autorun in
index.ts - Image data extracted from feature attributes (
images,image_group,image_tag) - Arrays converted to comma-separated strings for state model compatibility
- View updates via
updateFeature()action - React component parses strings back to arrays for display
- Images grouped by labels, types displayed as chips
- Feature selection triggers autorun in
index.ts - Markdown data extracted from feature attributes (
markdown_urls,descriptions,content_type) - State model stores comma-separated URL strings
- React component fetches markdown content from URLs
- ReactMarkdown renders content with custom components
- Cytoscape diagrams rendered interactively when encountered
parseImages(): Handles both prop and feature attribute sourcesgroupImagesByLabel(): Creates collapsible containers per labelLazyImage: Intersection observer-based loading component
fetchContent(): Async loading of markdown documentsCytoscapeDirectRender: Interactive cytoscape diagram rendererMarkdownComponents: Custom renderers for tables, code blocks, and diagrams
The image_tag attribute provides type labels for images:
- No predefined values: Any text can be used as image types
- Values are comma-separated strings matching image order
- Types appear as small rounded labels (Material-UI "chips") below each image filename
- Default type is "general" (no chip displayed)
- Chips are small gray rounded labels - look below the image filenames for small tags
- Common examples: "experimental", "analysis", "structure", "diagram", "microscopy", "western", "gel", "chart"
- Custom types: Users can specify any descriptive text (e.g., "before_treatment", "patient_sample", "control_group")
[Image]
filename.jpg
[experimental] ← This gray rounded tag is a "chip"
- Verify
imageorimagesattribute exists in GFF features - Check image URLs are accessible
- Ensure CORS headers for cross-domain images
- Check browser console for errors
- Verify
markdown_urlsormarkdown_urlattribute exists in GFF features - Check markdown document URLs are accessible
- Ensure CORS headers for cross-domain documents
- Check browser console for network errors
- Verify markdown syntax is valid
- Verify image URLs in markdown use correct
syntax - Check image URLs are accessible from the browser
- Ensure CORS headers for cross-domain images
- Check browser console for image loading errors
- Verify image formats are supported (JPG, PNG, GIF, SVG, WEBP, etc.)
- Ensure JSON format is valid in cytoscape code blocks
- Check browser console for cytoscape-specific errors
- Verify all node IDs are unique
- Ensure edge source/target IDs match existing nodes
- Ensure Newick format is valid in
newickcode blocks - Check browser console for phylo.js-specific errors
- Verify tree structure is well-formed (balanced parentheses)
- Ensure semicolon terminates the tree string
- Check for invalid characters in species names
- Reduce
maxImagesvalue for SelectImageGalleryView - Enable
enableLazyLoading(default: true) for images - Optimize image and document sizes
- Limit number of markdown documents per feature
- Use simpler cytoscape diagrams for better performance
npm install
npm start # Development server
npm run lint # ESLint
npm run build # Production buildMIT License
Alexie Papanicolaou - [email protected].
