BINF_tut


Project maintained by sarbal Hosted on GitHub Pages — Theme by mattgraham

Week 1: Intro and setting up

Hi! Welcome to the BINF2010 tutorial stream.

Overall tutoRial aims

CouRse outline

  1. Week 1: Installing all the things!
  2. Week 2: Introduction to Python
  3. Week 3: Data Viz in Python
  4. Week 4: Snakes on a plane
  5. Week 5: Biopython basics
  6. Week 6: BReak!
  7. Week 7: Biopython extra
  8. Week 8: Introduction to R
  9. Week 9: More R
  10. Week 10: Recap

What is Python?

What isssssssss it good for?

Modules

Install Python

Start off by downloading VSCode and then Python.

Install modules

These commands go in the terminal (your VSCode terminal, or another terminal on your computer as long as python3 works). This will NOT work in the python interactive console, nor should you type this into a .py file.

Note: sometimes python or pip will not be recognised; try pip3 or python3 instead.

pip install matplotlib
pip install biopython

Import modules

Now that the packages have been installed to your computer with pip, the way we include the code from those packages into any given instance of python is with import. The following line should be added to a .py file and then run (or, on the command line using python -c "import matplotlib").

import matplotlib

Install Jupyter notebooks

Again., these commands go in the terminal (your VSCode terminal, or another terminal on your computer as long as pip works). https://pypi.org/project/jupyter/

pip install jupyter

Select kernel

https://code.visualstudio.com/docs/datascience/jupyter-kernel-management

Testing your installation - Python

Make sure you have installed VSCode and Python correctly.

Open up VSCode rstudio console

If an Untitled-1 file appears, click on Select a Language at the top of the new file and search for Python. rstudio console

Otherwise, click on “File -> New Text File”, and that should open a new document. rstudio console

As a quick sanity check, see if you can execute this bit of code. Open a new file in VSCode.
vscode

Copy and paste (or type) this into your new file:

print("Hello, World!")

Save the file and name it “helloworld.py”. Note the “.py” extension. Click the triangle “play” button to run your code in the terminal. vscode

What is R?

What is it good foR?

Packages, Repositories, oh my!

Install R

Start off by downloading R and then RStudio.

Note: make sure you use the correct install specific to your computer’s hardware (e.g. M2 chip on newer macbooks will not work with the Intel CPU installation etc.)

Install packages

From CRAN:

install.packages("gplots")

From Bioconductor:

if (!require("BiocManager"))
    install.packages("BiocManager")
BiocManager::install("limma")

From github:

install.packages("devtools")
library(devtools)
devtools::install_github("karthik/wesanderson")

Load libraries

library(gplots)
library(limma)
library(wesanderson)

Testing your installation - R

Make sure you have installed Rstudio and R correctly.

Open up Rstudio. rstudio console

You should be able to see 4 different windows. We will be working within the “Source” and “Console” windows.

Start a new notebook file by selecting “File” -> “New File” -> “R Notebook” rstudio console

This should open up a file in the source window. Change the title to “Week 1”, and include your name as the author by including this line underneath the title: rstudio console

title: "Week 1" 
author: "Sara"

Save the file as “yourname_week1.Rmd”. Delete the instructions starting from “This is an [R…”. Insert any notes or comments below in the notebook. Code can be saved as R chunks. An R chunk is code placed after a line that starts with ` {r} `and ends before a line with ` `.

In the console window below the source window, check your working directory by typing in:

getwd()

rstudio console

To set your working directory, where is your directory, and project is a directory for your tutorials:

setwd("C:/<home>/project")

Run the code from earlier to install/load libraries. Then, save this helper script in your working directory.

Then run this bit of code in your console. Note, it might take a little while, but hopefully it will run smoothly.

source("helper.R") 

WheRe to get help

OtheR useful ssssstuff

And that’s it for this week!

Back to the homepage