Friday, 28 October 2016

Pretty patterns in R

The past two weeks has been all about programming in R, a language that's supposed to be the next great thing for statistics and computational biology. I'd already covered it in my last course and it was a source of great pain. This has been less pressured, but still challenging.

The highlight so far has been one section on building graphs. As far as I can tell, the beauty of R is that you can plot an awful lot of things in an awful lot of ways, but making even a simple line graph is waaaay more complicated than you'd imagine. This exercise was all about how to make a fairly complex graph from a matrix of data and then strip it all down to pretty quilt patterns. You should be able to paste this all into R (or RStudio) and run it, though I'd do it line-by-line to avoid formatting errors:


install.packages("ggplot2")
require(ggplot2)
require(reshape2) #reshape2 comes included with the basic R download

#We're going to plot a matrix of random values taken from a normal distribution #[0,1]. Because ggplot2 only accepts dataframes, we'll use reshape2 to 'melt' the matrix into a dataframe.

GenerateMatrix <- function(N){
  M <- matrix(runif(N*N),N,N)
  return(M)
}
GenerateMatrix(3) #The function fills a matrix with N*N random numbers from the uniform distribution. The matrix is N rows by N columns. So, the fill and size match.

M <- GenerateMatrix(10)
M #It's a 10 by 10 matrix
M[1:3,1:3] #Square brackets specify what you want to look at: this views just the first three rows and columns
Melt <- melt(M)
Melt[1:4,] #This object has many many rows (we see the first 4) and 3 columns (Var1, Var2 and value)

ggplot(Melt,aes(Var1,Var2,fill=value))+geom_tile() #The fill=value is what colours each tile according to its value. What a pretty diagram. But, we can make it prettier.

#Saving the plot as an object:
Plot <- ggplot(Melt,aes(Var1,Var2,fill=value))
Plot #It's just the blank plot; we're about to add another layer
Plot <- Plot+geom_tile()
Plot
#Removing the legend:
Plot2 <- Plot+theme(legend.position="none")
Plot2
#Removing all the rest:
Plot2 <- Plot+theme(legend.position="none",
            panel.background=element_blank(),
            axis.ticks=element_blank(),
            panel.grid.major=element_blank(),
            panel.grid.minor=element_blank(),
            axis.text.x=element_blank(),
            axis.title.x=element_blank(),
            axis.text.y=element_blank(),
            axis.title.y=element_blank())
Plot2 #It's now just a lovely blue grid
Bathroom tiling


#Exploring the colours:
Plot3 <- Plot2
Plot3+scale_fill_gradient2()
Flowers for grandma

Plot3+scale_fill_continuous(low="yellow",high="darkgreen")
Aftermath of limeade explosion

Plot3+scale_fill_gradientn(colours=c("red","white","blue"))
Picnic blanket with a touch of chaos

