Reputation: 133
I have a gene expression data set (myfirst_df) that has 259 columns (samples) and also I have another data set (mysecond_df) that include 100 rows. I would like to select and extract these 100 rows from 259 samples in the first data set. All 100 samples in mysecond_df are in 259 samples in myfirst_df. I need to guide at the code level for doing this task. I write my code in the R language.
Myfirst_df
sample1 sample2 sample3 sample4 sample5 … sample259
gene1
gene2
.
.
.
Gene50000
mysecond_df
col1 col2 col3 col4 col5 ….. col40
sample1
sample4
sample9
sample13
.
.
sample100
My Favorite dataset
sample1 sample4 sample9 sample13 … sample100
gene1
gene2
.
.
.
Gene50000
Upvotes: 0
Views: 38
Reputation: 11981
try something like this:
mysamples <- mysecond_df[,1]
or if sample1, sample4,..
are row.names then
mysamples <- rownames(mysecond_df)
Afterwards
Myfirst_df[, mysamples]
should give the desired result.
Upvotes: 1