user438383
user438383

Reputation: 6206

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

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

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:

            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.

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!

Upvotes: 0

Views: 2682

Answers (1)

user438383
user438383

Reputation: 6206

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)

Upvotes: 1

Related Questions