Atharva Bhagwat

Stage 10: Checking your conclusion

0Plan
Stage 10Core
★★★

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:

run this
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:

run this
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:

run this
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

Repeat the comparison with 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.

one solution
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.

one way to get it
print(len(df[df["expts"] >= 3]))

Special thanks to Nilay!