0
resSig <- subset(res, res$padj < 0.05 )  

Using this code i create a vector resSig

head( resSig[ order( resSig$log2FoldChange ), ], 500)

I print top 500 genes

 baseMean log2FoldChange     lfcSE      stat       pvalue         padj
                 <numeric>      <numeric> <numeric> <numeric>    <numeric>    <numeric>
ENSG00000096006   1987.812       -14.1212  1.286311 -10.97807  4.87215e-28  5.77837e-25
ENSG00000170477 125694.012       -11.3416  0.519680 -21.82421 1.36677e-105 1.37784e-101
ENSG00000143536   7731.399       -11.2569  1.504429  -7.48249  7.29248e-14  7.90489e-12
ENSG00000016602   5531.968       -10.5545  0.417882 -25.25705 9.47707e-141 1.91077e-136
ENSG00000178690    151.547       -10.4074  1.255369  -8.29030  1.12959e-16  2.01547e-14
...                    ...            ...       ...       ...          ...          ...

Now, I am trying to export this data to a csv file

Rui Barradas
  • 70,273
  • 8
  • 34
  • 66
  • Hi sushmitha. You're unlikely to get a good answer to this question because your problem is not reproducible. Check this question for advice on how to produce a reproducible code segment in R: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Captain Hat Jan 22 '21 at 11:09
  • At the very least, it would be helpful to see the error message you are receiving (assuming you're getting an error)? – Captain Hat Jan 22 '21 at 11:11

1 Answers1

0

You should start by storing the data into a data frame and then call write.csv()

resSig <- subset(res, res$padj < 0.05 )
resSig<-resSig[ order( resSig$log2FoldChange ),]
resSig_top500<-resSig[1:500,]

write.csv(resSig_top500,"resSig_top500.csv")

cheers