Sunday, September 28, 2014

Long Lab (summer fun edition)

L->R: Arnold Mak, David Filice, Katie Plagens, Tristan Long, Thiropa Balasubramaniam, Mireille Golemiec, Emily Martin


How to (truly) randomly assign mating treatments - an elegant R approach

This week in the lab we'll be setting up some experiments using our 45 inbred lines of flies (lines were inbred by mating sets of single male an females, derived from the IV line, and subsequently selecting a single brother and sister from the resulting offspring to found the next generation. This process was repeated for >10 generations).

In the experiment we want to randomly pair males and females from different lines, which in R seems pretty simple, as you can use the code

inbred.lines <-c(1:45)
random.mates<- sample(inbred.lines, 45, replace = FALSE)
combos <-cbind(inbred.lines, random.mates)

Which (most of the time) will end up with randomly pairing males and females from different lines....
...However, as this is a random process, there is a chance that R might by chance choose pairs of males and females from the same line. This may not seem a big issue, as you could use a simple logical argument such as


to make sure that there were no matches, and re-run the random sampling if any TRUE values returned by the last command until all pairs were different.

This "brute force" approach is OK, I guess, but becomes much less efficient if we want to place two (or more) males, each selected from a different line in with females. Now we might get a TRUE value if we had a match between the female and "male 1" ,  a match between the female and "male 2", or  a match between "male 2" and "male 1". You can imagine how this problem can get more difficult as the number of combinations increases with the number of males and females in each vial (see Handshake Problem).

So, as I could not find a solution online, I have developed some R code to quickly and elegantly solve this problem.
Let's begin as above

inbred.lines <-c(1:45)

Here is my solution

for (i in 1:length(inbred.lines)){treatmentBB<-sample(inbred.lines,45)}
if (treatmentBB[i]==inbred.lines[i]) {treatmentBB<-sample(inbred.lines,45)} else{treatmentBB}

As you can see in this code, I am creating a new column "treatmentBB" that I am populating with 45 randomly sampled numbers (with no replacement) from the inbred.lines vector. The next step is to ask R to check if any of the rows match. If they do, then we ask R to start all over again, but if there are no matches, then to leave treatment BB alone.

Now let's expand this to see if we wanted to add a second (random male) into each treatment, by creating a column of values called treatmentEI. As you can see below, I have taken into account potential matches between "females and males from treatmentBB", "females and males from treatmentE1", and "males from treatment E1 and males from treatmentBB"

for (i in 1:length(inbred.lines)){treatmentE1<-sample(inbred.lines,45)}
if (treatmentE1[i]==inbred.lines[i]|treatmentE1[i]==treatmentBB[i]) {treatmentE1<-sample(inbred.lines,45)} else{treatmentE1}
Created by Pretty R at

and If I wanted to add a third, I would need to make sure that all possible matches are accounted for... 

for (i in 1:length(family)){treatmentE2<-sample(family,45) if (treatmentE2[i]==family[i]|treatmentE2[i]==treatmentBB[i]|treatmentE2[i]==treatmentE1[i]) {treatmentE2<-sample(family,45)} else{treatmentE2}}

Hope you find this useful!

Wednesday, June 25, 2014

Setting up for a hemiclone assay

 Several of the assays we are conducting in the lab this summer are examining the genetic basis of female mating behaviours. There are many ways to do these assays, but (in my opinion) one of the best ways to measure ofstanding genetic is using hemiclonal analysis. Both Mireille and Arnold (above) have been learning the ropes of this technique, and this week set up the first (of many) assays.

The first step involves mating clone males (which carry a randomly-sampled haploid genome, and set of translocated autosomal chromosomes) with many wild-type virgin female collected from one of our outbred populations. These mated flies are placed into half-pint collectors outfiltted with 35mm (diameter) petrie dishes containing a grape-juice/agar media for no more than 18h.

During that time, eggs are laid on the surface (see above).
As fruit fly development can be strongly influenced by variation in larval density, it is essential that our assay vials are standardized. This is done by counting exact numbers of eggs (under the microscope, using a paintbrush)...
...which are then gently cut from the surface of the juice "cookie"....
...and transferred to vials containing ~10ml of our lab's standard banana Drosophila media!
Due to the nature of the cross between the clone males and the wild-type females, there is a 50% mortality (due to chromosomal imbalances). Thus, for every 100 eggs we transfer into the vial, only 50 will hatch into larvae. To further establish standard developmental conditions in the vials, we add an additional 50 eggs from one of our other populations that carry a recessive-brown-eyed marker, yielding a total of ~100 larvae per vial (which mimics the typical developmental conditions experienced in the our lab populations).

Now that our vials are set up, we'll incubate them, and then collect hemiclonal (red-eyed) females as they eclose starting 9d later. Check back for updates!

Sunday, June 22, 2014

More great news!

I'm a little slow to post this, but last week was also Spring Convocation here at Laurier. It was great to see all the lab alumni (Ashley Guncay, Leah DeJong and Conor Delar) walk across the stage. After the ceremony, I had the honour of presenting Leah DeJong with the 2013-2014 Rick Playle Award for Best Thesis! Congratulations Leah!
Incidentally, Leah is the third student from the lab to win this award (following Erin Sonser in 2012-2013, and Jessie Young in 2011-2012)!

Bac(teria) to the Future

This week, the Long Lab was very busy examining the relationship between immunocompetence and parental characteristics (using fruit flies, as a model organism). This work, which began in the Fall with the work of Ashley Guncay (co-supervised with Dr. Joel Weadge) is being continued by two of our lab's summer students Katie Plagens & Thiropa Balasubramaniam (seen here with their flies). 

  So far this summer, Thiropa & Katie have been busy, first learning the ropes of fly pushing, then in running behavioural assays, and setting up immunocompetence assays. All of this has led up to the events of this week - a massive bacterial plating assay. It was hard work (but very rewarding), and would not have been possible without the concerted work of everyone in the lab (as well as many kind expert volunteers from the Weadge lab)!
Briefly, from each vial of flies (top), 5 (virgin) individuals were collected. They were then homogenized in LB media in order to release their bacteria into the solution. The next step is to create a serial dilution of the solution (transferring 10ul in succession into vials containing 90ul of LB media). These solutions are then plated onto petrie dishes (below) which are then checked on the following day for bacterial growth. The number of colonies on each plate (below) are counted, and from this, we can estimate the bacterial load of the original flies.

Ready for action!

Sunday, June 1, 2014

How to create a multi-panelled line graph with error bars in ggplot2

#Below you will find some code that I cobbled together from various sources to create a multi-panelled line graph with error bars
#first I need to load the file and the ggplot2 package
#FYI I am using ggplot v 0.8.9 on R 2.13.1 (I know, I should upgrade!)
#if you look at the file 
# you will see the mean (and sd), and median scores on a standardized student survey for each of the last 3 years of my BI393 Biostatistics class (useful data for preparing a tenure application file). As the QUESTION column is a bit long & unweildy, I will force it to break every 70th character (helps with the formatting of the strip text in gglplot)
BI393$groupwrap = unlist(lapply(strwrap(BI393$QUESTION, width=70, simplify=FALSE), paste, collapse="\n"))
#now, to business: I want to plot the mean scores for each question by year
printing<- ggplot(BI393,aes(x=as.factor(YEAR),y=MEAN,colour=QUESTION))
#and add on some error bars
#connect the points with colour-coded lines
+geom_line(aes(group = QUESTION))
#and make the points clear to see
+geom_point(shape=21, fill="white")
#adjust the range of the y-axis, and customize the x-label
+ylim(1,7.5)+xlab("Academic Year")
#change the background colours
#wrap the scores by the questions
+facet_wrap(~ groupwrap,ncol=3)
#and get rid of a pesky legend (as the question is in the strip text)
#make an informative y-axis label
+ylab(expression(paste("BI393 Scale Grade (Mean" %+-% "1SD)")))
#and now print it off...
ggsave(printing, file="396.png", width=10, height=10)
Created by Pretty R at

Wednesday, May 7, 2014

A big week for Hannah Tennant

This week is shaping up to be a big week for our very own MSc candidate Hannah Tennant. First of all she defend her thesis tomorrow (the 8th)[UPDATE MAY 8th: HANNAH PASSED WITH FLYING COLOURS- CONGRATULATIONS!!!]. 
I have created a wordle based on her thesis text - can you guess what she has been working on?
Secondly, one of Hannah's thesis research chapters has reached the press! Congratulations!

BMC Evolutionary Biology 2014, 14:95  doi:10.1186/1471-2148-14-95

Hemiclonal analysis of interacting phenotypes in male and female Drosophila melanogaster

Hannah ME TennantErin E Sonser and Tristan AF Long
Identifying the sources of variation in mating interactions between males and females is important because this variation influences the strength and/or the direction of sexual selection that populations experience. While the origins and effects of variation in male attractiveness and ornamentation have received much scrutiny, the causes and consequences of intraspecific variation in females have been relatively overlooked. We used cytogenetic cloning techniques developed for Drosophila melanogaster to create "hemiclonal" males and females with whom we directly observed sexual interaction between individuals of different known genetic backgrounds and measured subsequent reproductive outcomes. Using this approach, we were able to quantify the genetic contribution of each mate to the observed phenotypic variation in biologically important traits including mating speed, copulation duration, and subsequent offspring production, as well as measure the magnitude and direction of intersexual genetic correlation between female choosiness and male attractiveness.
We found significant additive genetic variation contributing to mating speed that can be attributed to male genetic identity, female genetic identity, but not their interaction. Furthermore we found that phenotypic variation in copulation duration had a significant male-associated genetic component. Female genetic identity and the interaction between male and female genetic identity accounted for a substantial amount of the observed phenotypic variation in egg size. Although previous research predicts a trade-off between egg size and fecundity, this was not evident in our results. We found a strong negative genetic correlation between female choosiness and male attractiveness, a result that suggests a potentially important role for sexually antagonistic alleles in sexual selection processes in our population.
These results further our understanding of sexual selection because they identify that genetic identity plays a significant role in phenotypic variation in female behaviour and fecundity. This variation may be potentially due to ongoing sexual conflict found between the sexes for interacting phenotypes. Our unexpected observation of a negative correlation between female choosiness and male attractiveness highlights the need for more explicit theoretical models of genetic covariance to investigate the coevolution of female choosiness and male attractiveness.

