Tools for downloading, annotating, and exploring fluorescence microscopy images from the Human Protein Atlas (HPA) Subcellular section to investigate and demonstrate channel separation artifacts in RGB composite images.
This repository provides tools to systematically download images from the Human Protein Atlas and alert about that using RGB multi-color jpgs instead of single-channel jpgs will lead to encountering a technical artefact from the multi-color combination that can be perceived as spectral bleed-through while it is in fact just a computational artefact and there is no true bleed-through in HPA images.
JPG is a lossy image compression. The artefact arises specifically when individual channels are extracted from RGB composite JPGs provided by HPA for visualization purposes.
The artifact is completely absent when using the single-channel JPG or TIFF files that HPA provides alongside the composites. This repository documents the mechanism, quantifies the artifact, and provides a full reproducible workflow for the community. This repository also emphasizes that for any analysis, single-channel and not multi-channel JPG files should be used.
Spectral bleed-through is a genuine concern in fluorescence microscopy. It occurs when excitation and/or emission spectra of different fluorophores overlap, causing signal from one channel to contaminate another during image acquisition. This is a well-recognized problem and must be controlled for in any quantitative co-localization study applying fluorescence microscopy.
This is controlled by optimizing the image acquisition while considering excitation wavelength, excitation spectra, emission wavelength, emission spectra and emission-band settings.
The Human Protein Atlas immunofluorescence data is acquired in three sequentially applied channel acquisitions with separate excitation and emission-band settings, which eliminate true optical bleed-through at the point of acquisition (see Figure 1 below):
-
Sequential 1 recordes the protein of interest (Fluorophore Alexa 488,
greenimage on atlas) -
Sequential 2 records the nucleus (DAPI,
blueimage on atlas) and the ER (Fluorophore Alexa Fluor 647,yellowimage on atlas) -
Sequential 3 records the microtubule channel (Fluorophore Alexa 555,
redimage on atlas)
Figure 1
Sequential 1:
Click to explore this setting on fpbase.org
Sequential 2:
Click to explore this setting on fpbase.org
Sequential 3:
Click to explore this setting on fpbase.org
Figure 1: Sequential acquisition of Human Protein Atlas subcellular section images with confocal immunofluorescence microscopy. Top: At first the protein of interest (labeled by an Alexa Fluor 488-coupled anti-rabbit antibody) is acquired with a precise excitation at 488 nm (limiting excitation of any other present fluorophores) and a narrow emission band-pass filtering excluding signal from weak Alexa Fluor 555 excitation with the 488 nm laser. Middle: The second sequential acquisition records DAPI and Alexa Fluor 647 (labeling the Endoplasmic reticulum marker) with precise laser-excitation at 405 and 633 nm and tailored band-pass filters to avoid detection of the other fluorophores. Bottom: The third sequential acquisition records the microtubule channel, where microtubules are visualized through immunofluorescence staining involving a secondary antibody conjugated with Alexa Fluor 555. Precise excitation at 543 nm is applied, and an emission band that restricts detection of the emission signal to the emission of Alexa Fluor 555. Plots were generated with FPbase.org (Reference: Lambert, TJ (2019) FPbase: a community-editable fluorescent protein database. Nature Methods. 16, 277–278. doi: 10.1038/s41592-019-0352-8).
However, a separate and distinct phenomenon can arise computationally when individual channels are extracted from pre-rendered and compressed color composite images instead of single-channel images. This computational artifact can closely resemble true optical bleed-through in its appearance but has a completely different cause. Particularly, when using lossy image compression formats like jpeg.
Apparent bleed-through observed in computational analyses of HPA data originates from the image processing pipeline, specifically from the use of RGB composite files (explained below, and Figure 2).
The Human Protein Atlas provides immunofluorescence images in three distinct formats for each staining:
| Format | File | Bit depth | Channel status |
|---|---|---|---|
| RGB composite JPG | blue_red_green.jpg |
8-bit per channel | Channels merged and lossy-compressed; inter-channel correlations introduced; for simultaneous multi-channel display only |
| Single-channel JPG | blue.jpg, red.jpg, green.jpg, yellow.jpg |
8-bit | Individual channels exported separately; no inter-channel correlations; for single-channel display and suitable for data analysis |
| Single-channel TIFF | blue.tif, red.tif, green.tif, yellow.tif |
16-bit | Raw microscopy data; no inter-channel correlations; best option for data analysis |
The RGB composite JPG (blue_red_green.jpg) is intended as a visualization aid only and displayed on the online version of the HPA. Producing it requires mapping each channel to a color lookup table (LUT), merging the result into a three-channel RGB color space, and applying JPEG compression. This processing introduces correlations between the stored red, green, and blue pixel values that do not reflect any true bleed-through in the original image data.
When a researcher computationally extracts the red, green, or blue component from this composite file and treats it as a single-channel fluorescence measurement, the extracted values contain contributions from all original channels. This creates the appearance of bleed-through where none exists in the raw data.
The single-channel JPGs and TIFFs are not affected by this issue. JPEG compression of an individual channel image introduces quantization noise within that channel but cannot introduce correlations with other channels, because the other channels are stored in separate files.
The 16-bit TIFFs are uncompressed raw data and are the gold standard for quantitative analysis.
Machine learning models trained on fluorescence microscopy images of the HPA are increasingly used for protein localization prediction, phenotype classification, and image-to-image translation tasks. If training data is derived from RGB composite JPGs through channel extraction, the model will be exposed to these artificial inter-channel correlations (or data leakage) during training. As a result:
- Models may learn spurious cross-channel features that do not reflect biological reality
- Predictions may appear to depend on signals from channels that should be independent
- Generalization to new data acquired under different conditions will be compromised
- Apparent model failures may be misattributed to biological complexity rather than to data preprocessing errors
The solution is straightforward: use single-channel source files for all quantitative analyses. Both the single-channel JPGs and TIFFs are freely available from HPA alongside the composite images and require no additional processing to use correctly.
Analysis of matched image sets (comparing channels extracted from RGB composite JPGs against the corresponding single-channel JPGs and TIFFs for the same fields of view, Figure 2) confirms the following:
- Single-channel TIFFs and single-channel JPGs show clean channel separation with no inter-channel signal.
- Channels extracted from RGB composite JPGs show substantial artificial cross-contamination that closely mimics the appearance of spectral bleed-through.
Figure 2 is based on the comparison matrix figures generated by this toolkit (see Step 4 scripts of the workflow below, generating different example output figures for visualization). The figures show the artifact across multiple proteins and organelle categories, confirming it is systematic and not specific to any individual image or protein.
Figure 2:
Figure 2: Example Comparison of Single-Channel Images and Composite-Derived Channel Images. Single-Channel Tif and Single-Channel JPG images do not show any bleed-through between channels. By contrast Blue, Red, and Green channels extracted from the RGB JPG files show bleed-through between channels, as apparent in the horizontal line plots and the residual maps. The residual maps show the subtracted image of the single-channel JPG images from the channel images extracted from the composite JPG files, revealing the artificial bleedthrough introduced through extracting channels from the RGB composite image.
-
1_HPA_Image_Download_BatchDownload.py- Batch download images for multiple proteins from a list
- Reads from
Organelle_Example_GenesAndCellLines.txtprovided in this repository as example images - Downloads JPGs and TIFFs for all channels
- Creates nested folder structures (Gene/Antibody/CellLine)
-
1_HPA_Image_Download_SingleProtein.py- Interactive download for a single protein
- User provides HPA URL and cell line
- Useful for testing or downloading individual examples
-
2_Square_Selector.py- Interactive ROI (Region of Interest) annotation tool
- Select 640×640px regions in downloaded images
- Supports two modes:
- Complement: Only annotate images without existing ROIs
- Re-annotate: Allow re-selection of all images
- Outputs:
ROI.txtwith coordinates and metadata, example file available in this repository.
-
3_Best_Example_Selector.py- Select representative example images for each gene
- Visual grid interface showing all images with ROI overlays
- Supports complement/re-select modes
- Outputs:
ROI_examples.txtwith selection result and metadata already contained in ROI.txt, example file available in this repository.- Note: We manually created a
ROI_examples_Selected.txtwith just 6 selected subcellular structures / proteins for creating a smaller overview figure. The file is also shared in this repository.
- Note: We manually created a
-
4_Matrix_Figure_Generator.py,5_Matrix_Figure_Generator_2.py,6_Matrix_Figure_Generator_3.py, or7_Matrix_Figure_Generator_4.py- Generate different kinds of comparison matrix figures
- Creates side-by-side visualization of:
- TIFFs (not showing bleed-through)
- Single-channel JPGs (not showing bleed-through)
- RGB composite JPG
- Channels extracted from RGB composite JPG (showing bleed-through)
- Line profile plots
- Residual images
- Outputs: PDF, PNG, and SVG figure files
Organelle_Example_GenesAndCellLines.txt- List of proteins and cell lines for each organelleROI.txt- ROI coordinates for all annotated images (example output from 2)ROI_examples.txt- Selected example images with annotation metadata (example output from 3)
- Python 3.8 or higher
- tkinter (usually included with Python, on Linux:
sudo apt-get install python3-tk)
# Clone the repository
git clone https://github.com/cellprofiling/HPA_BleedThrough_Exploration
cd HPA_BleedThrough_Exploration
# Install dependencies
pip install -r requirements.txt
python 1_HPA_Image_Download_BatchDownload.py
This uses Organelle_Example_GenesAndCellLines.txt to download all example images.
python 1_HPA_Image_Download_SingleProtein.py
Enter URL (e.g., https://www.proteinatlas.org/ENSG00000117519-CNN3/subcellular) and cell line (e.g., U2OS).
python 2_Square_Selector.py
Interactive mode selection:
- Mode 1: Complement only - Annotate only images without ROIs
- Mode 2: Re-annotate all - Allow re-annotation of existing ROIs
Controls:
- Click and drag the red square to position the 640×640px ROI
- Click outside the square to move it to that location
- Save: Accept ROI and continue
- Save & Skip: Mark image for exclusion from analysis
- Cancel: Skip this image without saving
Output: ROI.txt containing all ROI coordinates.
python 3_Best_Example_Selector.py
Mode selection:
- Mode 1: Complement only - Select examples only for genes without selections
- Mode 2: Re-select all - Allow changing example selections For each gene, a grid displays all available images. Select ONE representative example image.
Output: ROI_examples.txt with Example column (T/F).
Multiple visualization scripts create side-by-side image comparisons demonstrating the RGB composite artifact. Each script uses different display methods (colormaps, intensity adjustments, profile plots, residuals) to highlight how extracting channels from RGB composite JPGs introduces artificial cross-contamination, while single-channel files maintain proper channel independence.
Input data: All scripts use ROI_examples.txt (all 34 example proteins/structures) or ROI_examples_Selected.txt (6 selected proteins/structures, manually created by selecting lines from the ROI_examples.txt).
Final figure: Script 7_Matrix_Figure_Generator_4.py was selected.
All scripts create somewhat different figure arrangements. The final picked figure was based on script 7_Matrix_Figure_Generator_4.py.
python 4_Matrix_Figure_Generator.py
Creates the most comprehensive comparison matrix showing (left to right):
-
Single-channel JPGs - Full range,
<>_blue.jpg,<>_red.jpg,<>_green.jpg,<>_yellow.jpg -
Information - Gene, antibody, cell line, annotation
-
4-channel composite -
<>_blue_red_green_yellow.jpg -
Unadjusted TIFFs - Full dynamic range,
<>_blue.tif,<>_red.tif,<>_green.tif,<>_yellow.tif -
Adjusted TIFFs - Specified intensity range (0-25700, corresponding to 0-100 of an 8-bit range) for better visualization of low intensity range
-
Adjusted single-channel JPGs - Intensity adjusted (0-100) for better visualization of low intensity range,
<>_blue.jpg,<>_red.jpg,<>_green.jpg,<>_yellow.jpg -
RGB composite -
blue_red_green.jpgmerged visualization -
Channels from RGB composite - Extracted and adjusted (0-100) showing bleed-through artifacts, especially in low intensity range
-
Intensity profiles - Both horizontal and vertical line plots through image centers:
- RGB composite extracted channels (showing correlated intensities)
- Single-channel JPGs (showing independent channels)
- Profile line locations are overlaid on images (dashed white crosshairs)
- Linear intensity scale (0-100)
Outputs: HPA_comparison_matrix.pdf/.svg/.png
python 5_Matrix_Figure_Generator_2.py
Provides a streamlined comparison focusing on the images without intensity range adjustment:
- Information - Gene, antibody, cell line, annotation
- Raw TIFFs - Full range,
<>_blue.tif,<>_red.tif,<>_green.tifonly - RGB composite JPG - Merged visualization
<>_blue_red_green.jpg - Channels from RGB composite JPG -> Extracted channels showing artifact
- Single-channel JPGs - Full range,
<>_blue.jpg,<>_red.jpg,<>_green.jpgonly -> Clean channel separation - Color scales to interpret intensity is defined on bottom
Outputs: HPA_comparison_matrix_2.pdf/.svg/.png
python 6_Matrix_Figure_Generator_3.py
Provides a version of the 4_Matrix_Figure_Generator.py without intensity adjustment:
- Information - Gene, antibody, cell line, annotation
- 4-channel composite -
<>_blue_red_green_yellow.jpg - Raw TIFFs - Full range,
<>_blue.tif,<>_red.tif,<>_green.tif,<>_yellow.tif - Single-channel JPGs - Full range,
<>_blue.jpg,<>_red.jpg,<>_green.jpg,<>_yellow.jpg - RGB composite JPG (
<>_blue_red_green.jpg) and extracted channels - Demonstrating the artifact - Intensity line profiles - Both horizontal and vertical line plots through image centers, showing:
- Profile line locations overlaid on images (dashed white lines)
- Single-channel JPGs (showing spatial independence)
- Linear intensity scale for direct comparison
- Color scale to interpret intensity defined on bottom
Outputs: HPA_comparison_matrix_3.pdf/.svg/.png
7_Matrix_Figure_Generator_4.py (Simplified version with full intensity range images and horizontal line profiles)
python 7_Matrix_Figure_Generator_4.py
Provides an alternative visualization emphasizing:
- Information - Gene, antibody, cell line, annotation
- 4-channel composite -
<>_blue_red_green_yellow.jpg - Raw TIFFs - Full intensity range,
<>_blue.tif,<>_red.tif,<>_green.tif,<>_yellow.tif - Single-channel JPGs - Full intensity range,
<>_blue.jpg,<>_red.jpg,<>_green.jpg,<>_yellow.jpg - RGB composite JPG (
<>_blue_red_green.jpg) and extracted channels - Demonstrating the artifact - Residual images - Pixel-by-pixel difference (Extracte from RGB Composite JPG − single-channel JPG)
- Intensity profiles - Horizontal line plots through image centers on log2 scale for single-channel JPGs and RGB composite JPG
- Referring profile line locations overlaid on images before (dashed white lines)
- Color scales to interpret intensity and residuals are defined on bottom
Outputs: HPA_comparison_matrix_4.pdf/.svg/.png
| Script | Intensity Adjustment | Profiles | Residuals | Best For |
|---|---|---|---|---|
| 4 | Multiple (raw + adjusted) | Horizontal + Vertical (linear) | No | Comprehensive comparison with profiles |
| 5 | Raw only | None | No | Simple figure focusing on visual comparison |
| 6 | Raw only | Horizontal + Vertical (linear) | No | Extended comparison with profiles |
| 7 | Raw only | Horizontal only (log2) | Yes | Balanced comparison with profiles |
All scripts save individual cropped images to the same Crops/ folder.
- The
Crops/folder contains the individual PNG images displayed in the matrix (if needed) - Files are named with gene, antibody, cell line, and processing method
- Running different scripts may overwrite files with the same names
- To preserve crops from multiple scripts, rename or move the
Crops/folder before running another script
Example file naming pattern: GENE_ANTIBODY_CELLLINE_PREFIX_processingmethod.png