gpt4 book ai didi

R错误: "attempt to select less than one element in get1index"

转载 作者:行者123 更新时间:2023-12-02 04:06:25 29 4
gpt4 key购买 nike

我是 R 初学者,我正在尝试使用包 ClonEvol,但是 github 网页上的文档非常有限。因此,现在我正在使用他们的示例代码,并尝试将其调整为我的名为 ce 的数据。

  ce <- data.frame(
cluster = c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7),
gene = c("geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC",
"geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD","geneA","geneB","geneC","geneD"),
prim.vaf = c(0.5,0,0,0,0.5,0.5,0,0,1,0.5,0,0,1,0.5,0,0.5,0.5,0.5,0,0.5,0.5,0.5,0,1,0.5,0.5,0.5,0)
)

cluster <- ce$cluster
gene <- ce$gene
prim.vaf <- ce$prim.vaf

x <- ce

vaf.col.names <- grep('prim.vaf', colnames(x), value=T)
sample.names <- gsub('prim.vaf', '', vaf.col.names)
x[, sample.names] <- x[, vaf.col.names]
vaf.col.names <- sample.names
sample.groups <- c('P', 'R');
names(sample.groups) <- vaf.col.names
x <- x[order(x$cluster),]

pdf('box.pdf', width = 3, height = 5, useDingbats = FALSE, title='')
pp <- variant.box.plot(x,
cluster.col.name = ce$cluster,
show.cluster.size = FALSE,
cluster.size.text.color = 'blue',
vaf.col.names = vaf.col.names,
vaf.limits = 70,
sample.title.size = 20,
violin = FALSE,
box = FALSE,
jitter = TRUE,
jitter.shape = 1,
jitter.color = clone.colors,
jitter.size = 3,
jitter.alpha = 1,
jitter.center.method = 'median',
jitter.center.size = 1,
jitter.center.color = 'darkgray',
jitter.center.display.value = 'none',
highlight = 'is.driver',
highlight.note.col.name = 'gene',
highlight.note.size = 2,
highlight.shape =16,
order.by.total.vaf = FALSE
)
dev.off()

但是,我收到以下错误:

    Error in .subset2(x, i, exact = exact) : recursive indexing failed at level 2

如果我删除 cluster.col.name=ce$clustervaf.col.names=vaf.col.names,错误将变为以下内容:

    Error in .subset2(x, i, exact = exact) : attempt to select less than one     
element in get1index

有人知道出了什么问题吗?

最佳答案

我今天遇到了此错误消息。我对这个问题中的 R 包知之甚少,但我想我可以在这里展示错误消息的含义。也许找出问题对你很有用。

当我们使用NULL作为索引来对列表进行子集化时,就会发生错误。
以下是调用此错误消息的表达式:

any.list <- list(1, 2, 3)
# If single brackets, no error occurs:
any.list[NULL]
## list()

# If double brackets, the error occurs:
any.list[[NULL]]
## Error in any.list[[NULL]] :
## attempt to select less than one element in get1index

上面的列表可以是任何列表,甚至是向量。

a.vector <- c(1, 2, 3)
a.vector[[NULL]]
## Error in a.vector[[NULL]] :
## attempt to select less than one element in get1index

这是类似的错误消息:

any.list[[0]]
## Error in any.list[[0]] :
## attempt to select less than one element in get1index <real>

结束

关于R错误: "attempt to select less than one element in get1index",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44949923/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com