# HG changeset patch # User dereeper # Date 1435824826 14400 # Node ID 92ddf4f7c0c6311b0681415628f94aba57ed3dc0 # Parent 78b98120be91d24bd19930ffe3f0dae9502d8a69 Uploaded diff -r 78b98120be91 -r 92ddf4f7c0c6 admixture/Admixture.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/admixture/Admixture.pl Thu Jul 02 04:13:46 2015 -0400 @@ -0,0 +1,112 @@ +#!/usr/bin/perl + +use strict; +use Switch; +use Getopt::Long; +use Bio::SeqIO; +use File::Basename; + +my $usage = qq~Usage:$0 [] +where are: + -i, --input + -o, --output + -k, --kmin + -m, --maxK + -d, --directory +~; +$usage .= "\n"; + +my ($input,$output,$kmin,$kmax,$directory); + + +GetOptions( + "input=s" => \$input, + "output=s" => \$output, + "kmin=s" => \$kmin, + "maxK=s" => \$kmax, + "directory=s" => \$directory, +); + + +die $usage + if ( !$input || !$output || !$kmin || !$kmax || !$directory ); + +if ($kmin =~/^(\d+)\s*$/){ + $kmin = $1; +} +else{ + die "Error: kmin must be an integer\n"; +} +if ($kmax =~/^(\d+)\s*$/){ + $kmax = $1; +} +else{ + die "Error: kmax must be an integer\n"; +} + + + +open(my $P2,"$input.fam"); +my $n = 0; +my $ind_num = 0; +my @individus; +while(<$P2>) +{ + my ($ind,$other) = split(/ /,$_); + push(@individus,$ind); +} +close($P2); + +my $basename = basename($input); + +################################### +# launch admixture for different K +################################### +my %errors; +for (my $k = $kmin; $k <= $kmax; $k++) +{ + system("admixture --cv $input.bed $k >>$directory/log.$k 2>&1"); + my $cv_error_line = `grep -h CV $directory/log.$k`; + if ($cv_error_line =~/: (\d+\.*\d*)$/) + { + $errors{$1} = $k; + } + system("cat $directory/log.$k >>$directory/logs"); + system("echo '\n\n====================================\n\n' >>$directory/logs"); + system("cat $basename.$k.Q >>$directory/outputs.Q"); + system("echo '\n\n====================================\n\n' >>$directory/outputs.Q"); + system("cat $basename.$k.P >>$directory/outputs.P"); + system("echo '\n\n====================================\n\n' >>$directory/outputs.P"); +} + +my @sorted_errors = sort {$a<=>$b} keys(%errors); +my $best_K = $errors{@sorted_errors[0]}; + + +open(BEST1,"$basename.$best_K.Q"); +open(BEST2,">$directory/output"); +print BEST2 "\n"; +print BEST2 ""; +for (my $j=1;$j<=$best_K;$j++) +{ + print BEST2 " Q" . $j; +} +print BEST2 "\n"; +my $i = 0; +while() +{ + my $line = $_; + $line =~s/ /\t/g; + my $ind = $individus[$i]; + print BEST2 "$ind "; + print BEST2 $line; + $i++; +} +close(BEST1); +close(BEST2); + +system("cp -rf $directory/log.$best_K $directory/log"); + + + + diff -r 78b98120be91 -r 92ddf4f7c0c6 admixture/admixture.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/admixture/admixture.sh Thu Jul 02 04:13:46 2015 -0400 @@ -0,0 +1,26 @@ +#!/bin/bash +bed=$1 +fam=$2 +bim=$3 +outputs=$4 +logs=$5 +best_k_output=$6 +best_k_logfile=$7 +kmin=$8 +kmax=$9 + +directory=`dirname $0` +mkdir tmpdir$$ +cp -rf $bed tmpdir$$/input.bed +cp -rf $fam tmpdir$$/input.fam +cp -rf $bim tmpdir$$/input.bim + + +/usr/bin/perl $directory/Admixture.pl -i tmpdir$$/input -o $outputs -k $kmin -m $kmax -d tmpdir$$ + +mv tmpdir$$/output $best_k_output +mv tmpdir$$/log $best_k_logfile +mv tmpdir$$/outputs.Q $outputs +mv tmpdir$$/logs $logs + + diff -r 78b98120be91 -r 92ddf4f7c0c6 admixture/admixture.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/admixture/admixture.xml Thu Jul 02 04:13:46 2015 -0400 @@ -0,0 +1,56 @@ + + a population structure from large SNP genotype datasets + + admixture + + ./admixture.sh $bed $fam $bim $outputs $logs $best_k_output $best_k_logfile $kmin $kmax + + + + + + + + + + + + + + + + + +.. class:: infomark + +**Program encapsulated in Galaxy by Southgreen** + +.. class:: infomark + +**Admixture version 1.23** + +----- + +============== + Please cite: +============== + +"Fast model-based estimation of ancestry in unrelated individuals.", **D.H. Alexander, J. Novembre, and K. Lange.**, Genome Research, 19:1655{1664, 2009. + +----- + +=========== + Overview: +=========== + +ADMIXTURE is a program for estimating ancestry in a model-based manner from large autosomal SNP genotype datasets, where the individuals are unrelated (for example, the individuals in a case-control association study). + +----- + +For further informations, please visite the Admixture_ website. + + +.. _Admixture: http://www.genetics.ucla.edu/software/admixture/index.html + + + diff -r 78b98120be91 -r 92ddf4f7c0c6 admixture/tool_dependencies.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/admixture/tool_dependencies.xml Thu Jul 02 04:13:46 2015 -0400 @@ -0,0 +1,6 @@ + + + + + + diff -r 78b98120be91 -r 92ddf4f7c0c6 tool_dependencies.xml --- a/tool_dependencies.xml Thu Jul 02 04:08:56 2015 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ - - - - - -