Skip to content

6. R analyses

Fursham Hamid edited this page Aug 25, 2023 · 2 revisions

Differential expression analyses using DESeq2

Dimensional reduction

PCA

UMAP

t-SNE

Clustering

Heirarchical clustering

K-means clustering

Correlation analyses

Statistical tests

Data visualisation using ggplot2

library(ggplot2)
data("mtcars")

The most basic syntax to create a ggplot object consists of the following:

  1. Data
  2. Aesthetic
  3. Geometry
mtcars %>% 
    ggplot(aes(x=cyl, y = mpg)) +
    geom_point()

Data Wrangling with tidyverse

The Tidyverse is a collection of R packages designed to make data manipulation more user-friendly. Some of these R packages are dplyr, ggplot2, tidyr, etc.

All of these packages will be available to use once you load the library. This can be done as follows:

## Loading the library
library(tidyverse) 

To make R code more human-readable, the Tidyverse tools use the pipe %>% to allow the output of a previous command to be used as input to another command. In the example below, we create a vector of numbers and then we pipe it to the function mean(). This pipe operator can be used for all sorts of functions as we will see later.

Numbers <- c(5,10,15,20,25)

Numbers %>%
  mean()

When it comes to manipulating data dplyr has many useful functions.

The codeblock below describes a list of the most used by the lab:

## You have a data frame with information about cars. As columns, you have information about price, year, model, gears, and mpg. Each row is the information for different types of cars. 

## Extracting columns from a data frame
data <- mtcars %>%   # piping data
        select(price,year)  # selecting only the columns price and year

## Removing a column from a data frame
data <- mtcars %>%   # piping data
        select(-c(price))  # removing the column price from data frame






Common lab SOPs:

Bioinformatics-related:

Image analyses-related:

Programming-related:

Clone this wiki locally