Volcano and MA Plot Visualization for Omics Data

This notebook provides interactive visualization tools for displaying omics data in two common formats: Volcano plots and MA plots.

Data Loading and Processing

The PlotData class handles loading data from CSV files and mapping columns to standard names.


source

PlotData

 PlotData (file_path, column_mapping=None, log_fdr=False,
           highlight_ids=None)

Initialize the PlotData class for various omics experiments.

empty_data_dict
{'log2fc': None,
 'log10_fdr': None,
 'avg_intensity': None,
 'id': None,
 'description': None,
 'fdr': None,
 'highlight_indices': None}

Visualization Function

Now we’ll define the function to generate the side-by-side volcano and MA plots:


source

create_volcano_ma_plots

 create_volcano_ma_plots (plot_data, plot_title='Volcano and MA Plots',
                          width=600, height=800)

Create one-on-top-of-the-other volcano and MA plots using Plotly.

Example Usage

Let’s demonstrate how to use these functions with a real dataset:

column_mapping = {
    'log2fc': 'logFC',            # logFC column from your data
    'fdr': 'FDR',                # FDR column from your data
    'avg_intensity': 'log_AveExpr', # log_AveExpr column from your data
    'id': 'Gene_id',            # Gene_acc column from your data
    'description': 'Desc'         # Desc column from your data
}

file_path = '../tests/volcano_plots/for_web_limma_WT-C3.csv.zip'
# Create the PlotData instance
plot_data = PlotData(file_path, column_mapping, highlight_ids=['Blasticidin','Puromycin'])

# Print some information about the loaded data
print(f"Data loaded: {plot_data.data is not None}")
print(f"Number of rows: {len(plot_data.data) if plot_data.data is not None else 0}")
print(f"First few IDs: {plot_data.id[:5] if hasattr(plot_data, 'id') else 'Not loaded'}")
print(f"Highlight Indices: {plot_data.highlight_indices}")
# Quick access to all plotting data
plotting_data = plot_data.get_data_for_plotting()
Data loaded: True
Number of rows: 6205
First few IDs: ['Blasticidin' 'Puromycin' 'Tb05.5K5.100;Tb927.5.4450'
 'Tb05.5K5.110;Tb927.5.4460' 'Tb05.5K5.120;Tb927.5.4470']
Highlight Indices: [0, 1]
#!rm iframe_figures/*
fig = create_volcano_ma_plots(
    plot_data,
    plot_title="Differential Expression Analysis: Sample vs Control"
)
fig.show('iframe')