Chapter 5 Computational skills

5.1 Basic navigation

  • We will begin our work using the command line or shell.
  • Click on the Terminal tab in your RStudio to access the command line interface, which we’ll be using for our genomic analyses.

If you don’t have access to the server AND you are on a PC download git-bash and open it.

To see the list of files on this computer in your “home” directory do the following:

ls

If you are on the server you should see your project folder listed. Alternatively, you may be in your project folder and you will see the script you were working with previously.

If you are on your personal computer you are likely in your home folder and you may see a number of files related to your personal computer.

Check which folder you are in using the following command.

pwd

If you are already in your project folder you may skip the next step. Otherwise you must move into that directory. To change directories you need two things - the command to change directory and the argument that specifies which directory to move into.

cd evolution_workshop

If you are working on your personal computer you may need to cd into your folder using a more complex path. For example my command (on a Mac) might look like cd ~/Desktop/URI/teaching/Andes_workshop/Andes_workshop_codebook - this tells the computer to go to my Andes_Workshop_codebook folder, which is in my Andes_workshop folder, which is in my teaching folder, which is in my URI folder, which is in my Desktop folder, which is in my home folder. Think of folders inside of drawers in a filing cabinet. You can have folders inside of folders to stay highly organized. If you are on a PC your file paths will look similar but often start with C:/ and use / instead of \. Once you are in your project folder everything will be simpler so long as all your files are in there.

Make a directory to put your scripts in inside your workshop folder. We’ll write these scripts in a little while, but basically a script is a list of commands that you will give the computer to do all the steps to analyze your data.

To make a directory you again need a command (make directory) and an argument (the name).

mkdir scripts 

Now we can move into that folder. cd means change directory so we’ll use that a lot to open different folders. This command also has an argument.

cd scripts 

Now to get back to your home folder you can’t cd and give it a folder name because the computer will look in your current folder (scripts) for another folder. Instead you need to tell the computer to “move one level up”, going outside the current folder to the one containing it.

cd ..

To practice, repeat this process but make a directory called results. Now list the files in your current home directory again. Do you see the two folders you just made?

If you want to check out what is in these folders (they are currently empty but we will add to them later) you have two options. First, you can change directory with the cd command and list the contents of the folder with ls. Think about these folder just like a filing cabinet. You started off in your home folder and now you are opening the results folder.

Alternatively, list the contents of a folder by given ls the folder name as an argument (e.g. ls scripts).

We will learn lots more commands as we work through our data.

Adapted from http://swcarpentry.github.io/shell-novice/