Hi! Welcome to the BINF2010 tutorial stream.
pip
(package installer for Python).Start off by downloading VSCode and then Python.
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
orpip
will not be recognised; trypip3
orpython3
instead.pip install matplotlib pip install biopython
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
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
https://code.visualstudio.com/docs/datascience/jupyter-kernel-management
Make sure you have installed VSCode and Python correctly.
Open up VSCode
If an Untitled-1 file appears, click on Select a Language at the top of the new file and search for Python.
Otherwise, click on “File -> New Text File”, and that should open a new document.
As a quick sanity check, see if you can execute this bit of code.
Open a new file in 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.
library()
or require()
functions.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.)
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")
library(gplots)
library(limma)
library(wesanderson)
Make sure you have installed Rstudio and R correctly.
Open up Rstudio.
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”
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:
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()
To set your working directory, where
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")
And that’s it for this week!
Back to the homepage