Eric C. Anderson
1/21/2020
A quick what and why to the installations and configurations:
Although R is not generally revered as a hard core bioinformatic language/environment (but see https://www.bioconductor.org/, a set of R packages for HTS data that we won’t use too much in this course), it is in widespread use in ecology, and any chance to get more familiar with it is beneficial.
An integrated development environment (IDE) for writing R code (and much more). This is where we will spend most of our programming time in this course, because it:
The so-called “Bourne-again shell” for dealing with Unix and writing Unix scripts. Most of our hard-core bioinformatic analysis will take place on supercomputers, which all run Unix. However, it is really nice to have a Unix installation on your own laptop to experiment with. Mac’s are already Unix-based and come standard with bash, but Windows PCs are not. Git Bash provides an environmentthat emulates a Unix shell on Windows.
This is the underlying program that provides a “distributed version control” system. We will go into more details of its inner workings later in the week. You will use it extensively to store versions of your homework, etc., and by the end of the semester I hope that everyone is familiar enough with it to make use of it in their own research programs.
This is a website that lets you store copies of your work, research, code, etc. In my opinion, it is one of the most important developments for doing reproducible and collaborative research in the last decade. All the materials for this course are served up from GitHub. The course is also enrolled in GitHub Classroom. All homework assignments will be obtained and submitted through GitHub.
At the end, we’ll have everyone open a small RStudio project from GitHub to make sure everything is working.
These are pretty easy to install on either Windows or a Mac. The directions are largely the same for either system.
On Windows: You should also go back to the cran downloads page and download and install the Rtools35.exe. This will let you compile and build R packages on your computer.
Once this is done, open RStudio and immediately set some settings:
There are some packages that should be installed now. Enter the lines of code listed below (in the code blocks) into the R Console in RStudio.
bookdown: This package is what I used to create these course notes. Getting it automatically installs a lot of other packages that are useful for authoring reproducible research.
tinytex: If you don’t already have LaTeX installed, do the following so that you can be guided in maintaining a LaTeX distribution. Basically, with this package installed, if you try to create PDF output from an RMarkdown document, this package will detect that and give you a message about how to install a LaTeX system.
other R packages that we will want to have, namely, the package tidyverse, which installs a number of Hadley Wickham’s packages, and also a package called remotes that makes it easy to install packages from GitHub and other repositories..
Getting Bash on Windows is a little tougher than on a Mac. I recommend here that you get the Git Bash system, which gives you a serviceable Unix-like command line for Windows. And you get Bash in the process as well. Yay!
You can follow these steps:
C:\Program Files\Git\bin if it is not already there.If you successfully installed Git for Windows, then you have git. You just have to let RStudio where to find it.
C:/Program Files/Git/bin/git.exe. If it is empty, try adding that text.You might already have git. To find out do this:
If you are using a Mac with a reasonably new OS, you should be able to just open the Terminal application (/Applications/Utilities/Terminal) and type “git” at the command line. If you have git it will say something that starts like:
usage: git [--version] [--help] [-C <path>] [-c name=value]
[--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
<command> [<args>]
These are common Git commands used in various situations:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
etc. etc. etc.If you do not have git then it should pop up a little thing asking if you would like to install a reduced set of developer tools. You do. Click OK. NOTE Instead of a pop up it might say something like, “xcrun Error: invalid active developer path. etc. etc…”. In that case, you can install a fresh set of command line tools by typing this at the command line:
git or that you already have it.There a few configurations to do for git:
When you use git, it stamps the changes with your name and email. You need to let it know those things, if you haven’t already configured things. You need to do this on both a PC and a Mac.
Tools -> Terminal -> New Terminal. That will pop up a Unix shell in a new window in RStudio’s lower left pane.Type the following lines into that terminal window replacing John Doe and his email with your name and your email, hitting return after each.
On a Mac, there is one further step that will help you not have to re-type your password every time git communicates with GitHub. (On Windows, if you installed Git/Bash for Windows according to the directions given earlier, this type of feature should already be enabled.
If you don’t already have an account on GitHub, go to github.com and click the “sign up” link near upper right of the page. It is pretty self-explanatory. Go ahead and get a free account. There is nothing to pay for here!
If you are a graduate student and you do not feel comfortable posting your data on a public site like GitHub, then you should request some private repositories from GitHub. GitHub has a great deal for academic users like students: free private repositories. Please go to https://education.github.com/pack to sign up for your free student pack.
I’ve prepared a small RStudio project and I have put it onto GitHub. We can use this to make sure that most of the installations are working properly.
Steps to get it:
In the next dialog window copy and paste the following URL into the “Repository URL” text entry box:
And then, using the “Browse” button, select a destination on your local hard drive to save the resulting RStudio project. You should consider having a directory where all your work for the course will go.Click “Create Project”
If everything goes right (i.e., if git is successfully installed) this will create a new RStudio project and open up the associated project window for it.
Now, from the file browser (bottom left pane, typically) click on example.Rmd. When that is open, click the “Knit” button on the top of the upper left pane.
If all is right, this will bring up a new window some html output. It should look exactly like the file “expected-output.html” in the project. You can open that file by clicking on it in the RStudio file browser window and choosing “View in Web Browser.”
The last exercise was good for making sure that all the local installations were working. Now, we want to make sure that you can push things up to your own GitHub account.
To do that. You will all create a new repository with git version control on your laptop, then you will create a repository on GitHub and push your local repository up to it.
Once you have created that project, we will talk a little about how git works, and about RStudio’s interface to it.
a-first-projectAt this point you get two command lines under “…or push an existing repository from the command line”.
In your RStudio “a-first-project” project, choose Tools->Terminal->New Terminal, and paste those two command lines into there and hit return. That should push your project up to GitHub.
Make sure that password caching is working.