Quick Way To Combine Two Datasets Using Only Common Markers

Quick Way To Combine Two Datasets Using Only Common Markers

6

Is there a quick way to combine two datasets so that only the common markers are kept? Currently, if I have two datasets, I have to first get the intersection of the two BIM/MAP files, then extract those markers for each dataset, then merge the two.

The merge-mode doesn’t seem to have the option I’m looking for either


plink

• 16k views

Hi I suggest to combine R & Plink this way:

> R code:
> map2 = read.delim("file2.map", header=F, quote="")
> map1 = read.delim("file1.map", header=F, quote="")
> common.snps = which(map2$V2 %in% map1$V2)
> write.table(map2$V2[common.snps], file="list.snps", sep="t", col.names=F, row.names=F, quote=F )

and finally

> the Plink commands:
> plink --bfile <file1> --extract list.snps --make-bed --out data1
> plink --bfile <file2> --extract list.snps --make-bed --out data2
> plink --bfile data1 --bmerge data2.bed data2.bim data2.fam --make-bed --out merge

Why don’t you figure out the common snps between the two datasets using a shell command (awk) or a R one-liner. You can then reduce each of those datasets to the same set of SNPS using the “–extract” option and then merge the datasets. Also, you should check if the two datasets have the same build.

8.8 years ago by


Joey

&utrif;

410

I would do this in R (as you can do this for an infinite number of sets by doing an intersection of the intersection…)

common.snps <- intersect(map1$V2, map2$V2)
write.table(common.snps, file = "common_snps.txt", sep ="t", col.names = FALSE, row.names = FALSE, quote = FALSE )

–write-snplist + –extract/–make-bed lets you do this purely with plink, though the other solutions also work.

why not use plink –merge-mode 1, which would output Consensus calls.

The grep command doesn’t work for me: grep -f file1.map file2.map | cut -f2 > common_snps.txt
I use this:

sort file1.map file2.map|uniq -d > common_lines.txt
awk '{print $2}' common_lines.txt > common_snps.txt

Then use plink –extract and merge


Login
before adding your answer.

Traffic: 1624 users visited in the last hour

Read more here: Source link