Installing package xlsx in R on Ubuntu

I had some problems installing the R package xlsx due to a failure from R not being able to find the Java runtime. I found a pretty quick fix for it on Stack Overflow that simply involved running

sudo R CMD javareconf

the command line. Quick and simple.

Phun with Phylogenies: Part 1

So I’ve started working on a phylogenetic project, after a long break from anything directly working with them. As such, I find myself back at the beginning of having to learn how to do a few things again, in particular the powerful yet cryptic program known as TNT (“Tree analysis using New Technology”). To get TNT started on a Linux box, follow the steps below:

Step 1: Download TNT from http://www.lillo.org.ar/phylogeny/tnt/

Step 2: Save your matrix/nexus files into TNT format using some of the tips here: https://matthewvavrek.com/2011/10/19/tnt-and-ubuntu/

Step 3: Navigate to the TNT folder in a terminal, and then spend 10 minutes trying to figure out why TNT isn’t running when you type in “sudo ./tnt”

Step 4: Realise you wasted 10 minutes because all you had to do was make sure the “tnt” file (the one in the folder you downloaded) was made executable; do this by navigating in a terminal window to the TNT folder, then type in “sudo chmod +x tnt”.

Step 5: Sigh deeply, and come to the realization that using TNT again after not having touched it for 4 years is unlikely to be “phun” at any point.

 

New online home for NADP

Just a quick note announcing our new website for the Northern Alberta Dinosaur Project:

https://northernalbertadinos.wordpress.com/

The NADP is an international group of palaeontologists, all with a shared interest in the palaeontology of the northwestern Alberta Wapiti Formation. Please check out the site to see bios on all of our members, publications on the Peace Region, and news about recent discoveries from the region.

So you need research grant…

One thing almost every researcher needs to deal with, at some point or the other, is getting funding to do their work. While it would be nice if we could all have six-figure research grants, a lot of work can still get done using funds from outside the big federal (e.g. NSERC) or provincial (e.g. FQRNT, OGS) funding agencies. From personal experience I’ve found that, with a bit of creative planning, even a few thousand dollars can go a long way. However, I’ve been discovering over the past few months that despite regular searches for funding sources even I was unaware of a number of grants, some of which, according to their managers, are being underutilised. As such, I thought it might be useful to put together a list of some of the funding sources that are available, and that people may not realise are out there. In some ways, this page is as much a reference for myself, and I will try to occasionally update it as new grants come up.

Note: this post is written from the perspective of a Canadian palaeontologist, and as such is intended to be a resource for both myself and my peers. That means that for non-Canadians or non-palaeontologists, they may not be eligible for many of these grants.

