[R] matching doesn't work

Rasmus Liland jen@r@@mu@ @end|ng |rom gm@||@com
Fri Apr 10 23:24:16 CEST 2020


On 2020-04-10 15:38 -0500, Ana Marija wrote:
| Hi,
| 
| I have this code:

Dear Ana,

none of the ID tuples in the head 
outputs you provided matches, so I added 
two lines in ibdlist that matches up;  
perhaps if you provided more lines that 
would have matched in a pastebin 
somewhere ...


options(stringsAsFactors=FALSE)
plink.genome <-
"FID1	IID1	FID2	IID2	RT	EZ	Z0	Z1	Z2	PI_HAT	PHE	DST
fam1054	G1054	fam1054	G700	OT	0	0.0045	0.9938	0.0017	0.4986	-1	0.839150
fam1054	G1054	fam1054	G701	OT	0	0.0000	1.0000	0.0000	0.5000	-1	0.838381
fam1079	G1079	fam2484	G2484	UN		0.0000	0.0007	0.9993	0.9997	-1	0.999889
fam1245	G1237	fam1245	G1245	OT	0	0.0036	0.9964	0.0000	0.4982	-1	0.838770
fam1245	G1241	fam1245	G1245	OT	0	0.0042	0.9854	0.0104	0.5031	-1	0.840569
fam0176	G174	fam0176	G176	OT	0	0.0000	1.0000	0.0000	0.5000	-1	0.837799"

plink.genome <-
read.delim(text=plink.genome, header=TRUE)

ibdlist <-
"ID1	ID2	k0	k1	kinship
G1000	G1001	1.0000000	0.00000000	0.000000000
G1000	G1003	0.9938901	0.00000000	0.003054932
G1241	G1245	1.0000000	0.00000000	0.000000000
G1000	G1005	1.0000000	0.00000000	0.000000000
G1079	G2484	0.9938901	0.00000000	0.003054932
G1000	G1009	1.0000000	0.00000000	0.000000000"
ibdlist <-
read.delim(text=ibdlist)

idx <-
match(paste(plink.genome$IID1, plink.genome$IID2),
  paste(ibdlist$ID1, ibdlist$ID2))
plink.genome[idx,]


See if this fits the rest of your 
data.frames ...  Did I nail it here, or?  

Best,
Rasmus



More information about the R-help mailing list