Thursday, April 3, 2014

A sticky situation!

Our lab was recently gifted with a fork-leaved sundew Drosera binata. It's first few weeks were a bit touch-and-go (it was chilly outside the day it was brought to us), but as you can see, it has started the Herculean task of catching our rogue flies using its stick trichomes.

Wednesday, March 26, 2014

Direct fitness consequences of male mate size in Drosophila melanogaster

As previously mentioned back in the infancy of this blog, one of the tools we have in our lab is a sieve shaker system, which was originally designed in the Rice Lab at UCSB as a way to quickly sort phenotypic variation in body size in our Drosophila melanogaster populations. Recently (3 weeks ago), Pam (an incoming member of the Long Lab) set up a simple experiment as part of her fly-lab training. We were originally planning to look at differences in mating speed in single females placed into vials along a single male (from one of three treatments: "Large" - flies that had not passes through the holes in the 1420um sieve; "Medium" - flies that had passed through the holes in the 1262um sieve, not through the holes in the 1214um sieve; and "Small" - flies that had passed through the 1079um sieve). 

However, it transpired that the flies were not really co-operating (the subject of a post for another day), so instead we decided to change the assay (on the fly, so to speak) into an examination of how offspring production differed between the three treatments. We left the pairs of flies in the vials for 48h, then flipped the pairs into a second vial for a final 48h before being discarded. The vials were then incubated for 14 days, and then Pam & I counted the number of eclosed vials. Here are the results of this assay:
Right from the start, there is greater fecundity in the first 48h there was a difference in mean offspring production (ANOVA, F=4.5871, df=2,58, p= 0.014), with the lowest reproductive output coming from the Large male treatment, and the greatest from the small male treatment.
This pattern continued in the next 48 period. (ANOVA*, F=5.0757 , df=2,58, p= 0.009)
And not surprisingly, when data from the two 48h are combined (ANOVA*, F=8.0934 , df=2,58, p= 0.0007)

Now observations of this phenomenon is not new. There have been several studies that have shown this pattern including:

Pitnick, Scott, and Francisco García–González. "Harm to females increases with male body size in Drosophila melanogaster." Proceedings of the Royal Society of London. Series B: Biological Sciences 269.1502 (2002): 1821-1828.
Friberg, Urban, and Göran Arnqvist. "Fitness effects of female mate choice: preferred males are detrimental for Drosophila melanogaster females." Journal of evolutionary biology 16.5 (2003): 797-811.

..but I should note that in both of these (excellent, by the way) studies, male size was experimentally manipulated by varying the density of competing larvae, or the quality of their food. Our flies, which came from a large, outbred population (IV), had been cultured according to our standard laboratory protocol, so this shows that this phenomenon is something routinely encountered by female flies in the lab population, and not an artifact of the experiment. A the very least, it is a good snapshot of some of the selective pressures resulting for mate choice in this model species, and is a fun introduction to Pam to the world of behavioural ecology/evolutionary genetics.

Future studies will be focusing on more fine-scale variation of this phenomenon, and more importantly see how this aligns with observations on female mating preferences and/or the outcome of male-male competition, and even more importantly in the behaviour and fitness of the offspring. -TAFL
By the way, I used ggplot to make these graphs. Here is some sample code.

> jpeg("CUMULATIVE_eggs.jpg",quality=100)
> qplot(PAM$TREATMENT, PAM$CUMULATIVE, data=PAM, geom=c("boxplot"), 
+    fill=PAM$TREATMENT,
+    xlab="", ylab="Eggs laid over 96h")+ opts(legend.position = "none")
Created by Pretty R at

Thursday, February 20, 2014

Happy Valentine's Day from the Long Lab!

Things have been pretty busy these last couple of weeks. Both Ashley and Leah continue to analyze and interpret their results, the experimental torch has been taken up by Emily and Shada who are collaborating on a project that looks at variation in pre-copulatory behaviour and mate perception, and the post-copulatory consequences. One of those consequences is egg production and size, which led to this beautiful (and season appropriate) image of fruit fly eggs! Hope you enjoy!