You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何绘制排除指定列值的基因富集散点图?

解决方案

核心思路是先对数据框df进行行过滤,排除term列中属于redundant_terms列表的条目,再将过滤后的数据集传入已有的get_plot函数生成散点图。

基础实现方式

假设你的get_plot函数接受一个数据框作为参数(比如get_plot(data)),可以这样处理:

# 过滤数据:保留term列不在redundant_terms中的行
filtered_df = df[~df['term'].isin(redundant_terms)]

# 调用现有函数生成散点图
plot = get_plot(filtered_df)
plot.show()  # 根据你的可视化库(如matplotlib/seaborn/plotly)调整显示方式

进阶:忽略术语大小写匹配

如果需要忽略term和redundant_terms之间的大小写差异(比如避免"GO:0005886"和"go:0005886"被误判为不同术语),可以用以下方式过滤:

# 将redundant_terms转为小写集合
lower_redundant = {term.lower() for term in redundant_terms}
# 过滤时匹配小写后的term
filtered_df = df[~df['term'].str.lower().isin(lower_redundant)]

# 生成图表
plot = get_plot(filtered_df)
plot.show()

若get_plot函数直接接收term列数据

如果你的get_plot函数是单独接收term列数据而非整个数据框,可以提取过滤后的term列传入:

filtered_terms = df.loc[~df['term'].isin(redundant_terms), 'term']
plot = get_plot(filtered_terms)
plot.show()

内容的提问来源于stack exchange,提问作者melolilili

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 20:45:37