Sunday, June 9, 2019

Introduction - why is this here?

I have been teaching undergraduate biology courses since 2001, and one area that I find is consistently difficult is math. Students seem to come into our biology program with the expectation that math doesn't matter. Sadly, they often receive a rude awakening very early on! One area of applied mathematics that they encounter is the Hardy-Weinberg equation. This is an equation that is used as a null model, representing what happens when evolution is NOT occurring. By determining if a population does or does not meet the conditions of the Hardy-Weinberg equation, you can potentially learn a lot about the population and how evolution might be acting on it.

For this reason we teach this topic to our students, but they often have a hard time understanding what the equation says and what it means. One thing that seemed promising would be to give them additional chances to practice using the equation, with feedback to help them improve. At this point, I got the idea to develop an app that would generate Hardy-Weinberg problems and see if students could answer them. From this, the Hardy-Weinberg quiz app was born. 

This site functions as an explanation/introduction to the Hardy-Weinberg equation and how to apply it. It also serves as a help system for the app. If you haven't reached this webiste from the app, you can get to the app in the Google Play Store at this link. If you are an iPhone user, I'm sorry, but I don't have a capability to program for Apple devices, so the app is Android only. You might still find this website useful for understanding Hardy-Weinberg even if you cannot (or don't want) use the app. Click on the links on the right for more information (in particular, the "Instructions" link gives more information on using the app) and if you have questions, you can reach me at utilitybeltsoftware@gmail.com

Saturday, June 8, 2019

What is the Hardy-Weinberg equation?


The Hardy-Weinberg equation was developed in the early 20th century. This equation describes the way that allele frequencies change (or do not change) over generations. It is generally used to examine one trait with two alleles, one dominant (represented by p in the equation) and one recessive (represented by q). It is also common to represent the dominant allele with a capital letter (e.g., "A") and the recessive allele with the same letter in lower case (e.g., "a"). To test this equation, we examine the gene pool, which consists of all the alleles that are present in  the population. Evolution is occurring when the frequencies of these alleles change from one generation to the next. Because there are only two possible alleles, their frequencies must add up to a total of 1.

p + q = 1 (equation 1).

This means that if you know the frequency of the dominant allele, you can calculate the recessive (and the reverse is also true). This must always be true, whether evolution is happening or not. The test of the equation is in how well it is able to predict the genotype frequencies in the population. If we are dealing with a population that is diploid and a gene with only two alleles, then there are three possible genotype frequencies, homozygous dominant (an individual with two copies of the dominant allele,, which can be abbreviated as "AA"), heterozygous (one dominant and one recessive, represented as "Aa"), and homozygous recessive (two recessive alleles, represented as "aa"). The standard way to present the Hardy-Weinberg equation is to start with equation 1 and square it, because there are two alleles in diploid individuals

(p + q)2 = 1 (equation 2)

This can then be expanded to

p2 + 2pq + q2 = 1 (equation 3)

In this equation, each of the items corresponds to a genotype, with p2 representing the homozygous dominant frequency, 2pq representing the heterozygotes, and q2 representing the homozygous recessive frequency. These are the values you expect to see for the genotypes if the Hardy-Weinberg equation is accurately describing your population. The equation describes a situation where evolution should not be occurring, meaning that the allele frequencies will remain unchanged from one generation to the next. This requires several assumptions:
  1. There is no factor that allows some individuals to be more successful than others
  2. The population size is large and there are no large-scale random events affecting it
  3. There is no net mutation in the population
  4. There is no net movement of individuals into or out of the population
  5. Mating is random
These assumptions do not have to be perfectly met, but the closer they are, the better the equation will apply. Even in situations where the assumptions do apply, there will tend to be some variation over time, because some randomness cannot be avoided. The figure below shows how two particular alleles are changing over time when the Hardy-Weinberg assumptions are met. Note that the alleles are tied together - when one allele goes up, the other goes down in response.


