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)
You have:
I guess this is not what you meant. If you wanted to use "order", there shouldn't be "<.1".
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.
It doesn't work that they. (You should have indicated that you are a novice R user.)
You first subset, and then you sort:
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.
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".
Thanks for the help!