This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Codes for preparing data for goseq!

Hi,

I am learning goseq and I know a bit of R. I just can read the codes and understand them but not very creative to type what I want to do. So I need to prepare data from deseq2res. One vector containing all genes (column 1) and the other vector containing all DE genes (padj < 0.05). Can anyone do the favor? Any lines of code is appreciated!

goseq

1 answer

d <- read.csv("deseq2res.csv", header=T, row.names=1)
all_genes <- row.names(d)
DE_genes <- all_genes[which(d$padj<0.05)]

Thanks a million Devon.

Random comment re: R style: In this case, you should avoid the call to which, ie. instead of

DE_genes <- all_genes[which(d$padj<0.05)]

do

DE_genes <- all_genes[d$padj<0.05]

because sometimes funny things happen when indexing with a 0 length vector (i.e. which would be what is returned from which if there were no results with padj < 0.05 ... and it's redundant here, anyway ;-)

That'll pick up NAs, which will be present in DESeq2's output due to independent filtering.

Thanks for mentioning it!

Log in to answer this question.