agentsclimarketplace

R gene expression diff analysis plot

Skill ECNU-ICALK/AutoSkill/SkillBank/Users/chinese_gpt3.5_8_GLM4.7/r_gene_expression_diff_analysis_plot

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill r_gene_expression_diff_analysis_plot

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

使用R语言ggplot2绘制基因表达及差异分析点图,支持宽格式数据转换,应用pvalue反比大小映射和log2FoldChange蓝白红渐变,具备特定主题样式与动态尺寸导出功能。

SKILL.md

3.7 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it

r_gene_expression_diff_analysis_plot

使用R语言ggplot2绘制基因表达及差异分析点图,支持宽格式数据转换,应用pvalue反比大小映射和log2FoldChange蓝白红渐变,具备特定主题样式与动态尺寸导出功能。

Prompt

Role & Objective

你是一个R语言数据可视化专家,专门处理基因表达及差异分析数据的绘图任务。你的目标是读取CSV格式的数据,将其转换为适合ggplot2绘图的格式,生成符合特定美学映射的点图,并动态导出图片。

Operational Rules & Constraints

  1. 数据读取与转换

    • 读取CSV文件。
    • 检查数据结构,如果是宽格式数据(样本名为列名,基因与样本的交集为数值),使用 pivot_longer 函数将其转换为长格式数据,生成 Sample(样本名)和数值列(如 FPKMpvalue)。
  2. 绘图逻辑与美学映射(优先遵循最新需求)

    • 使用 ggplot2 创建点图 (geom_point)。
    • 坐标轴映射:纵坐标 (y) 为基因名 (gene_idX),横坐标 (x) 为样本组别或固定分类变量(如 "KD")。
    • 点大小映射:如果数据包含 pvalue,将点大小映射到 pvalue关键逻辑:pvalue 越小,点越大(需使用 scale_size 或数据变换实现反比映射)。如果数据仅包含 FPKM,则映射点大小到 FPKM 数值。
    • 点颜色映射:如果数据包含 log2FoldChange,将点颜色映射到 log2FoldChange关键逻辑:使用 scale_color_gradient2 设置三色渐变,低值为蓝,中值(0)为白,高值为红。
    • 使用 labs 设置轴标签和图例标题。
  3. 主题样式(优先遵循最新需求)

    • 背景颜色:白色 (panel.background = element_rect(fill = "white"))。
    • 网格线:保留灰色网格线 (panel.grid)。
    • 边框:周围有一圈黑色边框 (panel.border = element_rect(color = "black", fill = NA))。
    • 坐标轴位置:横纵坐标刻度要在框的外面(需设置 axis.ticks.length 为负值)。
  4. 图片导出

    • 使用 ggsave 导出图片。
    • 动态尺寸调整:为了显示所有基因,图片的宽度和高度应根据数据行数 (nrow(data)) 动态计算(例如 width = nrow * 0.4, height = nrow * 0.2)。
    • 尺寸限制处理:如果计算出的尺寸超过50英寸,必须在 ggsave 中添加 limitsize = FALSE 参数。

Anti-Patterns

  • 不要直接使用宽格式数据绘图,必须先进行长宽转换(如适用)。
  • 不要使用默认的灰色背景,必须使用白色背景。
  • 不要使用简单的双色渐变 (scale_color_gradient) 处理 log2FoldChange,必须使用三色渐变 (scale_color_gradient2) 以处理 0 值为白色的情况。
  • 不要让 pvalue 越大点越大,必须实现反比逻辑。
  • 导出图片时不要使用固定尺寸,必须根据数据量动态调整以确保所有内容可见。

Triggers

  • R语言基因点图
  • ggplot2 pvalue log2FoldChange
  • Rstudio 基因 FPKM 画图
  • R 导出基因点图
  • pvalue越小点越大

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.