DESeq2 results export padj sorted
1
0
Entering edit mode
rbronste ▴ 60
@rbronste-12189
Last seen 5.0 years ago

When I do the following for some reason the output only includes ranges from a single chromosome or several, while if I look at the padj sorted GRanges in R it includes many chromosomes at the top of the padj list. Is there something I am doing wrong in the sorting and exporting of results? Thanks.

bn_group_male<-results(dds, lfcThreshold=1, altHypothesis="greater", format = c("GRanges"), independentFiltering=TRUE, contrast=c("group", "maleBB", "malevehicle"))

bn_group_male_padj.1 <- subset(bn_group_male, padj<.1)

bn_group_male_padj.1_sorted = bn_group_male_padj.1[order(bn_group_male_padj.1$padj<.1), ]

write.table(head(bn_group_male_padj.1_sorted,1000),"bn_group_male_padj.1.bed", quote=F, sep="\t", row.names=F, col.names=T)
deseq2 deseq differential binding analysis • 3.9k views
ADD COMMENT
0
Entering edit mode

You have: 

bn_group_male_padj.1_sorted = bn_group_male_padj.1[order(bn_group_male_padj.1$padj<.1), ]

I guess this is not what you meant. If you wanted to use "order", there shouldn't be "<.1".

ADD REPLY
0
Entering edit mode

Well basically in the end I want a BED file of the top 1000 ranges padj<.1, in this list there are many thousands however I just want to export the top thousand by padj.

ADD REPLY
0
Entering edit mode

It doesn't work that they. (You should have indicated that you are a novice R user.)

You first subset, and then you sort:

bn_group_male_padj.1 <- subset(bn_group_male, padj<.1)
bn_group_male_padj.1_sorted = bn_group_male_padj.1[order(bn_group_male_padj.1$padj), ]
ADD REPLY
0
Entering edit mode

I am a fairly novice user however if you look above at the initial example I did in fact first subset and then sort. Thanks.

ADD REPLY
1
Entering edit mode

I know. But you put the "<.1" into the parantheses after "order". So what happens is that the argument of order gets transformed into a vector of only TRUE and FALSE. The actual values of padj vanish. So, the ordering only ensures that FALSE comes before TRUE. 

Now, as you have already filtered, there is only TRUE, and the line with "order" does nothing. Everything stays in the order it was in before. And that was presumably ordered by chromosome. That's why the first 1000 items were all on chromosome 1.

What I just did is copy your two lines and remove the "<.1". 

ADD REPLY
0
Entering edit mode

Thanks for the help!

ADD REPLY
1
Entering edit mode
@mikelove
Last seen 2 hours ago
United States

See rtracklayer for writing GRanges to BED file.

ADD COMMENT
0
Entering edit mode

Thanks for the suggestion!

While I do get the bed file I am after, it seems to be sorted by chromosome as it only gives me chr1 ranges and not other. Not sure why since I am doing the following:

bn_group_male_padj.1_sorted = bn_group_male_padj.1[order(bn_group_male_padj.1$padj<.1), ]

export.bed(head(bn_group_male_padj.1_sorted,1000),"bn_group_male_padj.1.bed")​

So it seems like I am sorting by padj and all I basically want here is ranges on any chromosome that fall into the top 1000 by padj. Not exactly sure what I am doing wrong, thanks again.

ADD REPLY
0
Entering edit mode

I can't tell when you have a data.frame and when you have a GRanges. Does subset() give back a GRanges? I'd be careful about when you've got which class of object. You can definitely use [] and which(res$padj < .1) to operate on a GRanges. And [] with order(res$padj) should work as well.

ADD REPLY
0
Entering edit mode

Yes they are GRanges so not sure why its not ordering them properly. 

ADD REPLY

Login before adding your answer.

Traffic: 776 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6