我有一个包含 2 个变量(A 和 B)的矩阵,以及我想绘制与该变量相关的两个基因的表达。
数据:
A = c(1.16, 1.16, 0.96, 0.96, 0.96, 0.67, 0.67, 0.67, 0.78, 0.78, 0.55, 0.3, 0.3, 0.3, 0.26, 0.26, 0.26)
B = c(6.513421667, 6.513421667, 4.981984615, 4.981984615, 4.981984615, 2.858295, 2.858295, 2.858295, 3.19875, 3.19875, 3.604918, 10.82963857, 10.82963857, 10.82963857, 8.607186667, 8.607186667, 8.607186667)
gene1 = c(0.007614672, 0.007632451, 0.007066506, 0.007524053, 0.008337992, 0.012520277, 0.012249, 0.011351902, 0.01263021, 0.009969673, 0.008850031, 0.007290232, 0.00724349, 0.007161781, 0.004299581, 0.004896156, 0.005970637)
gene2 = c(0.019649471, 0.015339387, 0.0180094, 0.018787749, 0.014556951, 0.011603994, 0.012012431, 0.011189356, 0.012666218, 0.01472512, 0.016299402, 0.017398006, 0.021602747, 0.019780361, 0.014182726, 0.015611876, 0.018550423)
这就是我所做的:
df = data.frame(A, B, gene1, gene2)
df <- data.frame(A = rep(A, 3), B= rep(B, 3), y = c(gene1, gene2), genes = rep(c("gene1", "gene2", each = 17))
plot(A,B, pch=unclass(genes)) # different symbol
legend("bottomright", legend=levels(genes), pch=c(1:3))
我想在图表上绘制基因,以便它们对应于变量 A(x 轴)和变量 B(y 轴),所以它看起来像这样谢谢!: