Week 4 - Homework
week04
homework
Write your code directly in a Quarto document.
To create a Quarto document: go to File -> New File -> Quarto Document, then click Create.
- Import the
read-counts.csv
file.
Quick reminder: this data file contains gene expression values of samples from four groups, sample names are prefixed by “WT.”, “SET1.”, “SET1.RRP6.” and “RRP6.”. Each group has 10 samples.
- Create a function to calculate the average gene expression across samples by selected group. Test your function on WT samples.
- Use function created in question 2 to calculate the average for all sample groups, store the results in a list. Show the first 5 average gene expression of SET1.RRP6 samples.
- Transform the list obtained in question 3 to a data frame using
as.data.frame()
. Show the head lines of your data frame.
Tip
A data frame can be considered as a list of equal-length vectors.
- What are the genes having an average greater than 10000 in WT and SET1 samples? Compare if there are genes in common using learned operator or the
intersect()
function.
- Create a function to check if the average expression of each sample group is normally distributed (
?shapiro.test()
) using significance level at 5%. IfTRUE
, draw directly a histogram (?hist()
) for the values. Otherwise, draw a histogram for the log-transformed values. And return the p-value of normality test at the end.
Test your function on average expression of RRP6 samples.
- Click “Render” to generate your Quarto report.
The homework correction is available here: link