Question: merge two csv files in r (gene to protein pathways)
0
gravatar for pnixsweet
5.0 years ago by
pnixsweet0
pnixsweet0 wrote:

How can i read in two tab delimited files and map them together by one common column(protein) ? 

protein_pathway.txt

Pathway

Protein

Binding and Uptake of Ligands by Scavenger Receptors

P69905

Erythrocytes take up carbon dioxide and release oxygen

P69905

Metabolism

P69905

Amyloids

P02647

Metabolism

P02647

Hemostasis

P68871

 

protein_gene.txt

Gene

Protein

Fabp3

P11404

HBA1

P69905

APOA1

P02647

Hbb-b1

P02088

HBB

P68871

Hba

P01942

 

  datafile1 <- read.csv("c:/gene.csv", header=T, sep=",")
  datafile2 <- read.csv("c:/pathway.csv", header=T, sep=",")

  dim(datafile1)
  dim(datafile2)

  datafile <- rbind(datafile1,datafile2)
  dim(datafile)

  write.csv(datafile,"c:/datafile.csv")

 

This only gives me the merged (appended one). How can map by a common column protein here? 

 

R • 2.8k views
ADD COMMENTlink modified 2.9 years ago by tarmowow10 • written 5.0 years ago by pnixsweet0
2
gravatar for Devon Ryan
5.0 years ago by
Devon Ryan93k
Freiburg, Germany
Devon Ryan93k wrote:

help(match)

ADD COMMENTlink written 5.0 years ago by Devon Ryan93k
2

and help(merge) if you want to to it like a database join

ADD REPLYlink written 5.0 years ago by David W4.7k
2

And when merge() gets slow due to absolutely huge datasets:

library(dplyer)
help(left_join)
ADD REPLYlink written 5.0 years ago by Devon Ryan93k
1
gravatar for tarmowow
2.9 years ago by
tarmowow10
tarmowow10 wrote:

Merge them by using http://merge-csv.com. You can remove dupcliate headers also.

ADD COMMENTlink written 2.9 years ago by tarmowow10
0
gravatar for zx8754
5.0 years ago by
zx87548.7k
London
zx87548.7k wrote:

Use merge:

datafile <-  merge(datafile1, datafile2)

http://www.statmethods.net/management/merging.html

ADD COMMENTlink modified 5.0 years ago • written 5.0 years ago by zx87548.7k
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: 2373 users visited in the last hour