These assumptions need to apply to the particular trait being studied, not every trait in the organism. This means that some traits might be evolving while others are not. It is also generally applied to traits that are autosomal, although this is not required. This app will only focus on autosomal traits to minimize the complications. See other sections on this website for specifics on how to calculate the values and how the app tests your understanding...

Friday, June 7, 2019

Calculating allele frequencies

Generally when working with the H-W equation, you are given the information on your population and then must calculate the required values. The first set of values you are likely to need are the allele frequencies (p for the dominant, q for the recessive). To determine these values you will be given the number of individuals in a population for each genotype. From this you can calculate the values directly. For example, if you have a population with 252 AA, 640 Aa, and 382 aa. What are the values of p and q for this population? Because p and q represent the allele frequencies in the gene pool, you need to determine how many alleles are in the entire gene pool. For this you take the total number of individuals and multiply by 2 (because the individuals are diploid). Thus:

252 + 640 + 382 = 1274 individuals.

1274 x 2 = 2548 alleles

To calculate an allele's frequency you need to take into account how many total copies are present for that allele in the entire gene pool. This means you need to take into account two different types of individuals: heterozygotes and one type of homozygous individual. If you are calculating p, then you would count all the homozygous dominant individuals and the heterozygotes. However, you have to take into account the fact that a homozygous dominant individual has two dominant alleles while heterozygotes have only one. So in order to calculate p, you need to take

 (equation 1)

Replacing the generic equation listed above with the actual values we get 

 (equation 2)

This means that p = 0.449 (your number may vary slightly due to different number of decimal places). This means you know that q must be 0.551, because p + q = 1. You can also calculate q directly as a way to check your math (always a good idea!). You would use equation 2, but replace 252 with 382.

This is an important skill to cultivate - pretty much every other calculation you need for the Hardy-Weinberg equation requires that you know what the allele frequencies are!

Thursday, June 6, 2019

Calculating genotype frequencies

Once you know the allele frequencies you can calculate the expected genotype frequencies using those values (the values given here for p and q are from the topic on calculating allele frequencies).

Frequency of homozygous dominant = p2 = 0.4492  0.202

Frequency of heterozygous = 2pq = 2 x 0.449 x 0.551 = 0.495

Frequency of homozygous recessive = q2 = 0.5512 = 0.304

We often find that genetic diseases are recessive, and only expressed in the homozygous recessive form. In such a case, the heterozygous individuals would be called "carriers" because they can pass the disease gene to their offspring, but they usually don't have the disease. These genotype frequencies are going to be worthwhile in their own right, but mostly because they can be used for the calculations to see if the H-W equation applies to a particular population.

Wednesday, June 5, 2019

Calculating number of individuals of each genotype.

Once you have calculated the genotype frequencies that you expect if the H-W equation is true, you need to calculate how many individuals that corresponds to. To do this you multiply each genotype frequency times the size of the population. For our starting example this means:

Expected homozygous dominant (AA) individuals = p2 x 1274 (number of individuals in the population). This is 0.202 x 1274 = 257.4

Expected heterozygous (Aa) individuals = 2pq x 1274 = 0.495 x 1274 = 630.6

Expected homozygous recessive (aa) individuals = qx 1274 = 0.304 x 1274 = 387.3

NOTE: your expected values will typically not be whole numbers, which seems a little odd, because you cannot have fractions of an individual. However, for the purposes of the statistical test we're going to be using, fractional answers are reasonable. You can check to see if your numbers are reasonable by adding up your expected values. They may be off slightly due to round effects, but they should be close to the 1274 population size you are working with. If there is a large difference check your work - there may be an error in there somewhere!

Now that you have your expected genotype numbers, you can move on to perform the statistical test that will let you determine if the population meets the Hardy-Weinberg requirements or not.

Tuesday, June 4, 2019

Calculating if the population meets the Hardy-Weinberg requirements

