From ae1bbcff37168b27aa4146e83687616d54e869d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shixiang=20Wang=20=28=E7=8E=8B=E8=AF=97=E7=BF=94=29?= Date: Sun, 11 Oct 2026 20:46:14 +0800 Subject: [PATCH] perf: downsample iVolcano tutorial data and link Hiplot full version The iVolcano tutorial rendered 8 interactive widgets that each embedded the full example datasets (13,346 limma genes / 20,606 airway genes) as inline SVG, making the page ~46 MB in each language (~92 MB total on the deployed site) - the largest single page in the site. Changes (issue #306 A3.3): - Downsample df_limma in the load-data chunk: keep all significant genes (P.Value < 0.05 & |logFC| > 1, n = 1,950) plus a seed-fixed sample of 2,000 non-significant genes - Downsample df_airway in the pathway-linkage chunk: keep all genes with padj < 0.05, so GO enrichment and plot linkage are unaffected - Add callout notes (en/zh) linking the full-featured Hiplot Volcano app for users who need the complete no-code version Measured locally: page drops 48.2 MB -> 14.8 MB (-69%); deployed en+zh saving ~62 MB. All significant genes, all logFC > 8 extremes, top-50 labeling, and enrichment-linkage behavior verified intact with set.seed(1). Co-Authored-By: Claude Code --- Omics/iVolcanoPlot.qmd | 21 +++++++++++++++++++++ Omics/iVolcanoPlot.zh.qmd | 19 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Omics/iVolcanoPlot.qmd b/Omics/iVolcanoPlot.qmd index 0b9b47909..cef46b1ad 100644 --- a/Omics/iVolcanoPlot.qmd +++ b/Omics/iVolcanoPlot.qmd @@ -7,6 +7,12 @@ author: The interactive volcano plot is a visualization tool for differential expression analysis of high-throughput data (e.g., transcriptomics, proteomics). Building upon the traditional volcano plot, it supports mouse hover to view gene information, click to jump to external databases, and provides more flexible threshold settings and color schemes, helping researchers screen and interpret differential analysis results more efficiently. +::: callout-note +**Full-featured version on Hiplot** + +To keep this page lightweight, the interactive plots below are rendered from a downsampled subset of the example data (all significant genes plus a random sample of non-significant genes). For the complete, no-code interactive application, please use the Volcano plugin on the Hiplot website: +::: + ## Example ![](../images/Omics/iVolcanoPlot_demo.png){fig-alt="iVolcanoPlot DEMO" fig-align="center" width="60%"} @@ -61,6 +67,14 @@ We use the built-in `easy_input_limma.rds` dataset from the `ivolcano` package, # Load data f1 <- system.file("extdata/easy_input_limma.rds", package = "ivolcano") df_limma <- readRDS(f1) + +# Downsample to keep the tutorial page lightweight: retain all significant +# genes (P.Value < 0.05 & |logFC| > 1) plus a fixed random sample of 2,000 +# non-significant genes. Use the full dataset in your own analysis. +set.seed(1) +is_sig <- df_limma$P.Value < 0.05 & abs(df_limma$logFC) > 1 +df_limma <- df_limma[sort(c(which(is_sig), sample(which(!is_sig), 2000))), ] + # View dataset head(df_limma) ``` @@ -277,6 +291,13 @@ The `pathway_volcano` function can display an enrichment analysis dot plot along # Prepare airway differential analysis data and perform GO enrichment analysis f2 <- system.file("extdata/airway.rds", package = "ivolcano") df_airway <- readRDS(f2) + +# Downsample as above: all genes significant at padj < 0.05 are retained, so +# the enrichment analysis and plot linkage are unaffected. +set.seed(1) +is_sig_airway <- !is.na(df_airway$padj) & df_airway$padj < 0.05 +df_airway <- df_airway[sort(c(which(is_sig_airway), + sample(which(!is_sig_airway), 2000))), ] sig_genes <- df_airway$symbol[df_airway$padj < 0.01 & abs(df_airway$log2FoldChange) > 2] sig_genes <- sig_genes[!is.na(sig_genes)] entrez <- na.omit(mapIds(org.Hs.eg.db, sig_genes, "ENTREZID", "SYMBOL", multiVals = "first")) diff --git a/Omics/iVolcanoPlot.zh.qmd b/Omics/iVolcanoPlot.zh.qmd index 0dd54bad3..7856c2856 100644 --- a/Omics/iVolcanoPlot.zh.qmd +++ b/Omics/iVolcanoPlot.zh.qmd @@ -7,6 +7,12 @@ author: 交互式火山图(Interactive Volcano Plot)是一种用于高通量数据(如转录组、蛋白组)差异表达分析的可视化图形。它在传统火山图的基础上,支持鼠标悬停查看基因信息、点击跳转外部数据库,并提供更灵活的阈值设定与配色方案,帮助研究者更高效地筛选和解读差异分析结果。 +::: callout-note +**Hiplot 完整版应用** + +为控制页面体积,本教程中的交互式图形基于降采样后的示例数据绘制(保留全部显著基因,并随机抽取部分非显著基因)。如需完整功能的无代码版本,请使用 Hiplot 网站的 Volcano 插件: +::: + ## 示例 ![](../images/Omics/iVolcanoPlot_demo.png){fig-alt="iVolcanoPlot DEMO" fig-align="center" width="60%"} @@ -61,6 +67,13 @@ sessioninfo::session_info("attached") # 读取数据 f1 <- system.file("extdata/easy_input_limma.rds", package = "ivolcano") df_limma <- readRDS(f1) + +# 降采样以控制页面体积:保留全部显著基因(P.Value < 0.05 且 |logFC| > 1), +# 并固定随机种子抽取 2,000 个非显著基因。实际分析请使用完整数据集。 +set.seed(1) +is_sig <- df_limma$P.Value < 0.05 & abs(df_limma$logFC) > 1 +df_limma <- df_limma[sort(c(which(is_sig), sample(which(!is_sig), 2000))), ] + # 查看数据集 head(df_limma) ``` @@ -277,6 +290,12 @@ p # 准备 airway 差异分析数据并做 GO 富集分析 f2 <- system.file("extdata/airway.rds", package = "ivolcano") df_airway <- readRDS(f2) + +# 同样进行降采样:padj < 0.05 的基因全部保留,因此富集分析与图形联动不受影响。 +set.seed(1) +is_sig_airway <- !is.na(df_airway$padj) & df_airway$padj < 0.05 +df_airway <- df_airway[sort(c(which(is_sig_airway), + sample(which(!is_sig_airway), 2000))), ] sig_genes <- df_airway$symbol[df_airway$padj < 0.01 & abs(df_airway$log2FoldChange) > 2] sig_genes <- sig_genes[!is.na(sig_genes)] entrez <- na.omit(mapIds(org.Hs.eg.db, sig_genes, "ENTREZID", "SYMBOL", multiVals = "first"))