[R] some help regarding combining columns from different files

Harikrishnadhar hari.bombex at gmail.com
Tue Jan 12 22:48:36 CET 2010


Hi Jim,

I am want to merge two files into one file :

Here is my code . But the problem with this is that I am getting the 2nd
file appended to the first when i write temp3 in my code to the text file. I
am not sure what mistake I am doing .

also find the test files to run the code .

Please help me with this !!!!!!!!!!!!!!!!!!!!!!!

temp1 <- NULL
temp2 <- NULL
x.col.names <-c("genesymbol","geneDescription","orgSymbol","orgName")
y.col.names <- c("genesymbol","geneDescription","orgSymbol","orgName")
for (i in 1:length(list1.bp.files.names)){
    temp1 <-
read.table(list1.bp.files.names[i],sep="\t",header=T,stringsAsFactors=F,quote="\"")
  for (j in 1:length(list2.bp.files.names)){
     temp2 <-
read.table(list2.bp.files.names[j],sep="\t",header=T,stringsAsFactors=F,quote="\"")
    temp3 <- merge(temp1,temp2,by.x = x.col.names,by.y=y.col.names,all=T)
    myfile<-gsub("( )", "", paste("1_",merge.bp.files.names[i],".txt"))
    write.table(temp3,file=myfile,sep="\t",quote=FALSE,row.names=F)
  }
 }
