Question: Breaking PLINK.bim .bed .fam files into chromosomes
2
gravatar for safiradrak
16 months ago by
safiradrak20
safiradrak20 wrote:

Hello,

I am trying to get haplotypes for one locus on chromosome19 and for that, I need phased data. However, prior to the phasing, I am supposed to split my PLINK files into separated files by chromosome. I found this script online but it doesn't work (see below). Can you please give me advice on how to do this? I am rather a newbie in the data processing so I am sorry if this is a too basic question.

Thank you!

#!/usr/bin/perl

# This script takes as input the base filename of binary pedfiles (*.bed, 
# *.bim, *.fam) and a base output filename and splits up a dataset by 
# chromosome. Useful for imputing to 1000 genomes. 

chomp(my $pwd = `pwd`); my $help = "\nUsage: $0 <BEDfile base> <output base>\n\n"; die $help if @ARGV!=2;

$infile_base=$ARGV[0]; #base filename of inputs $outfile_base=$ARGV[1]; #base filename of outputs $plink_exec="plink
--nonfounders --allow-no-sex --noweb"; $chr=22; #last chromosome to write out


for (1..$chr) {     print "Processing chromosome $_\n";     `$plink_exec
--bfile $infile_base --chr $_ --make-bed --out ${outfile_base}$_;` }
snp plink • 1.9k views
ADD COMMENTlink modified 4 months ago by augmntd4th10 • written 16 months ago by safiradrak20
3
gravatar for zx8754
16 months ago by
zx87549.7k
London
zx87549.7k wrote:

No need for scripts, simple loop should work, something like:

for chr in {1..23}; do \
plink --bfile myPlink --chr $chr --make-bed --out myPlink_${chr}; \
done
ADD COMMENTlink modified 4 months ago • written 16 months ago by zx87549.7k
1
gravatar for AK
16 months ago by
AK1.9k
AK1.9k wrote:

I think the correct format is (in case some codes are commented out):

#!/usr/bin/perl

# This script takes as input the base filename of binary pedfiles (*.bed,
# *.bim, *.fam) and a base output filename and splits up a dataset by
# chromosome. Useful for imputing to 1000 genomes.

chomp( my $pwd = `pwd` );
my $help = "\nUsage: $0 <BEDfile base> <output base>\n\n";
die $help if @ARGV != 2;

$infile_base  = $ARGV[0];    #base filename of inputs
$outfile_base = $ARGV[1];    #base filename of outputs
$plink_exec = "plink --nonfounders --allow-no-sex --noweb";
$chr = 22;                   #last chromosome to write out

for ( 1 .. $chr ) {
    print "Processing chromosome $_\n";
    `$plink_exec --bfile $infile_base --chr $_ --make-bed --out ${outfile_base}$_;`;
}
ADD COMMENTlink written 16 months ago by AK1.9k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2187 users visited in the last hour