Once you have your expected values you can compare them to the observed ones, but doing so based on your intuition isn't reliable. Instead, you need to perform a statistical test that allows us to determine if our values are too far apart to be correct. The test we use is called the chi-square goodness of fit test (abbreviated as χ2). This test is calculated by taking the difference between the actual number of individuals in each genotype in the population and the numbers of each genotype that you expected if the Hardy-Weinberg equation is true. You compare those numbers using this formula:


For a H-W test, you will calculate three values (one for each genotype) and sum them together to determine the χ2 value. You then compare this value to a critical value to see if there is a significant difference, or if the differences between the observed and expected are just due to random noise. Normally, you need to have a statistical table to see if your value is significant or not, but that isn't necessary for us. For reasons we don't need to address here, the comparison value for H-W tests is always 3.841. Note: a common misunderstanding is to use a value of 5.991. This is based on an incorrect interpretation of how the χ2 test is done (see this website for more explanation). If the χ2 value is greater than 3.841, then we would say that the differences between the observed and expected are large enough to say that the H-W equation probably doesn't apply to that population. In other words, this would mean the population is evolving for this gene because at least one of the H-W assumptions is not correct. Further work would be needed to determine which assumption(s) are being violated.

For the example data we have been using recall that there were 252 AA, 640, Aa, and 382 aa individuals. These are the observed values. If the H-W equation is true, we expect 257.4, 630.6, and 387.3 for each genotype. This gives the following calculations


 Solving for each equation gives us

So the total is χ2 = 0.326.

Because this value is less than 3.841, there is no significant difference between the expected and observed values, leading us to conclude that this population is not evolving for this gene because it meets all the assumptions required by the H-W equation.

Monday, June 3, 2019

Instructions - introduction to the H-W Quiz App







When you start the app, you should see this screen. The "Make pop." button will randomly choose one of the question types that you have selected (check the Settings on the menu to see which types of questions are available) and generate a population that will be used for the numbers for the problem. The menu at the top right gives access to a number of options (discussed in separate items on this website). The hint button will activate the hint system, where the app will guide you through the calculations to get to the correct answer. This is discussed in more detail on this site. If you need general instructions for the app, you can access them by clicking on the menu and choosing "Instructions". Once you have generated a population you will see details on the population (number of individuals of each genotype) and a place to answer the question. There are two types of questions the app can ask: multiple-choice, where the app gives you a list of choices to answer the question being asked. The other type are fill-in questions where you have to provide a number you calculated to answer the question. Once you have made your choice or entered your answer, you will click on the check answer button and learn if your answer was correct or not. For the multiple-choice questions, the specific answer will be among the options. For the fill-in questions, the app permits some deviation from the correct answer. This is to take into account rounding issues. Depending on the type of question, the number of decimal points you should use in your answer will be indicated. The amount of "wiggle room" you have varies based on the type of question but it isn't very large in any type. You aren't required to use that many, but if you do, you're more likely to be within the acceptable limits for that type of question.

Based on providing correct answers quickly enough, you will earn points that can be used to increase your rank from its starting point (Novice) all the way up to the maximum value (Ph.D.). Answers that aren't given quickly enough will not earn points (but won't cost you any). Wrong answers will cost you points, so be sure you have the correct answer before you select it! See the section on the rankings for more information on this aspect.


Sunday, June 2, 2019

Instructions - selecting options from the menu

The app menu lets you select several options that will affect how the program functions as well as providing more information about it. Settings lets you control how the app works, rankings lets you view the rank you have earned for each question type, achievements lets you see the milestones you have earned in the app, instructions takes you to the instructions built into the app, online help takes you to this website, reset stats will erase all stored data (including your ranks), and about will display information on the version and date of the app.


Saturday, June 1, 2019

Instructions - the settings dialog

On the settings menu you can choose which types of question(s) the app will quiz you on as well as turning the sounds on or off. Select any question type you want to work on. You can choose any combination of question types (both multiple-choice and fill in) as long as at least one type is selected. The sounds are played after you select an answer to indicate if you are correct or incorrect. There are separate sound that play when you earn an achievement, a new rank (due to answering questions correctly), lose a rank (due to answering too many incorrectly), skip questions, or use the hint system.