Plot3+scale_fill_gradientn(colours=grey.colors(10)
Dodgy aerial connection (for anyone who remembers what an aerial is)

Plot3+scale_fill_gradientn(colours=rainbow(10))

My eyes are watering

Saturday, 22 October 2016

Dinky interstitial phyla

The first week or so of this taxonomy course was a whizz through the tree of life, to get us all familiar with most types of organisms at the most basic level. One lecture managed to cover all fourteen phyla in the group of animals called Lophotrochozoa. For perspective, a phylum is a very deep level of organisation for animals that divides them by their basic body plan. Phyla vary hugely in how many species they contain, but we belong to the phylum Chordata, which contains every single vertebrate plus a few of our very close invertebrate relatives, like tunicates (sea squirts). The lecturer did a fine job of not running out of breath.

I'd met all of Lophotrochozoa briefly before, on my biology course, and two phyla stood out both times. I'd doodled them to try and remember what they looked like, and they are just adorable. Both contain exceedingly tiny animals that live between sand grains - that makes them 'interstitial', in the same way that animals that live on the sea floor are benthic. Meet Kinorhyncha and Gastrotricha respectively, in fabulous microscopy:

http://palaeos.com/metazoa/ecdysozoa/scalidophora/kinorhyncha.html
https://tl.wikipedia.org/wiki/Talaksan:Gastrotrich.jpg



















I know, they're like hairy sausage puppies with bowl-cuts and glitter, right? And in less fabulous Paint.NET (not to scale):


Or even in the Vesryn region:





References
Kinorhynch photo:
http://palaeos.com/metazoa/ecdysozoa/scalidophora/kinorhyncha.html
Gastrotrich photo:
https://tl.wikipedia.org/wiki/Talaksan:Gastrotrich.jpg
Screenshot adapted from Pokemon Zeta, a real gem of a game: https://www.reddit.com/r/pokemonzetaomicron/

Friday, 21 October 2016

Lattices and lettuces

I get hungry when working alone on the laptop and, if I'm going to get distracted by looking for something on the Internet, it will be food. I have a folder of recipes that's a direct result of this. It's a mixed blessing. Yesterday, I was working on a type of graph called lattice plots, and all I could think of were things like this1:

Not something that appeals to me nowadays (vegetarian), but a nice reminder of the times when somebody cooked for me. I've developed a morbid curiosity for highly processed, dirt cheap food, and was delighted to discover that someone has dedicated a blog to their exploration of it: www.barelyedible.co.uk It's a shame that most of the really impressive terrible food out there is meat-based as I'd love to join in.

In the meantime, I'll continue to look for yellow stickers in supermarkets on slightly less entertaining items. A really good recent find was this wonderful thing:


I'd eaten most of the big leaves a few days ago and the medium ones are quickly filling the gaps. There are too many plants in there for them to really grow healthily, but hopefully enough will hang on to feed one person a salad once in a while. I did keep another supermarket live pot on my desk for most of last year (Basil the basil, pronounced à la Sybil Fawlty) and three plants are just about still alive. Unlike most organisms, window plants like these succeed at being loveable even while you eat them.


References (as a good scientist I cite my sources)
1 http://www.mysupermarket.co.uk/tesco-price-comparison/Pies_And_Quiches/Tesco_Creamy_Chicken_Garlic_And_Mushroom_Lattice_Pie_550g.html

Monday, 17 October 2016

The French grass snake

My summer holiday this year involved a visit to the lovely French countryside. Best of all, a sun-baked barn in the place we were staying had become the final resting place of a very large grass snake (Natrix natrix), reduced to mostly skin and bone by the time we left. I toyed with the idea of taking the whole thing back but was wisely convinced to just snip the head off. I wrapped it in kitchen roll, taped it securely into part of an egg box and managed to get it home unscathed via three trains and a metro.

For the next few weeks I had the fun job of cleaning away the remaining mummified tissue and reassembling the skull and some cervical vertebrae. Some little palatal bones were damaged already, and tragically I snapped one with a vacuum cleaner and never found the end, but overall it's quite intact. I left the cervical ribs and some loose teeth out because they were SO fiddly, perhaps to try again one day. She* now sits proudly on my little nature shelf at home, in a perfectly-sized sputum collection vial never used for its intended purpose.

(A, left lateral; B, dorsal; C, ventral; D, posterior; E, anterior views from a slightly shaky photographer)

The holiday spot turned out to be a great place for snakes. I even managed to catch a little one by leaping at it Irwin-style, but immediately felt very sorry for it while it writhed around and ineffectually tried to bite me. It quickly went back into the wall. I hope the locals are kinder to their lovely reptiles.


*Wikipedia tells me that male grass snakes only get to about 50cm long, so at about a metre, mine was certainly a lady.

Tuesday, 11 October 2016

Why moths are attracted to lights

Yesterday was Plant Day, but first I thought I'd share something from last week's arthropod session. One of the entomologists revealed the answer to a something that has puzzled me for a long time: why moths are attracted to lights. It turns out to be a feature of moth navigation that works very well using natural light sources, but isn't well adapted dealing with human ones.

Younger moths navigate at night using light sources in the sky, like stars (older moths switch to using landmarks). Because the stars are so far away, the moth can fly in a straight line by maintaining a constant angle to where the star appears to be:



But artificial lights are significantly closer than stars, so when a moth flies at a constant angle to one it needs to keep compensating for how the light source 'moves', leading it into a spiral:



So, light pollution pulls moths away from their important nightly activities by making them fly in circles until the sun comes up. Do moths a favour by switching off unnecessary lights at night.

Saturday, 8 October 2016

Catching arthropods

So, lectures started on Thursday. Those and the ones next week will be an overview of the tree of life, getting us all up to speed on what things are before we start looking at more complicated things. There were some excellent speakers - you can really tell when a lecturer is enjoying themselves.

After whizzing through early vertebrates and fungi on Friday morning, we spent the afternoon learning how to catch terrestrial arthropods. This involved swinging nets and beating trees and digging holes around the NHM wildlife garden, to the amusement of passing visitors. The soil samples were taken back by one of the entomologists to be processed over the weekend: you can separate critters from crud by pouring the samples into a funnel and shining a lamp over the top. The animals normally move away from light (they show negative phototaxis), so they gradually crawl downwards and fall into a collecting pot.

We could see the things beaten out of trees straight away - indeed, a few flew off as soon as they hit the collecting sheet. It was great to have experts on hand to identify them, though by the end of the session one was suffering after pootering up lots of hemipterans (true bugs) that released unpleasant fumes. One of the most interesting creatures was another hemipteran, probably a thread-legged bug (Emesinae) according to a quick Internet search. It looked like a tiny tiny stick insect, about 1.5 centimetres long, but had front legs just like a mantis.

However, the highlight of the afternoon was near the beginning, when we were standing in the meadow for a long while watching a trap being set up. All of a sudden, someone noticed an inch-long common frog on their shoe. Soon we'd seen half a dozen of them hopping around in the grass, and everyone became very conscious of where they were putting their feet. The shoe frog stayed safe on high ground until we'd gone.

Thursday, 6 October 2016

Beating biology

Today I was waiting at a crossing with a four-year old girl and her carer.

Girl: I don't want to marry a man.
Lady: Why's that?
Girl: I never want to have babies. That's why I want to marry a lady.
Lady: You know, if you marry a lady you can still adopt babies.
*Girl's face falls*

Wednesday, 5 October 2016

Dinosaurs at the NHM

Not to brag, but my course is mostly being taught in London's Natural History Museum. In between induction things this week, I've been taking a quick look around the galleries, partly to try and learn my way around but mostly because museums are fantastic and the NHM has a stellar reputation.

Most things were great, I'd like to make that clear. But the dinosaur gallery, the most anticipated part for me, was a bit disappointing. On the whole it seemed very well designed, and there were some fabulous mounts and no glaring errors in the text. There were lots of touchables and the school party in with me was having a great time. Unfortunately, every few minutes I'd notice something out of date, and with the exception of a note about feathered dromaeosaurs I didn't see any corrections.

The theropods were most obvious: there were several pronated hands*, though not universally, and many an upright body in the images. I quite enjoy retro palaeoart (I'm pretty sure a print of this was in there, carrying on the timeless trope of Deinonychus vs. Tenontosaurus: http://www.johnsibbick.com/library/display.asp?page=15&product=D15), but not when it's presented alongside up-to-date information with no caveat. There was also a case of nice shoebox-sized dinosaur sculptures, but again, most were totally vintage. There was even a humpy Stegosaurus that could have passed for a 1975 Invicta**.

In a shot at redemption that somewhat missed the mark, there were two animatronic Deinonychus near the end, with the note about feathers, that were indeed feathered. Unfortunately, I don't think they looked great. Most of the body had a short, shaggy coat that looked more like fur, with a token row of vaned feathers along each forearm and bare hands. I'm not basing this on primary sources, but I was under the impression that feathers in dromaeosaurs likely covered the hands to form a pretty clear wing, even if they didn't grow from the fingers. And, sadly, the hands were pronated.

Unfortunately, as I've grown more knowledgeable about dinosaurs I've just gotten more thorough in nit-picking. It was a fun exhibition with some solid science and great displays, just lacking in corrective signage. Hopefully it will get an update eventually, and the museum can help catch the public up with scientists.

I'd like to note that (at least on a quick view) I have nothing bad to say about the other galleries, and palaeontology is a particularly fast-changing thing. I have yet to see a dinosaur exhibition I can't pick faults with. Guess I'd better make one one day!


*The eminently readable Dave Hone explains the pronation problem: https://archosaurmusings.wordpress.com/2009/05/27/theropods-are-clappers-not-slappers/

**My summer guilty-pleasure reading: http://dinotoyblog.com/2010/07/22/stegosaurus-invicta/

Another footnote: I have the inevitable start-of-term cold today so might have been feeling less charitable than usual.

Early observations


So far this week, I have...
  • Seen my first ring-necked parakeets, flying overhead. They sounded like a cross between a squeaky toy and a particularly irritable sparrow.
  • Encountered my first manspreader on the Tube. I was bunched up against his right thigh. Thanks.
  • Sat in class doing nothing for half an hour when we were supposed to have an IT induction, because IT didn't know we were supposed to have an IT induction.
  • Sat in a lecture theatre watching colleagues play charades for half an hour when we were supposed to have a safety induction, because we'd all been given the wrong room for the safety induction.
  • Got lots of exercise in a futile search for said safety induction.
  • Lost faith in the organisational ability of the university.

Grey snot

Hello world,

I've just moved to London to start a course on taxonomy, the area of biology that deals with naming and classifying things. I'm hoping it will suit my joint interests of organising things and dinosaurs.

It's been a long couple of days; I moved into my new rented room on Sunday afternoon, then Monday was a 13-hour day of going through induction and shopping for things I'd forgotten. But I've been impressed with the efficiency of the Tube so far, and walking through central London is entertaining, if a bit surreal.

I'm going to try and use this blog to keep a record of what's sure to be a strange twelve months. It's my first permanent move away from home (the holidays during my undergraduate degree made me feel like a part-timer) and hopefully the first major step towards Dream Job. I'd love to be a natural history curator. I just hope museums will still have paid staff by the time I qualify!

Final thought: since moving down I've produced grey snot. There's no air pollution like London air pollution.