In a fit of constructive procrastination I have programmed a function to extract colour information from a JPEG image and make a colour palette. This was inspired partly by Karthik Ram’s Wes Anderson R package.
This is how it works. First find yourself a nice image, then use the function, palettebuildr(), to extract the dominant colours. The function extracts the red/green/blue (rgb) colour values for each pixel in the image. It then calculates a distance matrix for the similarity of the colour values of each pixel. i.e. different shades of red will show up as being similar, likewise for shades of green etc. The function feeds this distance matrix into a clustering algorithm which hierarchically clusters the n pixels into n groups, based on similarity, to produce a tree object. It then cuts this tree into groups based on the desired number of groups. I used a similar algorithm to divide individual sheep into sub-groups based on their geographical location in one of the papers from my PhD (Jones et al. 2006 J. Anim. Ecol.). Once the pixels have been assigned to groups the function simply takes an arithmetic mean of the r/g/b colour values across the members of the group.
The arguments to the function are (1) the path to the JPEG file, (2) the number of colours desired, (3) the distance algorithm, (4) the clustering algorithm. The defaults for the latter two arguments are “euclidian” and “complete” – see the respective functions dist() and hclust() for details. It is worth exploring combinations of the available algorithms in some cases, depending on what you’re looking for, but the defaults seem to work well in most cases.
These palettes are naturally divergent, and might make a fun alternative to the excellent RColorBrewer colour schemes.
Here is the function, saved as a gist on github
Edit 25/2/2015 – Here’s another great example by Russell Dinnage (@ecologician) of colour palette extraction from images. This time using phylogenetic methods to generate a palette which takes into account human perception/colour luminosity.
Some species live for a very long time, others more fleeting. Bristlecone pines have remarkable life spans of around 5,000 years and in the animal kingdom, creatures like elephants, whales and tortoises are comparatively long lived. Some of these even achieve individual fame; Harriet, one of the Galapagos tortoises supposedly collected by Darwin himself in 1835, died in 2006 having reached the astonishing age of 175. At the other end of the spectrum, creatures such as the mayfly or annual plants live for just a day or a year. The lifespan of modern humans can exceed 100 years. This puts us somewhere in the middle.
Underlying these figures are demographic patterns – the trajectories of mortality and fertility that respectively capture the changing probability of death and number of offspring produced, with age.
Why do we deteriorate with age?
Considering the enormous effort that goes into creating an entire organism from scratch, it seems odd that they should degrade with time: after all, maintenance of the body should be a relatively minor task. Since deterioration with age (in humans this might be less elastic skin, weakening bones or memory loss) confers no advantage to the individual, why it happens has long been a puzzle to biologists. The esteemed Peter Medawar referred to it as “an unsolved problem of biology”.
In the 1950s, 60s and 70s, Medawar, along with George Williams, Bill Hamilton and Tom Kirkwood, set their sights on explaining why evolution had resulted in senescence – the biological process of ageing. Their theories, collectively called the “evolutionary theories of ageing”, focused on the influence of selection over a life course.
Essentially, these theories point out that after sexual maturity, evolution’s power – or the force of selection – declines because the remaining number of offspring an individual is expected to produce before its death also declines – even if its eventual death is entirely due to chance and/or has no relationship with physical deterioration.
Mutations that result in increased reproduction early in life will therefore be favoured by selection even if they come at the cost of decreased later survival. The theories say that even mutations that confer no early-life benefits will tend to accumulate, since the force of selection becomes too weak to purge them from the population. From this, the resulting trajectory of mortality should show an increase from the age of sexual maturity while fertility should decrease.
These theories form the basis for the majority of demographic research into ageing, and Hamilton once famously remarked that “no species should escape my forces of senescence, even in the farthest reaches of any bizarre universe.”
But are these patterns truly universal? To test the universality of these predictions, our team based at the Max Planck Institute for Demographic Research (the second largest demographic research body in Europe) and latterly at the new Max-Planck Odense Center on the Biodemography of Aging, gathered data to examine the demographic trajectories of a wide range of organisms.
The two main types of data for demographic studies are the life table, which records age-specific death and fertility rates, and the population projection matrix, which records transition probabilities from age-to-age or stage-to-stage, (for example juvenile to adult or small to large) and the fertility of each stage or age. Researchers have constructed these tables and matrices for decades.
We scoured the literature to obtain such data for as wide a range of taxonomic groups as possible, while ensuring that it was up to the job: we needed data that followed individuals for at least 95% of the mature life course. We defined the mature life course as the time between maturity and the age at which survivorship fell to 5%.
A simple, but novel approach was then used to standardise the trajectories of each organism across this life course to map out shapes that could be compared among species with vastly different life spans and levels of mortality and fertility.
Challenging the theory
What we found was surprising. Although many species – like humans – showed mortality trajectories consistent with the classical theories (fertility declines, mortality increases), we found plenty of violations.
In some species, such as the desert tortoise, mortality actually declined with age, while in others such as the tiny freshwater organism known as the hydra, it remained constant. There was just as much diversity in the fertility trajectories, which could be hump-shaped (increasing and then decreasing with age), increasing, decreasing or flat.
Amazingly, the shapes of the mortality trajectories were not strongly associated with the lifespan of the species. In other words, both short and long-lived species can have increasing, decreasing, or constant mortality rates. This makes sense when you think about it – even with constant mortality, lifespan will largely depend on the absolute level of mortality, not whether it is increasing or decreasing.
Vertebrates such as humans and other mammals tend to have increasing death rates and hump-shaped fertility, while plants were highly variable.
Why might this be? There are certain to be features, such as the basic body plan, that become fixed early in evolutionary history that are lacking in others, and these features may constrain the evolutionary options open to a species. To that extent our paper raises many questions.
Although the classical theories appear to work well for most mammals and birds, theoreticians will need to turn to them again if we want our theoretical understanding of ageing to be universal. Then we need to explore the data to gain an understanding of why some species don’t follow expected patterns. Of course, to do this, we should look at a wider range than we currently do.
As a start we’re going to focus on the plant kingdom, a particularly interesting group for which there is abundant demographic data. This group shows a huge diversity in their demographic trajectories, and a similarly wide range of life styles. Where they live, such as in desert, tropical or grassland regions, and what kind of plant they are.
We have a long way to go, but it’s clear that with studies such as these and those in the lab, we will slowly come to understand why species – including humans – age in the way they do. Eventually, this knowledge may even help us figure out ways of slowing, halting, or even reversing the ageing process.