.子集(x, j)中的错误:无效的下标类型“列表”

时间:2022-07-27 22:30:38

So I'm pretty new to R, so if someone could help me out that would be great.

所以我对R很陌生,所以如果有人能帮我,那就太好了。

I'm using a program called NOISeq, which is an R based piece of software which detects differential gene expression between a number of factors. I've read in a table to a data frame which looks like this:

我使用的是一个名为NOISeq的程序,它是一个基于R的软件,它可以检测多种因素之间的差异基因表达。我在一个表格中读到一个数据框,它看起来是这样的:

            X10G48 X35Y87 X36W26 X23Y79 X2B84 X12Y30 X10B70 X10G87 X36W62
XLOC_000001     33     34     39     74    43     43     34     28     42
XLOC_000002     17     42     44     67    38     58     41     29     25
XLOC_000003      0      0      0      0     0      0      6      0      0
XLOC_000004      0      0      0      2     0      0     10      0      0
XLOC_000005     44     57     37     71    45     47     49     53     36
XLOC_000006     43     46     42     71    53     53     49     48     18
            X23Y70 X2UNA X12Y47 X10R99
XLOC_000001     82    38     28     23
XLOC_000002     58    53     28     27
XLOC_000003      0     0      0     12
XLOC_000004      0     0      4      2
XLOC_000005     47    67     48     39
XLOC_000006     53    61     37     26

The table is sorted by two factors, such that 10G48, 35Y87, 36W26, 23Y79, 2B84, 12Y30, 10B70 are all condition 1, and 10G87, 36W62, 23Y70, 2UNA, 12Y47, 10R99 are all condition 2.

表按两个因素排序,如10G48、35Y87、36W26、23Y79、2B84、12y30,10b70都是条件1,10G87、36W62、23Y70、2UNA、12Y47、10R99都是条件2。

I've used the code:

我使用了代码:

library(NOISeq)
setwd("/home/user/edgeR")
data.frame <- read.table("nalphavbeta.txt", header=TRUE, sep='\t', row.names=1)
myfactors=data.frame(c(1,1,1,1,1,1,1,2,2,2,2,2,2))
sam<-readData(data=data.frame, factors=myfactors)
myRPKM = rpkm(assayData(sam)$exprs, k = 0, lc = 1)
head(myRPKM[, 1:4])
mynoiseqbio = noiseqbio(sam, k=0.5, norm="rpkm", factor=NULL, lc = 1, r = 20, adj = 1.5, plot = FALSE, a0per = 0.9, random.seed = 12345, filter = 2) 

But it returns the error

但它返回错误。

Error in .subset(x, j) : invalid subscript type 'list'

I have a feeling it's to do with the factors argument, but I'm not sure exactly what. Any help would be much appreciated - thanks!

我有一种感觉,这和那些因素有关,但我不确定到底是什么。非常感谢您的帮助,谢谢!

1 个解决方案

#1


1  

Problem solved

问题解决了

I just needed to change the line

我只需要换行。

myfactors=data.frame(c(1,1,1,1,1,1,1,2,2,2,2,2,2))

to

myfactors=data.frame(caste= c(1,1,1,1,1,1,1,2,2,2,2,2,2))

i.e. give the factor a name, then add the factor level into the function

例如,给因子一个名称,然后将因子级别添加到函数中。

mynoiseqbio = noiseqbio(sam, k=0.5, norm="rpkm", factor=caste, lc = 1, r = 20, adj = 1.5, plot = FALSE, a0per = 0.9, random.seed = 12345, filter = 2)

#1


1  

Problem solved

问题解决了

I just needed to change the line

我只需要换行。

myfactors=data.frame(c(1,1,1,1,1,1,1,2,2,2,2,2,2))

to

myfactors=data.frame(caste= c(1,1,1,1,1,1,1,2,2,2,2,2,2))

i.e. give the factor a name, then add the factor level into the function

例如,给因子一个名称,然后将因子级别添加到函数中。

mynoiseqbio = noiseqbio(sam, k=0.5, norm="rpkm", factor=caste, lc = 1, r = 20, adj = 1.5, plot = FALSE, a0per = 0.9, random.seed = 12345, filter = 2)