Why the rm? OP's commands do not show an existing file by that name.
Hello,
I am trying to merge multiple bed bim fam files (each chromosome has separate file) into one file.
plink --allow-no-sex --bfile XX.chr1 --merge-list mylist.txt --make-bed --out XX.ch1-22
This does not work.
mylist.txt contains:
XX.chr2.bed XX.chr2.bim XX.chr2.fam
XX.chr3.bed XX.chr3.bim XX.chr3.fam
XX.chr4.bed XX.chr4.bim XX.chr4.fam
...
XX.chr22.bed XX.chr22.bim XX.chr22.fam
Thank you in advance!
3 answers
Here is the solution:
Be careful, before you merge different plink files, check the duplicate SNPs and remove them! and You'd better remove non-ATCG variants before merging, such as . in the dataset. Here, suppose you have chr1, chr2 .... and want to merge them.
chr1.bed
chr1.bim
chr1.fam
chr2.bed
chr2.bim
chr2.fam
....
rm mergelist.txt
for i in {1..22}
do
echo chr$i >> mergelist.txt
done
plink --merge-list mergelist.txt --make-bed --out G1000plink
What is in there that justifies your rm command?
Hi Ram, I believe the "rm mergelist.txt" is there so that it removes the mergelist.txt INCASE that file is already in existence. This code requires you to not have a mergelist.txt OR to have an empty mergelist.txt. So by "rm mergelist.txt", you make sure that the file doesn't exist prior to running your code.
If mergelist.txt does not exist, depending on other settings, there might be anything between a warning and script failure. Either test and remove, or use something like
seq 1 22 | xargs -I _num echo chr_num >mergelist.txt
so it overwrites any existing content. parallel > xargs > for and scripting an non-interactive careless rm can be dangerous.
Hi, it seems I just solved my problem on this issue. It may worth to check the file path in your merge-list text file, which means you need to make sure each path is really directed to the corresponding bed/bim/fam file, not just the file name, but the completed path to it. Hope it helps. Xiao
Log in to answer this question.
Is plink giving you an error? Otherwise, please define "does not work".
Yes, it says that "cannot open the file XX.chr2.fam". What would you think is wrong?
Does that file exist?
Yes. I changed the txt file to csv file, but it still says "Error: Failed to open XX.chr2.fam."
Message is as below... What would you think is wrong??
@khn How did you solve this problem? I am also new to plink. I am facing the same problem. How can we merge multiple binary files of different chromosomes using plink?
I have a similar trouble, but it seems to be different.
After conduct of command described in this page,
were generated, and no
XX.ch1-22-merge.bedXX.ch1-22-merge.bim.Is there any solutions?
Please use
ADD COMMENTand not the answer field. This is reserved for answers and helps to keep the thread organized. Thanks.