the case of the dead sand mouse
Here’s three different answers from us as Jupyter Notebook pages you can download. Each week we’ll give you three answers, two from the TFs and one from me (Sean).
No matter what the pythonistas say, there isn’t just One Right Way to solve a problem in python. By comparing the different answers, you’ll be able to see a range of different approaches and tricks. For example, in comparing the Moriarty and Adler gene name lists for part 1, a naturally pythonic approach is to use set operations, subtracting one set from the other. But you can just as easily iterate over the gene names in one list and test if a gene name is
not in the other list. Python has some very powerful syntax, such as list comprehensions and lambdas (anonymous functions), which is helpful (if you know them) but not necessary (if you don’t). You’ll see examples of more or less clever syntax here, but all of it’s getting the job done.
Sean: My solutions each week will generally be a bare bones example, and this is no exception. I shortcut the data exploration in step (3) by using unix commands, including
sort, inside the Jupyter notebook page.
Angel: A version with an example of defining a function, to get all the text-data-parsing code bundled neatly away in one reusable function. Uses a different way of sorting stuff, using a Python
lambda(basically, a quickie little one-line function that you use once and throw away - like when you need to provide a function as an argument to some other call, but you can’t be bothered to
defa real one). Shows some data plotting with matplotlib (which we haven’t introduced yet, but we will!)
Gloria: An even more advanced version that uses the Pandas data science module (which we haven’t introduced yet, but some of you already know how to use it), and does even more plotting with matplotlib.