Question: Subsetting DESeq2 results by padj quantity
0
gravatar for rbronste
3 months ago by
rbronste160
rbronste160 wrote:

I am trying to export DESeq2 results that fall under a certain padj in the following way:

resFemEB<-results(dds, lfcThreshold=2, altHypothesis="greater", alpha = .1, format = c("GRanges"), independentFiltering=FALSE, contrast=c(1, -1/3, -1/3, -1/3))

resOrderedFemEB <- resFemEB[which(resFemEB$padj < 0.1),]

 df <- data.frame(seqnames=seqnames(resOrderedFemEB),
+                  starts=start(resOrderedFemEB)-1,
+                  ends=end(resOrderedFemEB),
+                  names=c(rep(".", length(resOrderedFemEB))),
+                  scores=c(rep(".", length(resOrderedFemEB))),
+                  strands=strand(resOrderedFemEB))
> write.table(df, file="resOrderedFemEB.bed", quote=F, sep="\t", row.names=F, col.names=F)

This works well for getting all of the results in a BED format that fall below a certain padj, what I wanted to ask is how I can just get the top 1000 exported (currently the list is around 10K that falls within that padj criteria)?

deseq deseq2 R • 341 views
ADD COMMENTlink modified 3 months ago by mbk0asis320 • written 3 months ago by rbronste160
3
gravatar for mbk0asis
3 months ago by
mbk0asis320
Korea, Republic Of
mbk0asis320 wrote:
dta <- subset(result, padj<.1)
dta_sorted = dta[order(dta$padj), ]
write.table(head(dta_sorted,1000),"dta.tsv")
ADD COMMENTlink modified 3 months ago • written 3 months ago by mbk0asis320

Exactly what I was after, thanks!

ADD REPLYlink written 3 months ago by rbronste160
0
gravatar for WouterDeCoster
3 months ago by
Belgium
WouterDeCoster27k wrote:

You could use the head() function

e.g.:

head(df, n=1000)
ADD COMMENTlink modified 3 months ago • written 3 months ago by WouterDeCoster27k

Thanks, yes this I know how to do, what I need is to export the top 1000 that fall under padj<.1, doing this currently to export them all:

write.table(df, file="resOrderedFemEB.bed", quote=F, sep="\t", row.names=F, col.names=F)
ADD REPLYlink modified 3 months ago • written 3 months ago by rbronste160

So then you need to sort the data frame based on padj and then take the head()

ADD REPLYlink written 3 months ago by WouterDeCoster27k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1031 users visited in the last hour