This is a test version of Biostars. For the public version, visit https://www.biostars.org.
R - how to create an expression matrix from limma test DE data?

Hallo,

I would like to create such an expression matrix:

GENE ID/SAMPLE     sample1     sample2     sample3     sample4     sample-n
gene1              logFC       ...         ...         ...         ...
gene2              ...         ...         ...         ...         ...
gene3              ...         ...         ...         ...         ...
gene4              ...         ...         ...         ...         ...
gene-n             ...         ...         ...         ...         ...

using data from GSE at GEO. I will be grateful for any suggestions or just codes.

Second thing:

How to get such an expression matrix after limma DE analysis? How to modify limma codes? I will appreciate any suggestions or codes.

Thanks in advance, one more time.

Regards!

r procedure geo

1 answer

Something like this should about do it.

library(GEOquery)
# assumes only one platform in the GSE
gse = getGEO('GSEXXXX')[[1]]

gse is an ExpressionSet, so all the usual ExpressionSet methods work as expected. In particular, we can use fData() to get the feature information (gene information) and the exprs() method to get the actual values.

write.table(data.frame(fData(gse),exprs(gse)),sep="\t",row.names=FALSE,file='abc.txt')

You may need to use a subset of the columns in fData to match your needs.

Thank you for the answer. I have checked it already, and what I got:

Error in(function (classes, fdef, mtable)
  unable to find an inherited method for function 'fData' for signature '"list"'

The same thing appers when using only fData command.

Note that getGEO() returns a list. I'm guessing that you tried to use fData() on that list. To get the first element of the list (usually, that is what you want), you'll want to follow the code above and note the [[1]] after the getGEO() function call. In my code above, gse is an ExpressionSet. If you need to check, you can try class(gse).

Now, everything is working. You have solved my problem. Thank you very much!

Regards!

Log in to answer this question.