rowttests
package:genefilter の関数を使いたいです。rowtests
関数の引数は次のとおりです。
>rowttests(x, fac)
x: Numeric matrix. The matrix must not contain ‘NA’ values. For
‘rowttests’ and ‘colttests’, ‘x’ can also be an
‘ExpressionSet’.
fac: Factor which codes the grouping to be tested.
したがって、私の入力は以下のデータフレームであり、次の手順を実行しましたがエラーが発生しました..
> dataframe
V1 V2 V3 V4
1 1 5 6 7
2 2 6 7 8
3 3 7 8 9
4 4 8 9 10
5 5 9 10 11
6 6 10 11 12
7 7 11 12 13
>mat <-as.matrix(dataframe)
> mat
V1 V2 V3 V4
[1,] 1 5 6 7
[2,] 2 6 7 8
[3,] 3 7 8 9
[4,] 4 8 9 10
[5,] 5 9 10 11
[6,] 6 10 11 12
[7,] 7 11 12 13
>fac <- factor(c(1,1,2,2))
エラーは次のとおりです。
rowttests(mat, fac)
Error in rowcoltt(x, fac, tstatOnly, 1L) :
Invalid argument 'x': must be a real matrix.
> mode(mat)
[1] "numeric"
> class(mat)
[1] "matrix"
私も試しました:
>mat1 <-matrix((stack(dataframe))[[1]],nrow=7, ncol=4)
>mat1
[,1] [,2] [,3] [,4]
[1,] 1 5 6 7
[2,] 2 6 7 8
[3,] 3 7 8 9
[4,] 4 8 9 10
[5,] 5 9 10 11
[6,] 6 10 11 12
[7,] 7 11 12 13
再び同じエラー
rowttests(mat1, fac)
Error in rowcoltt(x, fac, tstatOnly, 1L)
Invalid argument 'x': must be a real matrix.
rowttests 関数で使用できるように、データ フレームをマトリックスに変換する方法を教えてください。