[BioC] Sorting matrix by column

Guest [guest] guest at bioconductor.org
Tue Oct 23 17:15:54 CEST 2012


Hi,

I would like to sort a matrix by a specific column (column 2). I tried the order() function, but I get an error. I think it is because the values in column 2 are not numeric, they are gene symbols. This may be a general R question, but I thought I would post it here since it is microarray data analysis.

I have matrix x:

> x
         ID         Gene Symbol     logFC      Adj.PVal 
10344624 "10371400" "Lypla1"        0.3592492  0.9999522
10344633 "10453900" "Tcea1"         0.1886117  0.9999522
10344637 "10375051" "Atp6v1h"       0.6713107  0.9999522
10344653 "10575211" "Oprk1"         -0.2342731 0.9999522
10344658 "10566254" "Rb1cc1"        1.790676   0.9999522
10344674 "10602372" "Fam150a"       1.397496   0.9999522
10344679 "10398428" "St18"          -0.3278807 0.9999522
10344707 "10383518" "Pcmtd1"        -0.2231074 0.9999522
10344713 "10397054" "Ahcy"          -0.1844897 0.9999522
10344723 "10384020" "Rrs1"          -0.2322781 0.9999522
10344725 "10608710" "Adhfe1"        0.5993566  0.9999522
10344741 "10363762" "Hnrnpa3"       -0.2660978 0.9999522
10344743 "10375058" "3110035E14Rik" 0.9178868  0.9999522
10344750 "10381603" "Sgk3"          -0.2961638 0.9999522
10344772 "10442373" "6030422M02Rik" -0.1653454 0.9999522
10344789 "10421227" "Cspp1"         -0.1480766 0.9999522
10344799 "10534966" "Cspp1"         -0.2436361 0.9999522
10344801 "10398408" "Cspp1"         -0.4040665 0.9999522
10344803 "10398418" "Cspp1"         -0.2556627 0.9999522
10344805 "10572772" "Cspp1"         -0.1864641 0.9999522

I want to sort on the "Gene Symbol" column so that I can remove the duplicates and keep the one with the highest log fold change.

I tried the following and received an error.
> x[order(x[,2]),]
Error in order(x[, 2]) : unimplemented type 'list' in 'orderVector1'

If anyone has any suggestions for an easy way to sort a significant gene list, remove duplicated values, and keep the value with highest fold change, that would be helpful!

I've posted my session info below.

Thanks!

Guest

 -- output of sessionInfo(): 

> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] tools_2.15.1

--
Sent via the guest posting facility at bioconductor.org.



More information about the Bioconductor mailing list