DrewWham / Genetic-Structure-Tools

R Functions for plotting and working with STRUCTURE files
Apache License 2.0
0 stars 2 forks source link

Genetic-Structure-Tools

R Functions for plotting and working with STRUCTURE files

Here you will find a couple of functions that are useful for plotting the results of STRUCTURE in R. Just download the "STRplot.r" file and open R. Set your working directory to your Results folder from your STRUCTURE run and also put your .txt formated STRUCTURE infile in this directory.

You can then run:

>source("plotSTR.r")

Getting Started

Lets start by turning the ugly STRUCTURE outfile into a clean .csv file

>read.STR("All Glynnii.txt","No Add Inf Lamb Final_run_10_f")

Now check your folder and you should have a file called "k4.csv", or if your running this on your own data it will be "kx.csv" where x= the k value you used.

If this file is in the order that you would like you are all set, if not you can reorder the file any way that you would like and then save it as "Order.csv", just be sure to keep your original "k4.csv" as well.

Now you can plot with:

>plotSTR("k4.csv")

or if you reordered the file you will use:

>plotSTR("k4.csv",order="Order.csv")

This should output the above .pdf