Mercurial > repos > dereeper > sniplay
changeset 15:31c23d943c29 draft default tip
Uploaded
author | dereeper |
---|---|
date | Tue, 08 Jan 2019 08:47:56 -0500 (2019-01-08) |
parents | d15869b3731a |
children | |
files | MDSplot/MDSbasedOnIBSmatrix.pl |
diffstat | 1 files changed, 19 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/MDSplot/MDSbasedOnIBSmatrix.pl Tue Jan 08 08:46:57 2019 -0500 +++ b/MDSplot/MDSbasedOnIBSmatrix.pl Tue Jan 08 08:47:56 2019 -0500 @@ -25,12 +25,10 @@ if ( !$in || !$out); -my $plink_command = $PLINK_EXE . " --file $in --noweb --cluster --matrix --mds-plot 2 --out $out >>$in.plink.log 2>&1"; +my $plink_command = $PLINK_EXE . " --vcf $in --cluster --allow-extra-chr --matrix --mds-plot 3 --out $out >>$in.plink.log 2>&1"; system($plink_command); -my $awk_cmd = "awk \{\'print \$1\'\} $in.ped"; -my $inds = `$awk_cmd`; -my @individuals = split("\n",$inds); +my @individuals = (); my %populations; if (-e "$in.individual_info.txt") @@ -47,9 +45,19 @@ close($I); } + +my $line_ind = `grep CHROM $in`; +$line_ind =~s/\n//g;$line_ind =~s/\r//g; +my @tab = split(/\t/,$line_ind); +for (my $i = 9; $i <= $#tab; $i++){ + push(@individuals,$tab[$i]); +} + open(my $OUT,">$out.mds_plot.txt"); my $go = 0; +print $OUT "Pop sample val1 val2 val3\n"; open(my $O,"$out.mds"); +my $numline = 0; while(<$O>) { if ($go) @@ -60,27 +68,29 @@ my @i = split(/\s+/,$line); if ($line =~/^ /) { - my $ind = $i[1]; + #my $ind = $i[1]; + my $ind = $individuals[$numline]; my $pop = "Pop1"; #if ($ind=~/^d/){$pop="Pop2";} if ($populations{$ind}) { $pop = $populations{$ind}; } - print $OUT "$pop $ind ".$i[4]." ".$i[5]."\n"; + print $OUT "$pop $ind ".$i[4]." ".$i[5]." ".$i[6]."\n"; } if ($line =~/^\w/) { - my $ind = $i[0]; + #my $ind = $i[0]; + my $ind = $individuals[$numline]; my $pop = "Pop1"; #if ($ind=~/^d/){$pop="Pop2";} if ($populations{$ind}) { $pop = $populations{$ind}; } - print $OUT "$pop $ind ".$i[3]." ".$i[4]."\n"; + print $OUT "$pop $ind ".$i[3]." ".$i[4]." ".$i[5]."\n"; } - + $numline++; } if (/C1/){$go = 1;} }