Tuesday, 10 March 2015

Python for Scientists

This year, 2014/2015, we started a new MSc course: Statistics for Computational Biology. We can see that there's a huge demand for bioinformaticians, for statisticians who can read biology, and for programmers who know about statistics and can apply stats to biological problems. So this new MSc encompasses programming, statistics and loads of the current hot topics in biology. It's the kind of MSc I would have loved to have done when I was younger.

As part of this degree, I'm teaching a brand new module called Programming for Scientists, which uses the Python programming language. This is aimed at students who have no prior programming knowledge, but have some science background. And in one semester we teach them the following:
  • The basics of programming: variables, loops, conditionals, functions
  • File handling (including CSV)
  • Plotting graphs using matplotlib
  • Exceptions
  • Version control using Git/Github
  • SQL database (basic design, queries, and using from SQLite from Python)
  • XML processing
  • Accessing data from online APIs 
We taught it as a hands-on module, lectures held in a room full of computers, programming as we go through the slides, with exercises interspersed and demonstrators on hand to help.


We had students sign up for this module from a surprisingly diverse set of backgrounds, from biology, from maths, from geography and even from international politics. We also had a large number of staff and PhD students from our Biology department (IBERS) who wanted to sit in on the module. This was a wonderful group of students to teach. They're people who wanted to learn, and mostly just seemed to absorb ideas that first year undergraduates struggle with. They raised their game to the challenge. 

Python's a great language for getting things done. So it makes a good hands-on language. However, it did highlight many of Python's limitations as a first teaching language. The objects/functions issue: I chose not to introduce the idea of objects at all. It's hard enough getting this much material comfortably into the time we had, and objects, classes and subclasses was something that I chose to leave out. So we have two ways to call functions: len(somelist) and somelist.reverse(). That's unfortunate. Variable scoping caught me out on occasion, and I'll have to fix that for next year. The Python 2 vs Python 3 issue was also annoying to work around. Hopefully next year we can just move to Python 3.


What impressed me most was the quality of the final assignment work. We asked the students to analyse a large amount of data about house sales, taken from http://data.gov.uk/ and population counts for counties in England and Wales taken from the Guardian/ONS. They had to access the data as XML over a REST-ful API, and it would take them approximately 4 days to download all the data they'd need. We didn't tell them in advance how large the data was and how slow it would be to pull it from an API. Undergrads would have complained. These postgrads just got on with it and recognised that the real world will be like this. If your data is large and slow to acquire then you'll need to test on a small subset, check and log any errors and start the assignment early. The students produced some clean, structured and well commented code and many creative summary graphs showing off their data processing and data visualisation skills.

I hope they're having just as much fun on their other modules for this course. I'm really looking forward to running this one again next year.

Monday, 9 March 2015

International Women's Day pub quiz

On Sunday 8th March 2015, Hannah Dee and I organised a pub quiz for International Women's Day. We wanted to highlight some famous women in science, but we don't expect people to know much about famous women in science. So how to do a quiz? We themed 5 rounds around the women:

1) The Mary Anning fossil hunting round
A huge word search with many words related to Mary Anning's work and fossils to find (including "ichtheosaur" and "she sells sea shells", "on the sea shore".

2) The Amelia Earhart aviation round
Create paper aeroplanes that will travel from Europe (over here) to America (over there) and land within an area marked by a hula hoop. We should have had planes crossing the Atlantic in the other direction, but oh well, we're in west Wales.

3) The Caroline Herschel stargazing round
Early astronomy was often about spotting small differences in maps of the heavens. Thanks to heavens-above.com we had a copy of the sky map for the evening, and another copy that had been modified with gimp. Spot the difference! Three Gemini twins?

4) The Barbara McClintock genome round
Here we used C. Titus Brown's shotgunator to make a set of short reads from a few sentences about the work of Barbara McClintock. The teams had to assemble the genome to decipher the sentences. It must have seemed as if transposons were at work, because with a few repeated words the sentences they were constructing did get rather jumbled.



5) The Florence Nightingale data visualisation round
Finally the teams got to use a box of stuff (pipe cleaners, stickers, fluorescent paper, googly eyes, coloured pens) to make the most creative version of this year's HESA stats on women employed in higher education.

The scales of employment in HE


No trivia or celebrities in the quiz at all!

Friday, 18 July 2014

Microscope webcam microtitre plate reading using image analysis

An A-level student has just spent two weeks with us for his work experience, and his project has been to investigate the use of a cheap microscope webcam as an alternative to an expensive plate reader for the measurement of the growth of yeast in microtitre plates. The longer term aim would be to mount this webcam on the deck of our Tecan Genesis liquid handler robot, and to have the robot arm move the plate under the webcam.