Friday, May 31, 2019

Instructions - the ranking system

The app has a ranking system to give you some incentive to use it and also to give you a chance to see how your skills are improving. There are separate rankings for each question, ranging through the following categories:
  1. Novice
  2. Freshman
  3. Sophomore
  4. Junior
  5. Senior
  6. Bachelors
  7. Masters
  8. Ph.D.
Each question type has its own ranking, so your rank in one does not have an impact on your ranking in any of the others. Each ranking is earned by a earning a particular score on that type of question (each question type has its own score as well). Your score goes up by a certain number of points for every question you answer correctly within the time limit. The number of points will depend on the type of question as well as your rank (e.g., you will earn more points at higher ranks and more points for some question types). The current score for that question type is displayed at the bottom of the app screen. If your score is above zero, it displays in green, and if it's below zero it is in red so that you have a visual indication of your status. At lower levels, you have more time to answer the question. As your rank increases, you have less time to answer the question if you want to earn points. If you surpass the time limit and give a correct answer your score doesn't change. if you give an incorrect answer, regardless of how long it takes you to give it, you lose points (like a correct answer the number of points will vary by question type and your rank). When you reach a certain number of points, you will earn a higher ranking and your score will reset to 0. The number of points you need to earn also increases as you go up, making it more difficult to earn those rankings. 
To prevent you from just guessing to earn ranks, for every question you answer incorrectly, you lose points. If you lose too many points, you will lose a ranking and your score resets to zero. The number of points you have to lose before you drop a rank varies by level as well.

If you are at the lowest rank for a question you cannot drop any lower, regardless of how many question you answer incorrectly, but you will get a warning if you answer too many incorrectly and your score will reset to zero.

Thursday, May 30, 2019

Instructions - Achievements

As you move forward through the app, in addition to earning points that contribute to advancing in ranks, there are also "achievements" that you earn at different milestones. There are a variety of different achievements, and unlike the ranks, once you earn an achievement, you won't lose it, even if you lose points for wrong answers. When you earn an achievement, you will be notified on the screen after answering the question. It's possible to earn an increase in rank at the same time as you earn an achievement, but that isn't required. Some achievements are for specific types of question (multiple-choice vs. fill-in) while others apply regardless of question type, e.g., you get an achievement the first time you get a streak of 10 questions in a row correct, regardless of what type of question they were). You can check on your current status in terms of achievements by choosing "Achievements" on the menu. This will let you know your current values for the number of points that you've earned for each type of question (these do not reduce when you get an answer wrong) as well as your current streak of correct answers (which resets when you get one wrong). Questions that take too long do not change these values, nor do questions where you used a hint. Below those numbers you will have a listing of all the achievements you have earned, and last you'll have an indication of how many achievements are remaining to be earned (there are 37 possible).

Wednesday, May 29, 2019

Instructions - In-app instructions

In addition to the information on this website, there is some basic information available in the app by choosing "Instructions" from the menu. This will display a dialog box that provides information on how to use the app. Click next to next and previous to view the different screens of information and press "Done" when you are finished.

Tuesday, May 28, 2019

Instructions - the online help system

You can access this website directly through the app by choosing "Online help" from the menu.

Monday, May 27, 2019

Instructions - resetting your scores

If you select "Reset stats" from the menu you have can reset all the data stored by the app. This includes the number of attempts, time data, and all your rankings and achievements. Because there is no way to undo this, you will receive a warning dialog to make sure you want to reset the scores. Once you have done this, all your values are back to 0, and your rankings are all novice.

Sunday, May 26, 2019

Instructions - about dialog

When you select "About..." from the menu, you get a dialog with information about the app including the version as well as the day and time it was compiled. Click OK to return to the app.

Saturday, May 25, 2019

Instructions - data on your performance

