Week 2 - Homework

week02
homework

Write your code directly in a Quarto document.

To create a Quarto document: go to File -> New File -> Quarto Document, then click Create.

Use the following code to import the file “read-counts.csv” (you have already downloaded it for the hand-on examples of week01). Name the imported data expr_data.

expr_data <- read.table(
  file = "../exos_data/read-counts.csv",  # replace the path with your own
  header = TRUE, sep = ",", row.names = 1
)
  1. Is the imported data a matrix?
  1. Transform it to a matrix using as.matrix().
  1. What are the dimensions of the matrix?
  1. What are the column names and row names?
  1. Extract all genes’ expression for the 10 WT samples (WT.1, WT.2, …, WT.10), and store it in a variable called expr_wt. Show the first few rows using head() function.
  1. What is the average expression level across all WT samples for each gene? Store the results in a variable called avg_wt.
  1. Draw a histogram to check the distribution of the average gene expression level for WT samples.
  1. Repeat questions 5 to 7 for the SET1 samples (SET1.1, SET1.2, …, SET1.10).
  1. What is the absolute difference between the average expression of WT and SET1 samples for each gene? Which gene shows the biggest difference?

Hints:

  1. Compare the following matrix to the one we created during the course’ exercise (the matrix named expression_levels). What is the key difference in how the matrix is constructed? Provide a brief explanation.
matrix(
  c(10, 12, 15, 20, 18, 22, 14, 16, 19, 8, 9, 7, 25, 30, 28),
  ncol = 3
)
     [,1] [,2] [,3]
[1,]   10   22    9
[2,]   12   14    7
[3,]   15   16   25
[4,]   20   19   30
[5,]   18    8   28
  1. Click “Render” to generate your Quarto report.

The homework correction is available here: link