#install dependencies
sudo apt-get install libgsl0ldbl
sudo apt-get install libboost-all-dev
sudo apt-get install gsl-bin
sudo apt-get install libfontconfig1-dev
sudo apt-get install libgsl0-dev

#treemix download and installation
wget https://bitbucket.org/nygcresearch/treemix/downloads/treemix-1.13.tar.gz
tar -xvf treemix-1.13.tar.gz
cd treemix-1.13
./configure
make
make install

#download files (treemix_files.tar.gz)
wget https://github.com/na399/popgen-project/blob/master/additional_files/treemix_files.tar.gz
tar -xvf treemix_files.tar.gz
cd treemix_files/
cd species

#then simply follow the info in link you shared with me:
plink --bfile species_grants --freq --missing --within new_species_clusters_Mk.clst
#or use
plink --bfile species_grants --freq --missing --within new_species_clusters.clst
#thats without exluding Mkomazi granti
gzip plink.frq.strat
python plink2treemix.py plink.frq.strat.gz treemix.frq.gz

#now following manual
treemix -i treemix.frq.gz -root thomsons -m 2 -o outstem

#producing R graphs
R

source("plotting_funcs.R")
plot_tree("outstem")
#for locations
#poporder is file in folder which is basically order of groups
plot_resid("outstem", "poporder")