下面是一个用Python编写的示例代码,可以帮助可视化具有统计学意义的基因及其对应的Z分数的散点图。
import matplotlib.pyplot as plt
import numpy as np
# 基因数据
genes = ['Gene1', 'Gene2', 'Gene3', 'Gene4', 'Gene5']
z_scores = [-1.5, 0.8, -2.1, 1.2, -0.5]
# 创建画布和子图
fig, ax = plt.subplots()
# 设置横纵坐标标签
ax.set_xlabel('Genes')
ax.set_ylabel('Z-scores')
# 设置标题
ax.set_title('Scatter plot of Genes and Z-scores')
# 绘制散点图
ax.scatter(genes, z_scores)
# 在每个数据点上添加文本标签
for i in range(len(genes)):
ax.annotate(z_scores[i], (genes[i], z_scores[i]), textcoords="offset points", xytext=(0,10), ha='center')
# 显示图形
plt.show()
运行上述代码将生成一个散点图,其中基因名称显示在x轴上,Z分数显示在y轴上。每个数据点上方都标有相应的Z分数。您可以根据自己的需求修改基因数据和Z分数。