Chapter 1 Prerequisites

1.1 R

This achieve this pratical work, you will need R, Rstudio and Seurat. Run Rstudio within the Linux virtual machine and load Seurat. The full reference manual of Seurat is available here.

R is a language and a calculator. Rstudio is a graphical development environment built on top of R. Seurat is a R package designed to analyse single-cell RNA-seq experiment data.

library(Seurat) # Single-Cell RNA-seq analysis
library(dplyr) # data manipulation
help("Read10X")

No report is required to fulfil this course. Yet you can send code, figures, questions, and suggestions to JB Alberge.

1.2 Best practices

Here are some good practices to write R code. They will help you write clear and maintainable code.

  • Comment your code with # statements
a <- choose(5, 2) # computes binomial coefficients
  • Avoid obvious comments
x <- 2
y <- 1
# if x is greather than y, then print x
if (x>y) print(x)
  • Group your code by task
# assign values
x <- 2
y <- 1

# compute statements
if (x>y) print(x)
  • Use a consistent naming scheme
# good !
sum.two.elements <- function(x, y){
  return(x+y)
}
multiply.two.elements <- function(x, y){
  return(x*y)
}

# bad !
my.function.bis <- function(x, y){
  return(x+y)
}
test.function <- function(x, y){
  return(x*y)
}
  • DRY principle: Don’t Repeat Yourself. Automate repetitive tasks. The same piece of code should not be repeated, but reused.
  • Limit line length
  • Set your working directory where you store all the code and the results setwd(‘C:/Users/toto/tp-biogen/’)
  • Should you receive any error message from the R console, make sure you’ve read it and googled it carefully before asking for help.