Dinosaur Research Institute (http://www.dinosaurresearch.com/)

The Dinosaur Research Institute (DRI) is an Alberta focused group, dedicated to promoting and supporting dinosaur research in western Canada. They have a variety of grants which can be applied for, ranging from student travel funding (primarily for travel to SVP) as well as fieldwork grants. Researchers applying to the DRI typically have to be doing work in Alberta, or have come from Alberta themselves, though they do appear to be loosening these rules somewhat.

Grant amounts: often $1000 to $4000

Deadlines: grants are typically reviewed once in spring and once in fall.

Jurassic Foundation (http://jurassicfoundation.org/)

The Jurassic Foundation supports scientific research on dinosaurs, and is international in scope. They typically try to fund researchers who are otherwise unable to find alternate funds, usually students.

Grant amounts: up to $3000

Deadlines: February 15th and September 15th

National Geographic Society (http://www.nationalgeographic.com/explorers/be-an-explorer/)

Several grants of various types and sizes are available, for researchers of all levels and nationalities.

Grant amounts: typically up to $20000, depending on grant

Deadlines: 10 months before field work begins

Society of Vertebrate Paleontology (http://vertpaleo.org/Awards.aspx)

Various awards for various levels of researchers (with a primary focus on students).

Grant amounts: depends on type, but often $500 to $2000

Deadlines: April, though changes from year to year

Royal Canadian Geographical Society (http://www.rcgs.org/programs/research_grants/)

The RCGS supports both student research and independent researchers, with a priority on projects that support their mandate “to make Canada better known to Canadians and to the world.”

Grant amounts: variable, from a few thousand for independent grants to $6000 for some of the student grants.

Deadlines: February 14th

Saskatchewan Heritage Foundation Archaeology and Palaeontology Research Grant Program (http://www.pcs.gov.sk.ca/shf-programs)

A relatively recent grant, available to researchers working in Saskatchewan. Note that they will only cover expenses incurred in the province, or for work on Saskatchewan specimens. Also, they ususally only give a grant for 50% of a project costs, so alternate funding (including in-kind support) is required.

Grant amounts: not stated, but program manager has told me they accept budgets of $10000 to $20000 (of which they will support 50%, or $5000 to $10000).

Deadlines: January 15th

George Frederic Matthew Research Grants in Geology (http://www.nbm-mnb.ca/index.php/collections-a-research-56/natural-sciences/grants)

A grant distributed through the New Brunswick Museum, for work that is done in New Brunswick. Can be a project on palaeontology, stratigraphy, paleoecology, mineralogy or petrology.

Grant amounts: $500 to $1000

Deadlines: December 31st

Nova Scotia Museum Research Grants Program (https://museum.novascotia.ca/grants)

Nova Scotia Museum gives out grants for research projects that “improve Nova Scotians’ understanding of heritage or offer a different interpretation of our province’s cultural history.” The funded project must be based out of Nova Scotia.

Grant amounts: up to $4000 (h/t to Kirstin Brink)

Deadlines: February 26th

Explorers Club Grants (https://explorers.org/expeditions/funding/expedition_grants)

From what I have seen, a difficult to obtain grant, but may be worthwhile for some. They provide both student and postdoctoral/early career scientist awards.

Grant amounts: $500 to $5000

Deadlines: October 19th

Association of Canadian Universities for Northern Studies (http://acuns.ca/en/awards/overview/)

ACUNS gives grants for northern fieldwork; you can see a map on their site that will show you if your site is “northern” or not. As their focus is northern studies, your project would be competing against things like polar bear and sea ice studies, which could be some stiff competition.

Grant amounts: $1000 to $50000

Deadlines: January 29th

Northern Scientific Training Program (https://nstp-pfsn.fluidreview.com/)

Provides funding through universities for research in northern regions. You need to be a registered graduate student at a participating university. Each university has its own application process (or at least, did as of 2013).

Grant amounts: $1000 to $5000

Deadlines: December 1st (or earlier, depending on institution)

AINA Grant-in-Aid (http://arctic.ucalgary.ca/aina-grant-aid)

Another Arctic focused grant, the Arctic Institute of North America Grant-in-Aid is intended for young researchers (typically students) to help offset costs associated with Arctic fieldwork.

Grant amounts: $1000

Deadlines: February 1st

Palaeontological Association Research Grants (http://www.palass.org/awards-grants/grants/research-grants)

The PalAss gives out grants for research that supports their mandate, and generally to those already with a PhD in hand. Also, they prefer projects to be a single research project, or help with the initial start-up of a project that may later be funded by another funding body. Also, you must be a PalAss member.

Grant amounts: up to £10,000

Deadlines: March 1st

Alberta Museums Association (http://www.museums.ab.ca/what-we-do/grants.aspx)

I received a grant from the AMA to travel to a conference and present my research, which fulfilled their requirements that I “undertake professional and personal learning opportunities to increase the overall body of knowledge of the Alberta museum community.” You need to be an AMA member to apply.

Grant amounts: up to $2500

Deadlines: was January 31st, but check website for updates.

Yukon Historic Resources Fund (http://www.tc.gov.yk.ca/yhrf.html)

Provide research funding for projects based in the Yukon, however will only cover 50% of budget, so matching funds must be found.

Grant amounts: up to $10000 (50% of a $20000 budget)

Deadlines: October 1st

Nunavut Archaeology and Palaeontology Research Support (http://www.cley.gov.nu.ca/pdf/2015-11-16-CH%20Grants%20and%20Contributions%20-%20November%2012%202015%20FINAL-revised.pdf)

Provide research funding for student projects based in Nunavut. Details in the form are scarce, so be sure to contact the program administrator.

Grant amounts: up to $5000

Deadlines: Not listed

Paleontological Society Arthur James Boucot Research Grants (http://paleosoc.org/grants-and-awards/paleontological-society-arthur-james-boucot-research-grants/)

Funding for early-career scientists (though others may be considered) for projects focused on morphology, taxonomy, and biostratigraphy. Must be a PalSoc member, and be affiliated with a professional institution.

Grant amounts: typically up to $5000

Deadlines: February 1st

M.A. Fritz Travel Grants (https://www.rom.on.ca/sites/default/files/imce/fritztavelgrantannouncement2015.doc_1.pdf)

Intended for graduate students, the fund helps to cover the cost of travelling to the ROM to study their palaeontology collections.

Grant amounts: typically up to $750

Deadlines: March 16th

The Lewis and Clark Fund for Exploration and Field Research (https://amphilsoc.org/grants/lewisandclark)

For US PhD students, or PhD students wanting to do fieldwork in the US.

Grant amounts: up to $5000

Deadlines: February 1st

Redpath Museum Awards (https://www.mcgill.ca/redpath/teaching/redpath-museum-awards)

Not for most people, but if you’re a McGilligan…

Grant amounts: $500 to $5000

Deadlines: January 31st

New paper out in Journal of Anatomy

This past month, I was part of a group of people who published a paper looking at how diapsids (that is, lizards, snakes, crocodiles, dinosaurs, birds, etc) change – or don’t change – the number of teeth they have as they grow up and age. We used a dataset of American alligators (Alligator mississippiensis), salt water crocodiles (Crocodylus porosus), and komodo dragons (Varanus komodoensis) that documented their jaw lengths and how many teeth each jaw had in it. Overall, we found that in all of these species they had the same number of teeth as babies that they did when they were adults. For some of them, such as the American Alligator, this was despite a huge change in body size; the smallest alligator skull was 3.5 cm long, while the biggest was almost 70 cm long.

From a palaeontological point of view, these sorts of results help us understand the type and form of variation we might expect in the fossil record. One character that is often used in palaeontology to differentiate between two species is the number of teeth each of them might have. However, there has been some debate as to how reliable this characteristic might be. Our research suggests that using the number of teeth to split apart, or in the case of babies and adults, group together two different specimens is a not a bad idea. Still though, the story is far from done, as some of the additional information that we gleaned after accumulating  a large body of literature on other animals showed that the relationship is not totally cut and dried. For example, smaller species of lizards do appear to increase the number of teeth they have during their lifetime, while there is some limited evidence in a couple of large-bodied theropods that they might decrease their tooth count as they grow. In the end though, having a question that is partially answered, but gives you a lot more work to do is a generally a good thing in science. Go collect more specimens, more data, and do it all again.

Brown, C.M., C.S. VanBuren, D.W. Larson, K.S. Brink, N.E. Campione, M.J. Vavrek, and D.C. Evans. 2015. Tooth counts through growth in diapsid reptiles: Implications for interpreting individual and size-related variation in the fossil record. Journal of Anatomy(Advanced early online publication).

Where am I? Or, adding a counter to a running R process

A quick post in response to a question that came up on Facebook via Liz Freedman and Nic Campione: how do you add a counter/ticker to a running process in R? This is something that can be really helpful if you’re still in the process of trying to debug some code, as a process that involves thousands of iterations may be either stuck and broken, or it could be just taking its sweet time to finish, and without any output during the iterations, you can’t know which it’s doing. So, in one line, here’s a simple way of adding a counter to a for loop (although while and other style of loops follow the same logic):

for (i in 1:1000) {
  if (i%%100==0) print(paste("This is iteration number ", i))
  #all your complex code can go down here, whatever it is
}

In this case, I just added a rule that printed the iteration number every 100 loops (the code can be run directly in a terminal if you want to see what I mean). The two percent signs right beside each other are the modulo operation, so that when the remainder of the iteration is zero (that is, every 100 loops), it prints out a message. The number can be changed easily so that it is every 1000 instead of 100, and you can also use different rules, but I find that this is a relatively quick and easy way to add a counter.

As for making the whole process run faster, using something like the foreach package (and associated packages like doMC or doParallel) can significantly speed things up if you have a multicore processor on your computer.

My new home in Grande Prairie

museum94-992

The new museum, when it’s done.

At the beginning of this month I started my new job in Grande Prairie with the Philip J. Currie Dinosaur Museum near Grande Prairie, Alberta. Although northern Alberta doesn’t have the same sort of recognition that southern Alberta does when it comes to dinosaurs, this museum is looking to change that (and I’m going to do everything I can to make sure that happens). Getting hired on at the museum will let me continue to do the work I’ve started in northern and western Alberta (and other northern places, too), and set me up even closer to my field sites. Despite the whirlwind first couple of weeks, I’ve already been able to spend time out in the field, looking for new sites that might yield something interesting.

stomped_024

The museum right now, which now has concrete poured and is not just literally a hole in the ground.

For the most part though, the next year will be a lot of work making sure that when this museum opens that we have a great story inside. This means a lot of reading and a lot of research, making sure that all of the details of the exhibits are accurate and up to date. What many people don’t realise is just how active the science of  palaeontology really is, with new papers being published on a daily basis. Even just within dinosaur palaeontology, there is a new species published about every 2 weeks, and even in the last year, there have been 5 species named just from Alberta, which is already one of the best studied areas in the world.

I’m really looking forward to working with the great team we have, and I can’t wait to take my two kids on a tour once it’s done.

Of data repositories and unforeseen circumstances

I was recently doing some research into the reproductive habits of crocodylians, looking for some possible information that might also apply to dinosaurs. While doing this, I was referred to a paper written by the the crocodile expert John Thorbjarnarson (who I will admit, I hadn’t actually heard of before), who tabulated reproductive data such as numbers of eggs, body mass, etc., on all of the living species of crocodylians. “Great”, I thought to myself, this is exactly the kind of data I as looking for. I started looking through the paper in a bit more detail, and saw that although he had already gathered all of the data that I was looking for, he had only published summaries of that data. No problem, I was thinking, the paper says to just contact the author for the original dataset. A little searching later turned up something a little more depressing than an email address: his obituary. He had tragically and unexpectedly died of malaria in 2010. 

This brings me to the point of this post, about data archiving. John likely couldn’t have placed the data he collected in a long term, accessible archive like Dryad or Morphobank (and the many others that serve similar purposes) because the paper was published in 1996. However, the excuses I sometimes hear still that “the data is in the paper” and “if people want it, they can just ask me” don’t really apply in 2013. Of course, this is somewhat of a unique situation, but how many other scientists have been struck down by unforeseen circumstances? How many hours of work in compiling this data set (and many others) have been lost, even if it was something more mundane like a computer crash? The point is, you never know what the future may hold, but you can make sure that your scientific legacy persists well beyond yourself. You never know how far down the line (17 years in this case) someone might be looking to carry on your work.

TNT and Ubuntu

TNT (or ‘Tree analysis using New Technology’) is a relatively fast parsimony-based phylogenetics program. However, to be quite frank, it is also totally confusing. It took me some time, but I have put together a script that does pretty much everything I want it to do now, so I can just reuse the script every time I need to do something. I’m posting it here, in the hopes that other people will not have to spend so long figuring this all out. Just note though, the actual commands are in this type of font.Of course, everything that follows is what I’ve figured out through reading papers and trawling the internet, so suggestions are appreciated.

First things first, make sure your data is in the correct format. Theoretically, TNT can handle .nex files, but then again, my old car could theoretically do 220 km/h because the speedometer went that high. Your best bet is to just take your .nex file and reformat it to .tnt format, which pretty much involves deleting everything except the actual matrix, and then editing the first few lines. The first line should read ‘xread’, with the next line containing the number of characters, a space, and the number of taxa. (You can add a line between those for a comment, just be sure to put the comment in quotes)

For example, a simple data set might look like this:


xread
‘sample phylogeny’
5 3
taxonA 00011
taxonB 01111
taxonC 11111
;

While TNT is not the most user-friendly program, using scripts can help a lot, as you often will run the same set of analyses on different data sets. For my purposes, most of the time I want to run a basic tree search to find all of the most parsimonious trees, find a consensus tree from that (if necessary), map the characters, get bootstrap values and finally find the Bremer supports. At the bottom of the page I’ve posted my default TNT script that I use. Note that it does include comments (lines with a # in front) that will need to be deleted for the script to run properly. Also, replace ‘samplephylo’ with whatever you’ve named your .tnt file. Finally, when you’ve done all that, you need to move both the script and the .tnt file into the folder that contains all the files for the TNT program (on mine, the folder is called ‘tnt64-no-tax-limit’).

Finally, once you’ve done all that, you can run TNT (usually by navigating in a terminal to that same ‘tnt64-no-tax-limit’ using the change directory command [i.e. cd]), and then running TNT by typing something like ‘sudo ./tnt’. Note that TNT typically doesn’t run properly unless you run it as root/administrator (same applies to Mac OS X, except you’d run it as ‘sudo ./tnt.command’).

Often, TNT will throw error messages for no apparent reason. A few things to make sure of is that all the file names are letters or numbers only (no punctuation, including periods or underscores, and no spaces), that both the command script and .tnt file are in the same folder as the TNT program and that the program is being run as root/administrator. Hopefully by putting this up here, more people will be able to finally figure out how to use TNT.


#take everything after here and put it in a file in the tnt folder
#delete all the lines that start with the # sign
#replace the ‘samplephylo’ with the name of your file. I recommend converting
#your matrix to .tnt format, which is pretty simple
#check out the example.tnt file in the tnt folder to see how it’s done
#the most imprtant part is the first few lines,
#but be sure to convert any polymorphisms to [] brackets
#load the data file
procedure samplephylo.tnt;
#write all the output to this file
log samplephylo.out;
#do a basic run – finds a bunch of parsimonious trees quickly
mult ;
#this should find all the MPRs
bbreak=tbr;
#find the consensus tree
nelsen * ;
#map the synapomorphies on the tree
apo [ ;
#export the MPRs and the consensus tree to a file
export samplephylo.tre;
#do a bootstrap analysis – might need to up the runs
resample ;
#the stuff below does a Bremer analysis
#it’s a bit convoluted, but is the only way to get
#TNT to do a Bremer, because TNT isn’t really meant to
#do a Bremer analysis
hold 1000; sub 1 ; bbreak=tbr;
hold 2000; sub 2 ; bbreak=tbr;
hold 3000; sub 3 ; bbreak=tbr;
hold 4000; sub 4 ; bbreak=tbr;
hold 5000; sub 5 ; bbreak=tbr;
hold 6000; sub 6 ; bbreak=tbr;
hold 7000; sub 7 ; bbreak=tbr;
hold 8000; sub 8 ; bbreak=tbr;
#calculate the Bremer support from the suboptimal trees
bsupport ;
#quit the program – you can always do this manually
quit

MrBayes and Ubuntu

A quick tutorial on how to install MrBayes on an Ubuntu system.

Step 1. Open Software Centre

Step 2. Search for ‘mrbayes’ and hit enter

Step 3. Click ‘Install’

Or, alternatively, open a terminal and type ‘sudo apt-get install mrbayes’. And to run MrBayes, open up a terminal and type ‘mb’. That’s it. I just spent 15 minutes downloading and compiling the software from source, when it was already done for me. Oh well.