After each question, the app updates the number of attempts for each type of question and how many you answered correctly. It also stores the time it took you to complete the last question of that type as well as the average time you have taken to answer those questions. These values apply to each question type separately, so when you generate a new population, the values will update to correspond to the type of question you are currently addressing.

The app also keeps track of your choice of whether or not to answer a question. If you want to skip a question, you can do so by just clicking on the "Generate Population" button again. When you do this, the question is skipped and you'll get a new one. However, there is a limit to how many questions you can skip without consequences (the number of acceptable skips decreases as you get to higher rankings). If you skip too many questions, you will start to lose points for that question type.

If you lose enough points, you can even lose a rank you earned by getting questions correct. Every time you earn a new rank, the number of questions you have skipped is forgotten. In addition, every time you get a question correct, one of your skips is "forgiven".



You can also reset the number of skips by resetting the stats, although this will reset all your stats, not just the number of skips.

Friday, May 24, 2019

Instructions - the hint system

If you click on the hint button, you will activate the app's hint system. This will walk you through the steps you need to answer the question. The system uses the numbers from the question you are being asked, so you will see the exact calculations that you need to answer the question. You can click "Done" at any point to return to the question. Once you activate the hint system, you cannot earn points for answering the question correctly, however, you still lose points for a wrong answer and skipping the question can also have impacts on your score, so be sure to read the hints carefully to make sure you read them correctly! The next and previous buttons allow you to move through the steps of solving that problem.

Thursday, May 23, 2019

Instructions - Hardy-Weinberg questions



For this type of question, you'll be provided with the number of individuals for each genotype and you'll need to determine if the population is in Hardy-Weinberg equilibrium or not. To determine this you'll need to complete a χtest as described elsewhere on this website. For multiple-choice versions of this type of question there are only the two options available. For the fill-in questions, you still have to choose the yes or no option, but you must also provide the chi-square value you calculated that led you to your decision. 

Wednesday, May 22, 2019

Instructions - Allele frequency questions

 When the allele frequency type of question comes up, you'll be given the number of each genotype and use that information to calculate either the frequency of the dominant allele (p) or the recessive allele (q). See the introduction section of this website to see how to perform those calculations. For the multiple-choice questions, the app displays the number to three decimal places, so there may be some variation in your numbers if you used more or fewer. However, the results should be close enough to pick the correct choice. Also note, the answers are in random order, so you should check all the answers because it is possible to have more than one answer that is close to the correct one. For this type of question there will always be five options. If there are multiple options with the same value, you can choose any one of them - if it is the correct answer, you will receive credit regardless of which one you selected. For the fill-in question, you won't have any guidance on what the possible answer is, so you'll want to make sure your calculations are done correctly.

Tuesday, May 21, 2019

Instructions - genotype number questions






 When the genotype number type of question comes up, you'll be given the number of each genotype and use that information to calculate what is the expected number of individuals in one of the genotypes if the Hardy-Weinberg equation is correct (which genotype you are asked for is selected randomly). See the introduction section of this website to see how to perform those calculations. The multiple-choice question displays the number to one decimal places, so there may be some variation in your numbers if you used more or fewer. However, the results should be close enough to pick the correct choice. Also note, the answers are in random order, so you should check all the answers because it is possible to have more than one answer that is close to the correct one. For this type of question there will always be five options. If there are multiple options with the same value, you can choose any one of them - if it is the correct answer, you will receive credit regardless of which one you selected. For the fill-in question you should enter the number to one decimal place to minimize the difference between your answer and the one calculated by the app.

Monday, May 20, 2019

Instructions - genotype frequency questions