The webcam is a Veho VMS-004, used at 20x magnification, and it costs just £40. It was recognised automatically by Linux as a webcam and worked really well with the OpenCV library.
Robert Buchan-Terrey did an excellent job in interdisciplinary science in just two weeks, including the following:
  • Preparing media and growing yeast in our lab
  • Pipetting the yeast to make dilutions
  • Using the microscope webcam, taking images of the wells in the plate at intervals throughout the day, and corresponding plate readings with a real plate reader
  • Coding using Python and OpenCV to process the images (find the circular well, work out the average pixel intensity in the well)
  • Data analysis and stats to understand the results
He also produced a poster to demonstrate the findings and to take back to his school.

And the answer is: although he's just analysed the data from one time point so far, and we took no care to make sure the lighting conditions were stable when taking the images, or to shake the plates to evenly disperse the yeast, it really does look very plausible that we could use this in future. Averaging over 8 replicate wells gives a remarkable correspondence between image-analysis results and plate reader results. Individual wells are more variable, but still show promise. We've yet to test all the data, and to test the full range of the scale of optical density, but this looks extremely exciting.

Thanks very much to Wayne Aubrey and Hannah Dee for their help and expertise with the yeast biology and the image processing respectively.

Saturday, 21 June 2014

The Genome Game with Countdown and High Score Table

The Genome Game now has a part where you have to guess the rules (correspondence between genotype and phenotype) before the time runs out. If you guess correctly then you get to join the (local storage) high score table. It's also bilingual now, so you can play in the medium of Welsh.

http://genome-game.dcs.aber.ac.uk/game


Friday, 13 June 2014

Sewable wearable computing

I gave this as a very short talk at the recent BCS Mid-Wales Show and Tell. So I'm describing it here in case it's of use to others.  The presentation was mostly a collection of rather large photos but it can be downloaded at http://figshare.com/articles/Sewable_Wearable_Computing/1056536. I was inspired to give it a go by Charlotte Godley (@charwarz on Twitter) who ran a wearables workshop for Girl Guides using Adafruit Gemmas.  These are small Arduino chips on a mounted on a base, made by a company called Adafruit. The base has holes so that you can sew it onto items of clothing. Slide 2 shows a Gemma attached by crocodile clips to an LED, a light that can be programmed to flash in any colour. The Gemmas are very cheap, only £6.50 so you can safely play with electronics without spending too much if you break it.



Steel thread can be used to sew your Gemma to its LEDs. This conducts and so replaces the crocodile clips (or soldering bits of metal) when you want to make wearable electronics. It's not that easy to sew. It doesn't bend and tie as easily as thread does, and can come undone, and make short circuits when it crosses other bits of thread. Also, the longer the thread, the higher the resistance.



After the Gemma, I got a Flora, it's bigger sister. This costs approx £20, and has more available connections. I wanted to attach an accelerometer and lights, and have the lights flash different colours in order to demonstrate the x, y or z direction of movement. The presentation shows how I put it together and how much it cost. You can see how it was stitched, how I used nail varnish to stop the knots in the ends of the steel thread from unravelling, and how it gets programmed using the Arduino environment.



The Adafruit site has a lot of useful explanations and videos about the Gemma and the Flora. You can buy the equipment from many sites (I used Phenoptix and 4tronix, both were good).


Overall, it was fiddly, but a lot of fun. Computing projects that have an element of real hardware, poor connections, and many parts, each of which could be wrong, are always harder to debug than software. I've never really played with electronics before, and I ended up learning a lot even in this simple project, about power, resistance and circuits. And I now have a thing with flashing lights that I can wear on my leg while dancing the Charleston.

Sunday, 20 April 2014

Lovelace Colloquium 2014

This year I'm not going to write about the fact that the Lovelace Colloquium is for women undergraduates in computer science because I already did this in 2012 and 2013. And I won't write about how much fun it was this year, because Charlotte has already done that.

I'm just going to mention that after the conference, on the way home, changing trains at Birmingham International, I went to browse WHSmiths for something to read on the train.


Yes, the computing magazines are in the section labelled "Mens Lifestyle". Not for us women. We can have interiors, weddings, home and travel. I don't know why even WHSmiths wants to discourage us from computing. Why do they need to separate the magazines by gender instead of by topic anyway?

Then, on the train, I saw a blog post on my twitter feed about the NSF Waterman award, which has been won by men for the last 10 years in a row.  All I can hope is that the women undergrads who entered and presented at Lovelace 2014 will now continue to enter many competitions for their work in science, to continue to present their work at conferences, to feel that they can enjoy computer science (whatever our high street shops try to tell us) and to win far more recognition than we do at present.

Update: Also see what Michelle Brown thought of Lovelace 2014.

Monday, 3 March 2014

Western Mail article about bioinformatics

As part of the Welsh Crucible I had an article in the Western Mail today. How computer science can solve problems in biology. We were asked to explain our work in 400-500 words (they chose the title). Much more challenging than I thought it would be, because that's not very many words.