Question: Merging of datasets from same tissue/region
0
gravatar for F
2.1 years ago by
F3.4k
Iran
F3.4k wrote:

Hi,

I have six data sets from different platforms, I annotated probs in each data to gene symbole. I want to merge them like so I have six data sets with the same gene symbols in rows. I used intertection but data sets returned NA. how to match these data?

I thought about merging one by one

merge(data1,data2,by="first col.name")

then extracting each data from merged one but that returned a data without genes in rows

when I tried to merge all

> merge=merge(data1,data2,data3,data4,data5,data6,by="ID")
Error in fix.by(by.x, x) : 
  'by' must specify one or more columns as numbers, names or logical

but all have ID in first col.name

I should merged one by one but

merged=merge(data1,data2,by="first col.name")

data1=merged[,1:43]

data2=merged[1,44:150]  gives just one observation
.

.
R • 1.1k views
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by F3.4k

To merge dataframes (DF) by row names, use DF=merge(DF1,DF2,by="row.names"). Also, you cannot merge multiple DF like this unless you store them into a list. Make a loop and iterate on each DF you want to merge or create a list of DF and use join_all function from plyr package (https://www.rdocumentation.org/packages/plyr/versions/1.8.4/topics/join_all).

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by Tom_L310

thank you,

I can exteact DF1 from DF by DF1=DF[,1:42] but for extracting DF2 ----> DF2=DF[1,43:150] gives only one observation and DF2=DF[,43:150] gives no genes in rows. how extract DF2 which contains row names also?

ADD REPLYlink modified 2.1 years ago • written 2.1 years ago by F3.4k
1

I don't understand what kind of structure do want to process and obtain. I mean, it seems like your DF is already merged so why sub-setting DF1 with the first 42 columns and DF2 with other columns but a single line?

ADD REPLYlink written 2.1 years ago by Tom_L310

because I need each of DF1 and DF1 independently

ADD REPLYlink written 2.1 years ago by F3.4k
2
gravatar for theobroma22
2.1 years ago by
theobroma221.1k
theobroma221.1k wrote:

DF2 <- DF[ , c(1, 43:150)]

ADD COMMENTlink written 2.1 years ago by theobroma221.1k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1880 users visited in the last hour