When the genotype frequency type of question comes up, you'll be given the number of each genotype and use that information to calculate the expected frequency of one of the genotypes if the Hardy-Weinberg equation is correct. See the introduction section of this website to see how to perform those calculations. The app displays the number to three decimal places, so there may be some variation in your numbers if you used more or fewer. However, the results should be close enough to pick the correct choice. Also note, the answers are in random order, so you should check all the answers because it is possible to have more than one answer that is close to the correct one. For this type of question there will always be five options. If there are multiple options with the same value, you can choose any one of them - if it is the correct answer, you will receive credit regardless of which one you selected. For the fill-in question, you should enter your answer to 3 decimal places to minimize the difference between your answer and the one calculated by the app.

Sunday, May 19, 2019

Release notes

This item will list the changes that have occurred with each version of the app.

Version 3.5.0
Added instructions screens to help you get familiar with the app as quickly as possible. It is accessed from the menu under "Instructions". You can also go to the online help for more detailed information.

Version 3.4.0
Added more achievements and modified sounds that are played when you earn them as opposed to "regular" ones.

Version 3.3.0
Started adding achievements - awards that you earn for reaching certain milestones in the app.

Version 3.1.0
Updated hint system for genotype questions so that it only provides values you need to answer the questions (e.g., you don't need to know q for homozygous dominant problems).

Version 3.0.0
Added hint system. If you aren't sure how to answer a question, click the "hint" button and it will walk you thought how to do it. When you use hints, you don't get points for getting that question correct, but you can lose points if you get it wrong. Some more tweaks to the scoring system. Also included some bug fixes.

Version 2.7.1
Further modifications to the scoring system so that it isn't too hard (or too easy) to reach a new level

Version 2.7.0
Modified how values are calculated to address problem of rounding errors in calculated values for the fill-in questions. Changes to how the points are awarded and subtracted for answers for different question types. General bug fixes.

Version 2.6.1
Added a penalty for skipping questions. If you skip too many of the questions the app presents to you, you'll start losing points (eventually losing ranks if your score drops enough).
Minor changes to the way populations are generated.

Version 2.5.0
Added fill-in questions for all question types. Now you can really test your understanding of the Hardy-Weinberg equation because the new questions require you to type the actual number into the app instead of picking from a list of choices. Updated the online help system (available through the app or at h-wquiz.blogspot.com) to cover the new question types.

Version 2.0.0
Added ranking system so that you can measure your progress in a different way. Each question you get right within a certain time limit gets you a point, and a certain number of points earns a higher rank. There are 8 ranks (novice to Ph.D.) As you level up, increased levels are more difficult to obtain. Can you make Ph.D. in all four question types? I've added an online help/instruction system (available through the app or at h-wquiz.blogspot.com. Also added minor changes to the UI/UX

Version 1.9.0
Testing gamification system with rankings and points.

Version 1.6.0
Aded a new type of question. You can now be asked the expected genotype frequencies in addition to the expected number of individuals with a particular genotype.

Version 1.5.0
Settings are now saved so that you don't have to reset them each time you start up the app. This includes the statistics like # correct, etc. You can reset the stats using the "Reset" option on the menu.

Version 1.4.5
Minor tweaks in how populations are generated.

Version 1.4.0
Added settings menu so you can choose which of the different types of questions you want to be tested on. It also allows you to set whether or not the sounds play for correct and incorrect answers.

Version 1.3.0
Minor tweaks to interface for tablets. Added a new type of question. You can now be asked to determine the number of individuals in a given genotype you would expect if the Hardy-Weinberg equilibrium is true.

Version 1.2.0
Added second type of question - calculating allele frequency for a given population. # correct and time data are stored separately for each type of question.

Version 1.1.0
Added display showing number of times you have been correct as well as time to answer the question and average time answering all attempts.

Version 1.0.0
Initial production version - determine if a given population is in Hardy-Weinberg or not, based on the genotype numbers you are given.

Saturday, May 18, 2019

Privacy Policy

Just to clarify, this app does not collect any data on you/your phone/behavior, beyond the data on correct answers, time to answer questions, etc. Those data are stored on your phone and are not accessible to anyone else. I do  not want/need/desire any of your personal data and I have no intention of doing so in the future. If I were to make changes to this policy, I would post that here.