首页 / 资讯中心 / 文章详情

高分Panel复现系列|看看这篇Cell,四类空间生态型的通路富集,怎样排成一张图

高分Panel复现系列|看看这篇Cell,四类空间生态型的通路富集,怎样排成一张图 ★ FEATURED ARTICLE
这张图的重点不只是四种颜色而是把不同空间生态型的通路富集方向、轨迹和显著性压缩到同一个坐标体系里。用 R 手动控制面板位置、轨迹透明度和标签锚点就能做出接近 Cell 论文风格的复合散点图。图片来源项目内容文章Cellular architecture and neighborhood-informed virtual spatial tumor profiling from histopathology期刊/年份Cell2026图号Figure 4iDOI/链接10.1016/j.cell.2026.05.031原文 Figure 4i 用通路富集结果解释四类空间生态型C-I 至 C-IV的分子特征。论文正文指出C-I 偏向先天炎症与 Toll-like receptor signalingC-II 呈现纤维化和间质重编程C-III 更接近细胞周期和增殖程序C-IV 则富集 IFN-γ、细胞因子和淋巴细胞相关程序。下面的代码保留这种视觉结构真实分析时把示例输入表替换成自己的通路结果即可。图片解读这是一张四象限空间生态型通路富集散点图。每个象限对应一个空间生态型顶部的色带承担分组识别功能象限内部的浅色轨迹用于提示同一生态型下通路信号的整体方向深色圆点则突出需要重点阅读的代表性通路。横轴-log10(FDR)越靠右代表统计证据越强纵轴Pathway enrichment score用于表达通路富集方向或强度点颜色对应 C-I、C-II、C-III、C-IV 四个空间生态型点大小示例代码中映射到size字段真实数据可替换成通路显著性、富集强度或命中比例浅色轨迹不是额外的统计量而是用于还原原图中柔和的通路分布背景标签连线把较长的通路名称从点位引出避免直接压在点上。输入数据本项目使用三张输入表。文件关键字段panel_layout.csvecotype,panel,x0,y0,width,heightpathway_points.csvecotype,label,x,y,size,label_x,label_ybackground_trails.csvecotype,trail,t,x,ylibrary(tidyverse)layout_df-read_csv(data/panel_layout.csv,show_col_typesFALSE)pathway_df-read_csv(data/pathway_points.csv,show_col_typesFALSE)trail_df-read_csv(data/background_trails.csv,show_col_typesFALSE)需要示例数据的后台添加小编领取调整好数据结构以下代码可以直接复制粘贴运行。第一步固定四个象限的位置和配色ecotype_colors-c(C-I#d7ae2b,C-II#b85b5b,C-III#5b83b5,C-IV#93b15a)to_global-function(dat){dat%%left_join(layout_df,byc(ecotype,panel))%%mutate(gxx0x*width,gyy0y*height,glxx0label_x*width,glyy0label_y*height)}第二步转换轨迹和标签坐标trail_global-trail_df%%left_join(layout_df,byecotype)%%mutate(gxx0x*width,gyy0y*height)pathway_global-pathway_df%%to_global()label_segments-pathway_global%%transmute(ecotype,xgx,ygy,xendglx,yendgly)第三步绘制背景轨迹、代表点和标签figure-ggplot()geom_rect(datalayout_df,aes(xminx0,xmaxx0width,yminy0,ymaxy0height),fillwhite,colour#d6d6d6,linewidth0.35)geom_rect(datalayout_df,aes(xminx0,xmaxx0width,yminy0height0.14,ymaxy0height0.46,fillecotype),colourNA)geom_text(datalayout_df,aes(xx0width/2,yy0height0.30,labelpanel),size3.1,fontfacebold,colour#2b2b2b)geom_path(datatrail_global,aes(xgx,ygy,grouptrail,colourecotype),linewidth1.35,alpha0.12,lineendround)geom_point(datatrail_global%%slice(seq(1,n(),by3)),aes(xgx,ygy,colourecotype),size0.55,alpha0.08)geom_segment(datalabel_segments,aes(xx,yy,xendxend,yendyend,colourecotype),linewidth0.28,alpha0.68)geom_point(datapathway_global,aes(xgx,ygy,sizesize,fillecotype),shape21,colourwhite,stroke0.55,alpha0.93)geom_text(datapathway_global,aes(xglx,ygly,labellabel,hjusthjust),size2.15,lineheight0.85,colour#363636)第四步统一主题并导出figure-figurescale_fill_manual(valuesecotype_colors,guidenone)scale_colour_manual(valuesecotype_colors,guidenone)scale_size_continuous(rangec(2.0,4.9),guidenone)scale_x_continuous(limitsc(0.25,21.0),breaksc(1.3,5.65,10.0,11.4,15.75,20.1),labelsc(0,5,10,0,5,10),expandc(0,0))scale_y_continuous(limitsc(0.35,10.15),breaksc(1.0,2.75,4.5,5.7,7.45,9.2),labelsc(0,5,10,0,5,10),expandc(0,0))labs(x-log10(FDR),yPathway enrichment score)coord_cartesian(clipoff)theme_classic(base_size10)theme(plot.backgroundelement_rect(fillwhite,colourNA),panel.backgroundelement_rect(fillwhite,colourNA),panel.gridelement_blank(),axis.lineelement_line(colour#3d3d3d,linewidth0.45),axis.tickselement_line(colour#3d3d3d,linewidth0.35),axis.ticks.lengthunit(2.5,pt),axis.titleelement_text(size10.5,colour#303030),axis.textelement_text(size8.2,colour#4a4a4a),plot.marginmargin(16,24,14,20))ggsave(figures/spatial_ecotype_pathways.png,figure,width9.6,height5.9,dpi420,bgwhite)ggsave(figures/spatial_ecotype_pathways.pdf,figure,width9.6,height5.9,devicepdf,bgwhite)完整代码library(ggplot2)library(dplyr)library(readr)library(scales)project_dir-normalizePath(.,winslash/,mustWorkFALSE)figure_dir-file.path(project_dir,figures)dir.create(figure_dir,showWarningsFALSE,recursiveTRUE)layout_df-read_csv(data/panel_layout.csv,show_col_typesFALSE)pathway_df-read_csv(data/pathway_points.csv,show_col_typesFALSE)trail_df-read_csv(data/background_trails.csv,show_col_typesFALSE)ecotype_colors-c(C-I#d7ae2b,C-II#b85b5b,C-III#5b83b5,C-IV#93b15a)to_global-function(dat){dat%%left_join(layout_df,byc(ecotype,panel))%%mutate(gxx0x*width,gyy0y*height,glxx0label_x*width,glyy0label_y*height)}trail_global-trail_df%%left_join(layout_df,byecotype)%%mutate(gxx0x*width,gyy0y*height)pathway_global-pathway_df%%to_global()label_segments-pathway_global%%transmute(ecotype,xgx,ygy,xendglx,yendgly)figure-ggplot()geom_rect(datalayout_df,aes(xminx0,xmaxx0width,yminy0,ymaxy0height),fillwhite,colour#d6d6d6,linewidth0.35)geom_rect(datalayout_df,aes(xminx0,xmaxx0width,yminy0height0.14,ymaxy0height0.46,fillecotype),colourNA)geom_text(datalayout_df,aes(xx0width/2,yy0height0.30,labelpanel),size3.1,fontfacebold,colour#2b2b2b)geom_path(datatrail_global,aes(xgx,ygy,grouptrail,colourecotype),linewidth1.35,alpha0.12,lineendround)geom_point(datatrail_global%%slice(seq(1,n(),by3)),aes(xgx,ygy,colourecotype),size0.55,alpha0.08)geom_segment(datalabel_segments,aes(xx,yy,xendxend,yendyend,colourecotype),linewidth0.28,alpha0.68)geom_point(datapathway_global,aes(xgx,ygy,sizesize,fillecotype),shape21,colourwhite,stroke0.55,alpha0.93)geom_text(datapathway_global,aes(xglx,ygly,labellabel,hjusthjust),size2.15,lineheight0.85,colour#363636)scale_fill_manual(valuesecotype_colors,guidenone)scale_colour_manual(valuesecotype_colors,guidenone)scale_size_continuous(rangec(2.0,4.9),guidenone)scale_x_continuous(limitsc(0.25,21.0),breaksc(1.3,5.65,10.0,11.4,15.75,20.1),labelsc(0,5,10,0,5,10),expandc(0,0))scale_y_continuous(limitsc(0.35,10.15),breaksc(1.0,2.75,4.5,5.7,7.45,9.2),labelsc(0,5,10,0,5,10),expandc(0,0))labs(x-log10(FDR),yPathway enrichment score)coord_cartesian(clipoff)theme_classic(base_size10)theme(plot.backgroundelement_rect(fillwhite,colourNA),panel.backgroundelement_rect(fillwhite,colourNA),panel.gridelement_blank(),axis.lineelement_line(colour#3d3d3d,linewidth0.45),axis.tickselement_line(colour#3d3d3d,linewidth0.35),axis.ticks.lengthunit(2.5,pt),axis.titleelement_text(size10.5,colour#303030),axis.textelement_text(size8.2,colour#4a4a4a),plot.marginmargin(16,24,14,20))ggsave(file.path(figure_dir,spatial_ecotype_pathways.png),figure,width9.6,height5.9,dpi420,bgwhite)ggsave(file.path(figure_dir,spatial_ecotype_pathways.pdf),figure,width9.6,height5.9,devicepdf,bgwhite)复现结果参考链接Cell 原文页面PMC 全文与 Figure 4 图注DOI 页面CANVAS 项目代码
阅读完成 · 觉得有帮助?
咨询建站