如何在 R 中绘制剖面图? [英] How do I draw a profile plot in R?
问题描述
我想为不同时间点的 VPs8 基因生成轮廓图.
I want to generate a profile plot for VPs8 gene across different time points.
dat <- read.table("xyz", header=T, row.names=1)
cdc15 <- select(dat, 23:46)
VPS8 <- cdc15["YAL002W",]
VPS8_num <- data.frame(as.numeric(VPS8))
names(VPS8) <- str_remove(names(VPS8), 'cdc15_')
plot(c(1, ncol(VPS8), range(na.omit(as.numeric(VPS8[1,]))),
type="n", xlab="",
ylab="log2(intensity)",
main="VPS8 expression in yeast S. cerevisiae
cdc15 mutant during different time points of cell cycle arrest",
axes=FALSE
))
lines(c(1:ncol(dat)), as.numeric(dat[VPs8]), lwd=2, col="blue")
grid()
axis(1, at=c(1:ncol(dat)), dimnames(dat)[[2]], las=2, cex.lab=0.7)
axis(2)
数据:
> dput(VPS8)
structure(list(cdc15_10 = NA_real_, cdc15_30 = NA_real_, cdc15_50 = NA_real_,
cdc15_70 = -0.58, cdc15_80 = 0.23, cdc15_90 = -0.23, cdc15_100 = 0.08,
cdc15_110 = -0.62, cdc15_120 = 0.55, cdc15_130 = -0.32, cdc15_140 = 0.03,
cdc15_150 = -0.56, cdc15_160 = 0.47, cdc15_170 = -0.15, cdc15_180 = 0.49,
cdc15_190 = NA_real_, cdc15_200 = 0.23, cdc15_210 = -0.49,
cdc15_220 = 0.33, cdc15_230 = 0.18, cdc15_240 = 0.65, cdc15_250 = -0.29,
cdc15_270 = NA_real_, cdc15_290 = NA_real_), row.names = "YAL002W", class = "data.frame")
CDC15
预期输出:生成 VPS8 基因的轮廓图.在 x 轴上,仅提供没有cdc15_"的时间点.前缀.
Desired output: Generate a profile plot for VPS8 gene. On the x-axis, provide only the time points without the "cdc15_" prefix.
错误:xj[i] 中的错误:无效的下标类型列表"
Error: Error in xj[i] : invalid subscript type 'list'
推荐答案
行
match <- str_remove(as.list(VPS8), "cdc15_")
没有意义.纯属偶然,它不会引发错误,但它没有任何用处.实际上,您似乎想从表的列名中删除cdc15_
.你需要在这里做一些不同的事情:
makes no sense. By pure accident it doesn’t raise an error, but it does nothing useful. In reality, you seem to want to remove cdc15_
from the column names of your table. You’ll need to do something different here:
names(VPS8) <- str_remove(names(VPS8), 'cdc15_')
接下来,您观察到的实际错误来自于此:
Next, the actual error you’re observing is from this:
dat[VPS8,])
您正在使用 data.frame 作为子集的索引 - 这不受支持,并且不清楚您打算做什么.但根据数据,我猜该行应该如下所示(格式正确):
You are using a data.frame as an index for subsetting — this isn’t supported, and it isn’t clear what you intended to do. But based on the data I guess the line should probably look as follows (properly formatted):
plot(
c(1, ncol(VPS8)),
range(na.omit(as.numeric(VPS8[1, ]))),
type = "n", xlab = "",
ylab = "log2(intensity)",
main = "VPS8 expression in yeast S. cerevisiae cdc15 mutant during different time points of cell cycle arrest",
axes = FALSE,
lwd = 1
)
——当然,这纯粹是我的猜测,因为这没有绘制任何内容(因为你已经指定了 type = "n"
).
— Of course this is pure guesswork on my part, since this plots nothing (since you’ve specified type = "n"
).
这篇关于如何在 R 中绘制剖面图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!