When I started graduate school, I understood the science well, but was struggling to understand how to interpret results. Learning logic through programming helped.
Programming vs Logic
When I joined my graduate lab, I took a leap into something unknown. I had worked in an evolutionary development lab and a population genetics lab, and had stayed pretty far from bioinformatics. It wasn’t that I was uninterested, but that I did not have easy access to the tools to learn it.
The project I chose for my graduate research is a purely bioinformatics project. The data is collected by others, and then I sit on the computer, analyze the data, and try to interpret the results. To do this, I had to learn how to code.
I’ve learned PHP and R programming and am learning Python and Java, but being an effective programmer actually means far more than learning how to put the right code in a file. No matter the language, you need something in particular: logic.
What is Logic in Programming?
To me, logic is how we use a programming language, how we interrogate data to answer a question or to do a particular task. This is essential to learning programming, but has actually helped me become a better critical thinker. I’ve discussed in the past how being more creative helps us become better scientists, but logic is a more active and straightforward skill. This is because seemingly easy concepts can become more complicated when you are actually thinking through them thoroughly.
How can something easy become complicated?
Here is a simple example, using no particular language’s syntax:
Let’s say we have some variable, x. We want to know whether it is positive or negative. How can we do this?
Well, we could say if x is above zero, it’s positive. Otherwise, it’s negative.
IF x > 0
If you’re paying attention, you’ll already notice that something is wrong here. x is only Negative if x < 0, not just if it isn’t positive. So let’s add a little more to this. Let’s say that x is positive if it’s above zero, and negative if below zero.
IF x > 0
ELSE IF x < 0
This is better, and makes some sense. But wait, is this good enough? When programming, we usually want the code to work for ANY data that we put into it. So we have to account for “edge cases“, times when data is not how we expect it.
Here are some possible edge cases for this problem:
- x is zero
- x is not a number
- x doesn’t exist
- x is a number, but in the wrong data type (character)
For each edge case, we have to decide what to do. If it’s zero, we can just add another ELSE IF, but in other cases, we might have to set a default value for x, change the data type of x, or make some determinations about whether x is indeed a number in character’s clothing or not a number at all. And this means that something that we thought would be easy (4 lines of code) might actually end up being twice, thrice, or more in length.
But what does this have to do with problems outside coding?
Most of the people in my program know very little if any coding. A few of them don’t ever want to touch code (even if it would improve their science). And while I don’t believe one needs to learn code to be a good scientist, every good scientist needs to understand logic. Programming is just one way to learn this and has been very helpful for me.
One of the biggest issues I see in junior scientists is how to interpret their results. Often, the results of an experiment are treated as black and white (positive or negative), and edge cases are not thought through. I’m sure we can all think of an example where a student misinterpreted their results.
The first thing I ask when I see this is “What are your controls?” If they have no controls, or even if they have only a positive or only a negative control, I ask them “Is there another explanation to what you saw? How can you differentiate between these explanations?”
This is not a failure in understanding the science. This is a failure in having sound logic.
“Good Programming” takes a long time to learn
Becoming a good programmer is a long process, just as becoming a good scientist is. However, often I see fellow graduate students focusing heavily on the science and the technique, and not on thoroughly evaluating and interpreting their data. The logic is something that they just kind of pick up along the way. I think learning logic up front has saved me several headaches (and replaced them with other headaches).
What would you say to a young scientist who thinks learning to code will never help them?
Recently, when asked about bioinformatics, a student said “I’ll never use it. It just can’t help my research.” I was appalled, not because I do bioinformatics, but because a future scientist doesn’t appreciate all the tools at their disposal. There are SO many tools available to us as scientists, and my program has “interdisciplinary” in the name, so I thought it was obvious that we should be thinking along interdisciplinary lines. But this isn’t the first time I’ve heard a student say that a certain branch of science is of no use to their research.
To a young scientist who thinks this way, I would have two things to say:
- By limiting your tools, you limit your science. The more tools you have at your disposal, the more thorough and impactful your research can be.
- If you think it can help you to understand your data, use it. If you think it can make you a better scientist, use it. But most importantly, it’s a practical way to learn logic, which is essential to any scientist’s career.
I don’t know of many ways to actually practice logic in a straightforward manner, but coding seems the easiest to me. Reading about it doesn’t actually allow you to PRACTICE it. Being told your logic is wrong by your PI doesn’t necessarily help you fine-tune HOW and WHY it was wrong. Yet, just as in the example above with x, doing small practical exercises in a language of your choice can guide critical thinking skills.
How did you learn to critically evaluate data? Do you find it difficult to think through all the possibilities? Do you actively pursue learning critical thinking and logic skills? Let me know in the comments.
If you like these posts, please consider signing up for my mailing list below. I will only e-mail you to let you know of new posts. Otherwise, you can follow my crazy life journey on Twitter, where I also post when I update.