Load the example dataset (example2.tsv) using read_tsv.

library(tidyverse)
results <- read_tsv('example2.tsv',
                    col_types = cols(Chr = 'c', Strand = 'c'))

Filtering and Selecting

  1. Use filter to find out how many genes have an adjusted p-value less than 0.05.
filter(results, adjp < 0.05) %>%
  nrow()
  1. Find out which gene has the smallest p-value by sorting the data using arrange.
arrange(results, adjp) %>%
  select(., GeneID, Name, adjp) %>%
  head(1)
  1. Make a new column in the data that is -log10 of the adjusted p-value column. You can use the log10() function to calculate this.
results <- mutate(results, 
       log10p = -log10(adjp))

select(results, GeneID, Name, adjp, log10p) %>% 
  arrange(adjp) %>% 
  head(5)
  1. Make a new data.frame that contains the GeneID, Name and all the normalised count columns.
normalised_counts <- 
  select(results, GeneID, Name, contains('normalised_count'))
  1. Make the new data.frame data tidy using pivot_longer.
normalised_counts_long <- 
  pivot_longer(normalised_counts, c(-GeneID, -Name),
                names_to = 'sample', values_to = 'normalised count')

Plotting

  1. Using the iris dataset make a plot of Petal.Width (y) against Sepal.Width (x).
ggplot(data = iris) + 
  geom_point(aes(x = Sepal.Width, y = Petal.Width))

  1. Now colour the points by Petal.Length and use the viridis colour scale using scale_colour_viridis_c.
ggplot(data = iris, aes(x = Sepal.Width, y = Petal.Width)) + 
  geom_point(aes(colour = Petal.Length)) +
  scale_colour_viridis_c()

  1. Change the colouring to Species, choose a hollow shape (one of 21-25) and pick 3 colours to use with scale_fill_manual.
ggplot(data = iris, aes(x = Sepal.Width, y = Petal.Width)) + 
  geom_point(aes(fill = Species), shape = 22, size = 3) +
  scale_fill_manual(values = c('firebrick2', 'steelblue3', 'orange'))