Bioconductor Digest, Vol 79, Issue 24
1
0
Entering edit mode
Hari Easwaran ▴ 240
@hari-easwaran-3510
Last seen 8.9 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]]
• 630 views
ADD COMMENT
0
Entering edit mode
Tim Triche ★ 4.2k
@tim-triche-3561
Last seen 3.6 years ago
United States
Let's call your two data frames 'probe.ordered.df' and 'chrom.ordered.df'. Ordering the rows of the first to match the second: reordered.df <- probe.ordered.df[ match(chrom.ordered.df$probename, probe.ordered.df$probename), ] Or you could do this in-place: probe.ordered.df <- probe.ordered.df[match(chrom.ordered.df$probename,probe.ordered.df$pro bename),] Why not just use that first column as the row names for your intensity matrix/dataframe? Sorting is still easy: reordered.df <- probe.ordered.df[ match(chrom.ordered.df$probename, rownames(probe.ordered.df), ] But things like imputation, PCA, etc. are a lot easier if you have a matrix of numeric values (with perhaps some NAs mixed in). On Tue, Sep 29, 2009 at 12:37 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. > 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@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > -- Statisticians, like artists, have a bad habit of falling in love with their models. --George Box [[alternative HTML version deleted]]
ADD COMMENT

Login before adding your answer.

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