Stage 10: Checking your conclusion
A result is only as solid as the choices behind it. Change one rule, see how far the answer moves, and write down what you conclude.
Every analysis hides judgement calls: which rows to keep, where to draw a line. A trustworthy analysis shows how much the answer depends on them. Today's question: should we trust variants that were measured in only a couple of experiments?
Use the miss table from before. First, the missense variants in the phosphatase domain:
phos = miss[miss["region"] == "phosphatase_domain"]
print(len(phos), "variants, average score", phos["score"].mean())Now keep only variants measured in at least 3 experiments and compare:
strict = phos[phos["expts"] >= 3]
print(len(strict), "variants, average score", strict["score"].mean())
print("change in the average:", strict["score"].mean() - phos["score"].mean())One comparison could be luck. Try several settings and look at the whole picture, not one cherry-picked value. A loop does it in a few lines:
for minimum in [1, 2, 3, 4, 5, 6]:
kept = phos[phos["expts"] >= minimum]
print("at least", minimum, "experiments:", len(kept), "variants, average", kept["score"].mean())If the average barely moves while the number of variants falls, the conclusion is robust to this choice. If it swings, say so. Either answer is a result.
Write the conclusion
A number is not a conclusion. A conclusion says what you found, how sure you are, and what could change it. Look at your loop output: how many variants does each setting keep, and how far does the average move?
Now practise in Colab
You have read the ideas. Next, try them. The notebook repeats the code above with a few blanks for you to fill in, then ends with small exercises. It is all about this stage. Run the cells in order.
Open the practice notebookYou need a free Google account. When it opens, choose File, then Save a copy in Drive, so your work is yours.
Exercises
These are also in the notebook. Try each one yourself before you open the solution.
Try a stricter rule
expts >= 5 instead of 3. How many variants are left, and what is the new mean?Show a solution (try it first)
Your numbers will depend on the real table, so there is no fixed output to compare with.
strict5 = phos[phos["expts"] >= 5]
print(len(strict5))
print(strict5["score"].mean())Check your understanding
First star
Keep only rows whose expts is at least 3, across the whole table (every kind of variant). How many rows remain?
Stuck? Nudge and solution
len(df[df["expts"] >= 3]). Rows with a blank expts do not pass the test, so they are not counted.
print(len(df[df["expts"] >= 3]))Second star
For the missense variants in the phosphatase_domain: the average score with the rule expts >= 3 minus the average without it. Give the difference to 3 decimal places, keeping the sign.
Stuck? Nudge and solution
The code above already prints it as change in the average. A tiny difference is good news for how robust the earlier answer was.
print(strict["score"].mean() - phos["score"].mean())Third star
Write a short conclusion (four to six sentences) about the phosphatase domain, as you would in a lab meeting. Include the average with and without the rule, how many variants each keeps, whether you think the conclusion is robust to this choice, and one other analysis choice that could change it.
A model answer (use your own numbers)
"Across all ___ missense variants in the phosphatase domain the average score is ___. Requiring at least 3 experiments keeps ___ variants and moves the average to ___ (a change of ___). Because the shift is [small / large] compared with the spread between variants, I consider the domain-level conclusion [robust / sensitive] to this rule. The loop shows the estimate [settles / keeps changing] as the threshold rises, but keeping fewer variants makes the average noisier. Other choices could matter too, such as dropping variants with large standard errors or using the median instead of the average, so I would check those next before claiming anything strongly."
Did you cover
- Both averages and both counts?
- A judgement about robustness, with a reason?
- The cost of keeping fewer variants?
- A different choice that could change the result?
Stuck? How to start
Use this order: the finding with numbers, how it changed, how confident you are, and one caveat.
Special thanks to Nilay!