fmerge {GMRP} | R Documentation |
fmerg can be used to merge two GWAS result data sheets with the same key ID(SNP ID)
into one data sheet.
fmerge(fl1, fl2,ID1, ID2, A, B, method)
fl1 |
R object: data file 1 |
fl2 |
R object: data file 2 |
ID1 |
key id (SNP ID such as rsid) in file 1 |
ID2 |
key id (SNP ID such as rsid) in file 2 |
A |
postfix for file 1: A=".W1". W1 may be any identifier in file 1. Default is A="". |
B |
postfix for file 2: B=".W2". W2 may be any identifier in file2. Default is B="". |
method |
method for merging. See details. |
fl1 and fl2 are two GWAS result data files from different studies or with different risk variables. They contain SNPID
, hg18
, hg19
(positions), beta values, allele, frequency, and so on. The method has four options: method="No","NO" or "no" means that all data with unmatch SNP
s are not saved in the merged file; method="All","ALL" or "all" lets fmerge save all the data with unmatched SNP
s from two files but they are not paired one-by-one. This is
different from R merge function. method="file1" will save the data with unmatched SNP
s only from file 1 in the merged file and method="file2" allows function fmerge to save the data with unmatched SNP
s from file2 in the merged file.
Return a joined data sheet.
Function fmerg can also be applied to the other types of data.
Yuan-De Tan tanyuande@gmail.com
data1<-matrix(NA,20,4) data2<-matrix(NA,30,7) SNPID1<-paste("rs",seq(1:20),sep="") SNPID2<-paste("rs",seq(1:30),sep="") data1[,1:4]<-c(round(runif(20),4),round(runif(20),4),round(runif(20),4),round(runif(20),4)) data2[,1:4]<-c(round(runif(30),4),round(runif(30),4),round(runif(30),4),round(runif(30),4)) data2[,5:7]<-c(round(seq(30)*runif(30),4),round(seq(30)*runif(30),4),seq(30)) data1<-cbind(SNPID1,as.data.frame(data1)) data2<-cbind(SNPID2,as.data.frame(data2)) dim(data1) dim(data2) colnames(data1)<-c("SNP","var1","var2","var3","var4") colnames(data2)<-c("SNP","var1","var2","var3","var4","V1","V2","V3") data12<-fmerge(fl1=data1,fl2=data2,ID1="SNP",ID2="SNP",A=".dat1",B=".dat2",method="No") #data12[1:3,] # SNP.dat1 var1.dat1 var2.dat1 var3.dat1 var4.dat1 SNP.dat2 var1.dat2 var2.dat2 #1 rs1 0.9152 0.9853 0.9879 0.9677 rs1 0.5041 0.5734 #2 rs10 0.3357 0.116 0.3408 0.1867 rs10 0.9147 0.9294 #3 rs11 0.8004 0.8856 0.2236 0.4642 rs11 0.9262 0.5831 # var3.dat2 var4.dat2 V1 V2 V3 #1 0.4933 0.6766 0.1864 0.6836 1 #2 0.4104 0.1327 3.2192 1.4166 10 #3 0.8541 0.6228 1.1803 1.9044 11