Showing posts with label fastStructure. Show all posts
Showing posts with label fastStructure. Show all posts

Friday, April 17, 2015

Wow. It worked

Finally got fastStructure installed a few days ago, so that supersedes my previous post about, well, not being able to install it. Also, it is really, really, really fast, and the clusters it infers seem to make more sense than the last time I used it, then on a work computer.

So that's good.

Still, I stand by what I wrote: if it needs somebody with my level of computer knowledge to make it work on the fourth attempt and if it only works on Unix/Linux anyway, then the number of end-users will be sharply limited compared to the original STRUCTURE software that comes with Windows executables and a GUI.

And there are a few other issues:

Just like the last time I used it, if infers basically no admixture. All samples are assigned to a population with >99% except one, and that one is assigned to >95% to one population. And this is a dataset where everything else - morphology, neighbor joining phenogram, old STRUCTURE - screams that one population of our samples is a hybrid swarm. So fastStructure may be of limited use to those studying introgression.

In addition, the output is fairly user-unfriendly. First, to know which of several numbers of clusters (K) to accept, one has to compare the likelihood values for each. The STRUCTURE GUI can display them in a nice table, but when using fastStructure you have to look at each log file individually and perhaps copy-paste the relevant values out into a table of your own making. I wrote a Python script to automate that, but not every user can do that.

Second, now that you know that K = 6, for example, is your preferred result, you want to see what that population structure looks like. fastStructure comes with a little tool called 'distruct' that helpfully draws one of those typical little STRUCTURE bar plots. Without sample names.

Yes. Without sample names. You can supply it with a little file containing the population names, but how do you know which population should have which name without knowing which samples belong to each? So you could just as well have a toddler draw a random bunch of colourful patches, because that would have the same information content as the distruct output.

So time to go back to the actual output and draw a bar plot with other means. Here we hit another snag. Where STRUCTURE outputs a file like so:
Yoursample1  0.340  0.660  0.000
Yoursample2  0.999  0.001  0.000
Yoursample3  0.000  0.000  1.000
... the equivalent fastStructure output file with the extension meanQ looks like this:
0.340  0.660  0.000
0.999  0.001  0.000
0.000  0.000  1.000
Again, which sample is which? To make sense of the results I really need to know that, don't I? Well, they are in the same order as in your input file, but as that is usually going to be a '.str' file with two rows for each sample, it is not a trivial exercise to copy the results and the sample names next to each other in a way that you can use for producing the bar plot. Also, the columns are separated by two spacers instead of one tab, making it even harder to copy into an Excel or LibreOffice sheet, but if I remember correctly that was already the case in STRUCTURE.

From a user friendliness perspective this all looks rather poorly thought through. But again, the program is free and several orders of magnitude faster than STRUCTURE, so one can't complain too much.

Thursday, April 9, 2015

The ideal software tool is one that no end user can install

Did I write that I would not comment any more on fastStructure after my other two posts?

I just spent much of the evening trying to install it at home, and banging my head onto the desk for two hours would probably have been a more pleasant experience. After all that effort I got all the prerequisites - Numpy, Scipy, Cython and GSL installed, and even running the build seemed to have worked. At least when I try to do it over, it says, nope, I'm already done, no need.

But then when I try to run fastStructure, it says that it cannot find the libraries that are just sitting there in the same folder.

To all potential end users: Don't try this at home. Preferably ask your institution's IT people to put it onto some machine for you. Or use a different software.

To all bioinformaticians who hope that scientists will use their software: This is how not to do it. If you write a program that only another programmer can even so much as install, then hardly anybody will use it, and thus hardly anybody will cite your paper. Wasted effort. How about providing executables, like BEAST? Or at least something that can be installed by running a simple makefile, like r8s? Or an R package perhaps, like BioGeoBEARS? It's not as if there aren't people who get that right.

Update: It worked!

Wednesday, August 27, 2014

Final update on using fastStructure and similar software

After my somewhat mixed experience trying to use fastStructure, I have recently found the time to throw my data at two other programs for inferring population structure.

To recap, I have thousands of SNPs for two groups of species, in one case from 91 individuals and in the other from 224 individuals and I want to know how best to group the individuals into separate 'populations', in the present case potential species. I originally used fastStructure because it was new and supposedly written specifically for large numbers of SNPs, but the results were ultimately odd. The clusters didn't make very much sense and the program found virtually no admixed individuals, that is hybrids, although there really should have been some.

Earlier this week I then tried the R package adegenet. On the plus side, it turned out to be very simple and user-friendly. Of course you need to know how to use R, but the manual of the package is well written, and adegenet has a straightforward "read" function for importing datasets. It easily imported my Structure file without any hiccups, and after that it was a simple manner of handing my data over to adegenet's "find.clusters" function.

However, I tried different settings and did not get reasonable populations with any of them. One problem in my dataset are missing data, and I found that setting allele frequencies to zero for those cases produced the most meaningful results, but still there were several populations with no samples in them and the populations that had samples didn't make a lot of sense.

Yesterday I finally tried my luck with good old Structure itself - somewhat hesitatingly because I feared it would be very slow with such a big dataset. Yes, even for my smaller dataset what I wanted to do ran overnight, but that is still faster than I feared, and the results are worth it. The populations make sense, and in marked contrast to fastStructure it finds evidence of admixture. My larger dataset will probably need several days to be analysed, but if that is necessary so be it.

There is probably a reason why that program is the most popular in the area...

Friday, August 1, 2014

Trying to use fastStructure

Updated 16 August 2014 and 27 Nov 2014

A well established software tool in ecology and systematics is Structure. Using population level molecular data such as Amplified Fragment Polymorphism (AFLP), microsats or Single Nucleotide Polymorphisms (SNPs), it tries to find the underlying population structure. In practice, you run the program with a range of values for number of populations (K) and then compare the resulting likelihood values for each.

Apart from the best K value, that is the number of populations or clusters that your samples are best divided into, Structure also outputs how much of the genome of each of your samples is derived from each population. This is then often depicted in a graph such as the one seen here. Each line in that figure represents the results of one Structure run, from K = 2 to K = 6. Each colour is one of the clusters or populations. Each pixel column is one sample, with its colour showing to what population it belongs. So you may get many samples that belong fully or nearly fully to one population but also some that are 'admixed' between two, perhaps representing hybrids.

This methodology is used to examine population structure below the species level but also, and this is what is more interesting to a systematist like myself, to study the delimitation of species. I have such a project going with a colleague from a different herbarium, and we just got our data. They are more than 9,000 SNPs for 91 samples, and unfortunately Structure is rather slow especially when analysing such large amounts of data.

So you can imagine I was very happy to find that a few months ago the same lab released a program called fastStructure specifically to deal with large numbers of SNPs and promised to be one or two orders of magnitude faster than Structure. In fact it is so new at this point that the paper announcing it has only been cited twice - once in the editorial of the same journal (which doesn't really count) and once in a minor review article. In a few months papers will start coming out by people who have actually used it, but at the moment there is little practical experience to build on except the comments and questions of people on the Structure Google Group.

After our high performance computing staff kindly installed the program on a supercomputer, I spent most of today trying fastStructure out. I learned a lot but so far the results have been mixed. I write this partly to spare other people some of the frustrations I experienced.