Thanks
--Hari--
-------------- next part --------------
genesymbol	geneDescription	orgSymbol	orgName
E2f5 	 e2f transcription factor 5  	 RG  	 Rattus norvegicus
Msh2 	muts homolog 2 (e. coli) 	RG 	Rattus norvegicus
Kpna2 	karyopherin (importin) alpha 2 	RG 	Rattus norvegicus
Gtpbp4 	gtp binding protein 4 	RG 	Rattus norvegicus
Dtymk_predicted 	deoxythymidylate kinase (predicted) 	RG 	Rattus norvegicus
Ruvbl1 	ruvb-like protein 1 	RG 	Rattus norvegicus
Cetn2 	centrin 2 	RG 	Rattus norvegicus
Foxm1 	forkhead box m1 	RG 	Rattus norvegicus
Abtb1 	ankyrin repeat and btb (poz) domain containing 1 	RG 	Rattus norvegicus
Myc 	myelocytomatosis viral oncogene homolog (avian) 	RG 	Rattus norvegicus
Il1b 	interleukin 1 beta 	RG 	Rattus norvegicus
Cdc20 	cell division cycle 20 homolog (s. cerevisiae) 	RG 	Rattus norvegicus
Cdc25a 	cell division cycle 25 homolog a (s. cerevisiae) 	RG 	Rattus norvegicus
Kifc1 	kinesin family member c1 	RG 	Rattus norvegicus
Fancd2 	fanconi anemia d2 protein 	RG 	Rattus norvegicus
Rhob 	rhob gene 	RG 	Rattus norvegicus
Clp1 	cardiac lineage protein 1 	RG 	Rattus norvegicus
Psmd1 	proteasome (prosome, macropain) 26s subunit, non-atpase, 1 	RG 	Rattus norvegicus
Mad2l1_predicted 	mad2 (mitotic arrest deficient, homolog)-like 1 (yeast) (predicted) 	RG 	Rattus norvegicus
Dhcr24 	24-dehydrocholesterol reductase 	RG 	Rattus norvegicus
Ahr 	aryl hydrocarbon receptor 	RG 	Rattus norvegicus
Rnd3 	ras homolog gene family, member e 	RG 	Rattus norvegicus
Acvr1b 	activin a receptor, type 1b 	RG 	Rattus norvegicus
Mcm2_predicted 	minichromosome maintenance deficient 2 mitotin (s. cerevisiae) (predicted) 	RG 	Rattus norvegicus
Mapre3 	microtubule-associated protein, rp/eb family, member 3 	RG 	Rattus norvegicus
Mapre1 	microtubule-associated protein, rp/eb family, member 1 	RG 	Rattus norvegicus
Tardbp 	tar dna binding protein 	RG 	Rattus norvegicus
Cdca3 	cell division cycle associated 3 	RG 	Rattus norvegicus
Ccnb1 	cyclin b1 	RG 	Rattus norvegicus
Npm1 	nucleophosmin 1 	RG 	Rattus norvegicus
Pcaf 	p300/cbp-associated factor 	RG 	Rattus norvegicus
Cdc2a 	cell division cycle 2 homolog a (s. pombe) 	RG 	Rattus norvegicus
Dnajc2 	dnaj (hsp40) homolog, subfamily c, member 2 	RG 	Rattus norvegicus
Dab2ip 	disabled homolog 2 (drosophila) interacting protein 	RG 	Rattus norvegicus
Id2 	inhibitor of dna binding 2, dominant negative helix-loop-helix protein 	RG 	Rattus norvegicus
Kif23_predicted 	kinesin family member 23 (predicted) 	RG 	Rattus norvegicus
Nek6 	nima (never in mitosis gene a)-related expressed kinase 6 	RG 	Rattus norvegicus
Pola1 	polymerase (dna directed), alpha 1 	RG 	Rattus norvegicus
Il1a 	interleukin 1 alpha 	RG 	Rattus norvegicus
Ccnc 	cyclin c 	RG 	Rattus norvegicus
Ccnb2 	cyclin b2 	RG 	Rattus norvegicus
Pbef1 	pre-b-cell colony enhancing factor 1 	RG 	Rattus norvegicus
Rad17 	rad17 homolog (s. pombe) 	RG 	Rattus norvegicus
Racgap1_predicted 	rac gtpase-activating protein 1 (predicted) 	RG 	Rattus norvegicus
Ccna2 	cyclin a2 	RG 	Rattus norvegicus
Cdca8 	cell division cycle associated 8 	RG 	Rattus norvegicus
Sesn1_predicted 	sestrin 1 (predicted) 	RG 	Rattus norvegicus
Tpx2_predicted 	tpx2, microtubule-associated protein homolog (xenopus laevis) (predicted) 	RG 	Rattus norvegicus
Dmtf1 	cyclin d binding myb-like transcription factor 1 	RG 	Rattus norvegicus
Chek1 	checkpoint kinase 1 homolog (s. pombe) 	RG 	Rattus norvegicus
Mlh1 	mutl homolog 1 (e. coli) 	RG 	Rattus norvegicus
Cgref1 	cell growth regulator with ef hand domain 1 	RG 	Rattus norvegicus
Nek2 	nima (never in mitosis gene a)-related expressed kinase 2 	RG 	Rattus norvegicus
Tbrg1 	transforming growth factor beta regulated gene 1 	RG 	Rattus norvegicus
Kif2c 	kinesin-related protein 2 	RG 	Rattus norvegicus
Akap8 	a kinase (prka) anchor protein 8 	RG 	Rattus norvegicus
Zw10 	zw10 homolog, centromere/kinetochore protein (drosophila) 	RG 	Rattus norvegicus
Fabp1 	fatty acid binding protein 1, liver 	RG 	Rattus norvegicus
Pa2g4 	proliferation-associated 2g4 	RG 	Rattus norvegicus
Myh9 	myosin, heavy polypeptide 9 	RG 	Rattus norvegicus
Mdc1 	mediator of dna damage checkpoint 1 	RG 	Rattus norvegicus
Cdk2 	cyclin dependent kinase 2 	RG 	Rattus norvegicus
Steap3 	tumor suppressor phyde 	RG 	Rattus norvegicus
Vegfa 	vascular endothelial growth factor a 	RG 	Rattus norvegicus
Gadd45a 	growth arrest and dna-damage-inducible 45 alpha 	RG 	Rattus norvegicus
Anp32b 	acidic nuclear phosphoprotein 32 family, member b 	RG 	Rattus norvegicus
Cdk4 	cyclin-dependent kinase 4 	RG 	Rattus norvegicus
Bub1_predicted 	budding uninhibited by benzimidazoles 1 homolog (s. cerevisiae) (predicted) 	RG 	Rattus norvegicus
Cdkn1a 	cyclin-dependent kinase inhibitor 1a 	RG 	Rattus norvegicus
Uhrf1 	ubiquitin-like, containing phd and ring finger domains, 1 (mapped) 	RG 	Rattus norvegicus
Tcf3_predicted 	transcription factor 3 (predicted) 	RG 	Rattus norvegicus
Snf1lk 	snf1-like kinase 	RG 	Rattus norvegicus
Stmn1 	stathmin 1 	RG 	Rattus norvegicus
Eml4_predicted 	echinoderm microtubule associated protein like 4 (predicted) 	RG 	Rattus norvegicus
Cenpe_predicted 	centromere protein e (predicted) 	RG 	Rattus norvegicus
Ppm1g 	protein phosphatase 1g (formerly 2c), magnesium-dependent, gamma isoform 	RG 	Rattus norvegicus
Hgf 	hepatocyte growth factor 	RG 	Rattus norvegicus
Mapk14 	mitogen activated protein kinase 14 	RG 	Rattus norvegicus
Nbn 	nibrin 	RG 	Rattus norvegicus
Ccnl1 	cyclin l1 	RG 	Rattus norvegicus
E2f1 	e2f transcription factor 1 	RG 	Rattus norvegicus
Nasp 	nuclear autoantigenic sperm protein 	RG 	Rattus norvegicus
Bmp2 	bone morphogenetic protein 2 	RG 	Rattus norvegicus
Bard1 	brca1 associated ring domain 1 	RG 	Rattus norvegicus
Acvr1 	activin a receptor, type 1 	RG 	Rattus norvegicus
Xpc_predicted 	xeroderma pigmentosum, complementation group c (predicted) 	RG 	Rattus norvegicus
Cdc26 	cell division cycle 26 	RG 	Rattus norvegicus
Ptp4a1 	protein tyrosine phosphatase 4a1 	RG 	Rattus norvegicus
Ttk_predicted 	ttk protein kinase (predicted) 	RG 	Rattus norvegicus
-------------- next part --------------
genesymbol	geneDescription	orgSymbol	orgName
Fdft1 	 farnesyl diphosphate farnesyl transferase 1  	 RG  	 Rattus norvegicus
Sc4mol 	sterol-c4-methyl oxidase-like 	RG 	Rattus norvegicus
Fbp1 	fructose-1,6- biphosphatase 1 	RG 	Rattus norvegicus
Acat2 	similar to acetyl coa transferase-like 	RG 	Rattus norvegicus
Impa1 	inositol (myo)-1(or 4)-monophosphatase 1 	RG 	Rattus norvegicus
Pmm2_predicted 	phosphomannomutase 2 (predicted) 	RG 	Rattus norvegicus
G6pc 	glucose-6-phosphatase, catalytic 	RG 	Rattus norvegicus
Pklr 	pyruvate kinase, liver and red blood cell 	RG 	Rattus norvegicus
Apoa2 	apolipoprotein a-ii 	RG 	Rattus norvegicus
Tgfb2 	transforming growth factor, beta 2 	RG 	Rattus norvegicus
Gpi 	glucose phosphate isomerase 	RG 	Rattus norvegicus
Ca5a 	carbonic anhydrase 5 	RG 	Rattus norvegicus
Irs2 	insulin receptor substrate 2 	RG 	Rattus norvegicus
Insig2 	insulin induced gene 2 	RG 	Rattus norvegicus
Dgat2 	diacylglycerol o-acyltransferase homolog 2 (mouse) 	RG 	Rattus norvegicus
Dhcr7 	7-dehydrocholesterol reductase 	RG 	Rattus norvegicus
Sphk2 	sphingosine kinase 2 	RG 	Rattus norvegicus
Cpt1a 	carnitine palmitoyltransferase 1, liver 	RG 	Rattus norvegicus
Tm7sf2 	transmembrane 7 superfamily member 2 	RG 	Rattus norvegicus
Sds 	serine dehydratase 	RG 	Rattus norvegicus
Idi1 	isopentenyl-diphosphate delta isomerase 	RG 	Rattus norvegicus
Chdh 	choline dehydrogenase 	RG 	Rattus norvegicus
Comt 	catechol-o-methyltransferase 	RG 	Rattus norvegicus
Aldoa 	aldolase a 	RG 	Rattus norvegicus
Acaa2 	acetyl-coenzyme a acyltransferase 2 (mitochondrial 3-oxoacyl-coenzyme a thiolase) 	RG 	Rattus norvegicus
Igfbp1 	insulin-like growth factor binding protein 1 	RG 	Rattus norvegicus
Dlat 	dihydrolipoamide s-acetyltransferase (e2 component of pyruvate dehydrogenase complex) 	RG 	Rattus norvegicus
Mdh1 	malate dehydrogenase 1, nad (soluble) 	RG 	Rattus norvegicus
Pkm2 	pyruvate kinase, muscle 	RG 	Rattus norvegicus
Man2b1 	mannosidase 2, alpha b1 	RG 	Rattus norvegicus
Pcyt2 	phosphate cytidylyltransferase 2, ethanolamine 	RG 	Rattus norvegicus
Aldh2 	aldehyde dehydrogenase 2 	RG 	Rattus norvegicus
Ddc 	dopa decarboxylase 	RG 	Rattus norvegicus
Prkaa1 	protein kinase, amp-activated, alpha 1 catalytic subunit 	RG 	Rattus norvegicus
Pdk2 	pyruvate dehydrogenase kinase, isoenzyme 2 	RG 	Rattus norvegicus
Pmvk 	phosphomevalonate kinase 	RG 	Rattus norvegicus
Mvd 	mevalonate (diphospho) decarboxylase 	RG 	Rattus norvegicus
Ugp2 	udp-glucose pyrophosphorylase 2 	RG 	Rattus norvegicus
Pctp 	phosphatidylcholine transfer protein 	RG 	Rattus norvegicus
Atf3 	activating transcription factor 3 	RG 	Rattus norvegicus
Dhtkd1 	dehydrogenase e1 and transketolase domain containing 1 	RG 	Rattus norvegicus
Gata3 	gata binding protein 3 	RG 	Rattus norvegicus
Ippk 	similar to chromosome 9 open reading frame 12; 1,3,4,5,6-pentakisphosphate 2-kinase 	RG 	Rattus norvegicus
Ywhah 	tyrosine 3-monooxygenase/tryptophan 5-monooxygenase activation protein, eta polypeptide 	RG 	Rattus norvegicus
Aldh5a1 	aldehyde dehydrogenase family 5, subfamily a1 	RG 	Rattus norvegicus
Hmgcs1 	3-hydroxy-3-methylglutaryl-coenzyme a synthase 1 	RG 	Rattus norvegicus
Sult1b1 	sulfotransferase family 1b, member 1 	RG 	Rattus norvegicus
Ugdh 	udp-glucose dehydrogenase 	RG 	Rattus norvegicus
Hmgcs2 	3-hydroxy-3-methylglutaryl-coenzyme a synthase 2 	RG 	Rattus norvegicus
Sec14l2 	sec14-like 2 (s. cerevisiae) 	RG 	Rattus norvegicus
Gck 	glucokinase 	RG 	Rattus norvegicus
Ch25h 	cholesterol 25-hydroxylase 	RG 	Rattus norvegicus
Hsd17b7 	hydroxysteroid (17-beta) dehydrogenase 7 	RG 	Rattus norvegicus
Crem 	camp responsive element modulator 	RG 	Rattus norvegicus
Tat 	tyrosine aminotransferase 	RG 	Rattus norvegicus
Ldha 	lactate dehydrogenase a 	RG 	Rattus norvegicus
Coq7 	demethyl-q 7 	RG 	Rattus norvegicus
-------------- next part --------------
genesymbol	geneDescription	orgSymbol	orgName
E2f5 	 e2f transcription factor 5  	 RG  	 Rattus norvegicus
Aatf 	apoptosis antagonizing transcription factor 	RG 	Rattus norvegicus
Numa1 	nuclear mitotic apparatus protein 1 	RG 	Rattus norvegicus
RGD1305526_predicted 	similar to sperm 1 pou-domain transcription factor (sprm-1) (predicted) 	RG 	Rattus norvegicus
Kpna2 	karyopherin (importin) alpha 2 	RG 	Rattus norvegicus
Anapc4 	anaphase promoting complex subunit 4 	RG 	Rattus norvegicus
Gtpbp4 	gtp binding protein 4 	RG 	Rattus norvegicus
Mki67_predicted 	antigen identified by monoclonal antibody ki-67 (predicted) 	RG 	Rattus norvegicus
Brca1 	hypothetical gene supported by nm_012514 	RG 	Rattus norvegicus
Cited2 	cbp/p300-interacting transactivator, with glu/asp-rich carboxy-terminal domain, 2 	RG 	Rattus norvegicus
Rbl2 	retinoblastoma-like 2 	RG 	Rattus norvegicus
Ppp2ca 	protein phosphatase 2a, catalytic subunit, alpha isoform 	RG 	Rattus norvegicus
Aurkb 	aurora kinase b 	RG 	Rattus norvegicus
RGD1307084 	family with sequence similarity 33, member a 	RG 	Rattus norvegicus
Brip1_predicted 	brca1 interacting protein c-terminal helicase 1 (predicted) 	RG 	Rattus norvegicus
Ccng2_predicted 	cyclin g2 (predicted) 	RG 	Rattus norvegicus
Tgfb2 	transforming growth factor, beta 2 	RG 	Rattus norvegicus
Tubg1 	tubulin, gamma 1 	RG 	Rattus norvegicus
Gnl3 	guanine nucleotide binding protein-like 3 (nucleolar) 	RG 	Rattus norvegicus
Keg1 	kidney expressed gene 1 	RG 	Rattus norvegicus
Cgrrf1 	cell growth regulator with ring finger domain 1 	RG 	Rattus norvegicus
Gtf2h1_predicted 	general transcription factor ii h, polypeptide 1 (predicted) 	RG 	Rattus norvegicus
Cetn3 	centrin 3 	RG 	Rattus norvegicus
Mphosph1_predicted 	m-phase phosphoprotein 1 (predicted) 	RG 	Rattus norvegicus
Prc1_predicted 	protein regulator of cytokinesis 1 (predicted) 	RG 	Rattus norvegicus
Flcn 	folliculin 	RG 	Rattus norvegicus
Map2k6 	mitogen-activated protein kinase kinase 6 	RG 	Rattus norvegicus
Calr 	calreticulin 	RG 	Rattus norvegicus
MGC112830 	similar to transcription factor 	RG 	Rattus norvegicus
Fgf1 	fibroblast growth factor 1 	RG 	Rattus norvegicus
Top3a_predicted 	topoisomerase (dna) iii alpha (predicted) 	RG 	Rattus norvegicus
Egfr 	epidermal growth factor receptor 	RG 	Rattus norvegicus
Grlf1_predicted 	glucocorticoid receptor dna binding factor 1 (predicted) 	RG 	Rattus norvegicus
Itgb1 	integrin beta 1 (fibronectin receptor beta) 	RG 	Rattus norvegicus
Dnaja2 	dnaj (hsp40) homolog, subfamily a, member 2 	RG 	Rattus norvegicus
Cep55 	similar to chromosome 10 open reading frame 3 	RG 	Rattus norvegicus
Dlg7_predicted 	discs, large homolog 7 (drosophila) (predicted) 	RG 	Rattus norvegicus
Pdgfc 	platelet-derived growth factor, c polypeptide 	RG 	Rattus norvegicus
Npm1 	nucleophosmin 1 	RG 	Rattus norvegicus
Lig3 	ligase iii, dna, atp-dependent 	RG 	Rattus norvegicus
Psmd13_predicted 	proteasome (prosome, macropain) 26s subunit, non-atpase, 13 (predicted) 	RG 	Rattus norvegicus
Ccnf 	cyclin f 	RG 	Rattus norvegicus
Cenpf 	centromere autoantigen f 	RG 	Rattus norvegicus
Ppp2cb 	protein phosphatase 2a, catalytic subunit, beta isoform 	RG 	Rattus norvegicus
Rad51l3_predicted 	rad51-like 3 (s. cerevisiae) (predicted) 	RG 	Rattus norvegicus
Ccng1 	cyclin g1 	RG 	Rattus norvegicus
Btg3 	b-cell translocation gene 3 	RG 	Rattus norvegicus
Gmnn_predicted 	geminin (predicted) 	RG 	Rattus norvegicus
Gspt1 	g1 to s phase transition 1 	RG 	Rattus norvegicus
Cdc27 	cell division cycle 27 homolog (s. cerevisiae) 	RG 	Rattus norvegicus
Wee1 	wee 1 homolog (s. pombe) 	RG 	Rattus norvegicus
Ccnb2 	cyclin b2 	RG 	Rattus norvegicus
Nde1 	nuclear distribution gene e homolog 1 (a nidulans) 	RG 	Rattus norvegicus
Ranbp1_predicted 	ran binding protein 1 (predicted) 	RG 	Rattus norvegicus
Ptpn11 	protein tyrosine phosphatase, non-receptor type 11 	RG 	Rattus norvegicus
Ccdc5 	coiled-coil domain containing 5 	RG 	Rattus norvegicus
Prmt5_predicted 	skb1 homolog (s. pombe) (predicted) 	RG 	Rattus norvegicus
RGD1309522 	similar to hypothetical protein flj22624 	RG 	Rattus norvegicus
Nek2 	nima (never in mitosis gene a)-related expressed kinase 2 	RG 	Rattus norvegicus
Junb 	jun-b oncogene 	RG 	Rattus norvegicus
Cdc25c_predicted 	cell division cycle 25 homolog c (s. cerevisiae) (predicted) 	RG 	Rattus norvegicus
Kntc1_predicted 	kinetochore associated 1 (predicted) 	RG 	Rattus norvegicus
Plk1 	polo-like kinase 1 (drosophila) 	RG 	Rattus norvegicus
Inhba 	inhibin beta-a 	RG 	Rattus norvegicus
Rad1_predicted 	rad1 homolog (s. pombe) (predicted) 	RG 	Rattus norvegicus
Ccne1 	cyclin e 	RG 	Rattus norvegicus
Kif22 	kinesin family member 22 	RG 	Rattus norvegicus
Gadd45g 	growth arrest and dna-damage-inducible 45 gamma 	RG 	Rattus norvegicus
Sugt1 	sgt1, suppressor of g2 allele of skp1 (s. cerevisiae) 	RG 	Rattus norvegicus
Cdkn3_predicted 	cyclin-dependent kinase inhibitor 3 (predicted) 	RG 	Rattus norvegicus
Pbk_predicted 	pdz binding kinase (predicted) 	RG 	Rattus norvegicus
Pttg1 	pituitary tumor-transforming 1 	RG 	Rattus norvegicus
Kif11 	kinesin-like 1 	RG 	Rattus norvegicus
Ccnd1 	cyclin d1 	RG 	Rattus norvegicus
Casp3 	caspase 3, apoptosis related cysteine protease 	RG 	Rattus norvegicus
Rpa1 	replication protein a1 	RG 	Rattus norvegicus
Bccip_predicted 	brca2 and cdkn1a interacting protein (predicted) 	RG 	Rattus norvegicus
-------------- next part --------------
genesymbol	geneDescription	orgSymbol	orgName
Adh7 	 alcohol dehydrogenase 7 (class iv), mu or sigma polypeptide  	 RG  	 Rattus norvegicus
Adh1 	alcohol dehydrogenase 1 	RG 	Rattus norvegicus
Adh4 	alcohol dehydrogenase 4 (class ii), pi polypeptide 	RG 	Rattus norvegicus


More information about the R-help mailing list