0

I am trying to order data by the column weightFisher. However, it is almost as if R does not process e values as low, because all the e values are skipped when I try to order from smallest to greatest.

Code:

resultTable_bon <- GenTable(GOdata_bon,
                           weightFisher = resultFisher_bon,
                           weightKS = resultKS_bon,
                           topNodes = 15136,
                           ranksOf = 'weightFisher'
)
head(resultTable_bon)

#create Fisher ordered df
indF <- order(resultTable_bon$weightFisher)
resultTable_bonF <- resultTable_bon[indF, ]

what resultTable_bon looks like:

       GO.ID                             Term Annotated Significant Expected Rank in weightFisher
1 GO:0019373         epoxygenase P450 pathway        19          13     1.12                    1
2 GO:0097267   omega-hydroxylase P450 pathway         9           7     0.53                    2
3 GO:0042738 exogenous drug catabolic process        10           7     0.59                    3
  weightFisher weightKS
1      1.9e-12  0.79744
2      7.9e-08  0.96752
3      2.5e-07  0.96336

what "ordered" resultTable_bonF looks like:

        GO.ID                                        Term Annotated Significant Expected Rank in weightFisher
17 GO:0014075                           response to amine        33           7     1.95                   17
18 GO:0034372 very-low-density lipoprotein particle re...        11           5     0.65                   18
19 GO:0060710                     chorio-allantoic fusion         6           4     0.35                   19
   weightFisher weightKS
17      0.00014  0.96387
18      0.00016  0.83624
19      0.00016  0.92286
merryberry
  • 91
  • 1
  • 9
  • 3
    Could you provide a [reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) It will be much easier for others to answer your question if they can reproduce your issue. – Florian Jul 27 '17 at 17:01
  • 1
    read the help for `order` with `?order`. And use order's argument `decreasing`. R is doing exactly what you asked it to do. – Bhas Jul 27 '17 at 17:05
  • I want it to increase. By e value, I mean negative e value. Look at how the first table has very low weightFisher values, but then when I try to order it, in the next table, the lowest terms are not there first. – merryberry Jul 27 '17 at 17:18
  • How many rows are in "resultTable_bonF"? We can only see rows 17:19, but in those it looks like `weightFisher` is in ascending order. What do you get from `head(resultTable_bonF); tail(resultTable_bonf)`? – Luke C Jul 27 '17 at 17:28
  • nevermind got it. – merryberry Jul 27 '17 at 17:37

2 Answers2

1

As @bhas says, it appears to be working precisely as you want it to. Maybe it's the use of head() that's confusing you?

To put your mind at ease, try it with something simpler

dtf <- data.frame(a=c(1, 8, 6, 2)^-10, b=c(7, 2, 1, 6))

dtf
             # a b
# 1 1.000000e+00 7
# 2 9.313226e-10 2
# 3 1.653817e-08 1
# 4 9.765625e-04 6

dtf[order(dtf$a), ]
             # a b
# 2 9.313226e-10 2
# 3 1.653817e-08 1
# 4 9.765625e-04 6
# 1 1.000000e+00 7
AkselA
  • 8,153
  • 2
  • 21
  • 34
0

Try the following :

resultTable_bon$weightFisher <- as.numeric (resultTable_bon$weightFisher) 

Then :

resultTable_bonF <- resultTable_bon[order(resultTable_bonF$weightFisher),] 
nidabdella
  • 811
  • 8
  • 24