Help with rearranging dataframe
1
0
Entering edit mode
Hari Easwaran ▴ 240
@hari-easwaran-3510
Last seen 9.5 years ago
United States
Hi all, I have another question with handling dataframes. I have a dataframe with the 1-st column as probenames (agilent) and the remaining columns are the intensity values from multiple samples. I want to order this table such that the order of the probenames correspond to the order of the genes on the chromosome. To do this I have another table which has teh probenames in this order. For example: probename sample1 sample2 sample3 sample4 ... a v11 v12 v13 v14 d v21 v22 v23 v24 b v31 v32 v33 v34 c v41 v42 v43 v45 e v51 v52 v53 v54 I want the above table to be rearranged such that the 1st column is in the order a,b,c,d,e and the correspondig values (v11, v12, etc) are also appropriately rearranged. Thanks a lot for any help/suggestions. Sincerely, Hari [[alternative HTML version deleted]]
• 1.0k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On Tue, Sep 29, 2009 at 3:39 PM, Hari Easwaran <hariharan.pe at="" gmail.com=""> wrote: > Hi all, > I have another question with handling dataframes. > I have a dataframe with the 1-st column as probenames (agilent) and the > remaining columns are the intensity values from multiple samples. I want to > order this table such that the order of the probenames correspond to the > order of the genes on the chromosome. To do this I have another table which > has teh probenames in this order. Probably the simplest way is to merge the two data.frames first. See the merge() function. After merging, then do your reordering on the merged data.frame. Sean > For example: > > probename ? ? ? ? ? sample1 ? ? ? ? ?sample2 ? ? ? ? ?sample3 > sample4 ... > a ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?v11 > v12 ? ? ? ? ? ? ? ? ? ?v13 ? ? ? ? ? ? ? ? ?v14 > d ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?v21 > v22 ? ? ? ? ? ? ? ? ? ?v23 ? ? ? ? ? ? ? ? ?v24 > b ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?v31 ? ? ? ? ? ? ? ? ? ? ? ?v32 > ? ?v33 ? ? ? ? ? ? ? ? ?v34 > c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? v41 ? ? ? ? ? ? ? ? ? ? ? v42 > ? ? v43 ? ? ? ? ? ? ? ? ?v45 > e ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? v51 ? ? ? ? ? ? ? ? ? ? ? ?v52 > ? ?v53 ? ? ? ? ? ? ? ? ?v54 > > I want the above table to be rearranged such that the 1st column is in the > order a,b,c,d,e and the correspondig values (v11, v12, etc) are also > appropriately rearranged. > > Thanks a lot for any help/suggestions. > > Sincerely, > Hari > > ? ? ? ?[[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor >
ADD COMMENT
0
Entering edit mode
On Tue, Sep 29, 2009 at 3:47 PM, Sean Davis <seandavi at="" gmail.com=""> wrote: > On Tue, Sep 29, 2009 at 3:39 PM, Hari Easwaran <hariharan.pe at="" gmail.com=""> wrote: >> Hi all, >> I have another question with handling dataframes. >> I have a dataframe with the 1-st column as probenames (agilent) and the >> remaining columns are the intensity values from multiple samples. I want to >> order this table such that the order of the probenames correspond to the >> order of the genes on the chromosome. To do this I have another table which >> has teh probenames in this order. > > Probably the simplest way is to merge the two data.frames first. ?See > the merge() function. ?After merging, then do your reordering on the > merged data.frame. I should have mentioned that the more "Bioconductor" way of doing this is to combine these two data frames into an "ExpressionSet" object with the probe information in the featureData() slot and the expression values in the assayData. Then, ordering things, subsetting things, etc., is fairly straightforward and less error-prone. Sean
ADD REPLY
0
Entering edit mode
Hi Sean, Great. Actually I already got it working with the merge function. Thanks a lot. I was breaking my head the whole afternoon! I will also try the ExpressionSet approach. Thanks again. Sincerely, Hari On Tue, Sep 29, 2009 at 4:36 PM, Sean Davis <seandavi@gmail.com> wrote: > On Tue, Sep 29, 2009 at 3:47 PM, Sean Davis <seandavi@gmail.com> wrote: > > On Tue, Sep 29, 2009 at 3:39 PM, Hari Easwaran <hariharan.pe@gmail.com> > wrote: > >> Hi all, > >> I have another question with handling dataframes. > >> I have a dataframe with the 1-st column as probenames (agilent) and the > >> remaining columns are the intensity values from multiple samples. I want > to > >> order this table such that the order of the probenames correspond to the > >> order of the genes on the chromosome. To do this I have another table > which > >> has teh probenames in this order. > > > > Probably the simplest way is to merge the two data.frames first. See > > the merge() function. After merging, then do your reordering on the > > merged data.frame. > > I should have mentioned that the more "Bioconductor" way of doing this > is to combine these two data frames into an "ExpressionSet" object > with the probe information in the featureData() slot and the > expression values in the assayData. Then, ordering things, subsetting > things, etc., is fairly straightforward and less error-prone. > > Sean > [[alternative HTML version deleted]]
ADD REPLY

Login before adding your answer.

Traffic: 597 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