-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathassignment_1.qmd
More file actions
155 lines (99 loc) · 6.48 KB
/
assignment_1.qmd
File metadata and controls
155 lines (99 loc) · 6.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
---
title: "Assignment #1"
format: html
---
## Assignment 1
You only need to write lines of code for each question. When answering questions that ask you to identify or interpret something, the length of your response doesn’t matter. For example, if the answer is just ‘yes,’ ‘no,’ or a number, you can just give that answer without adding anything else.
We will go through comparable code and concepts in the live learning session. If you run into trouble, start by using the help help() function in R, to get information about the datasets and function in question. The internet is also a great resource when coding (though note that no outside searches are required by the assignment!). If you do incorporate code from the internet, please cite the source within your code (providing a URL is sufficient).
Please bring questions that you cannot work out on your own to office hours, work periods or share with your peers on Slack. We will work with you through the issue.
You will need to install PLINK and run the analyses. Please follow the OS-specific setup guide in [`SETUP.md`](../../SETUP.md). PLINK is a free, open-source whole genome association analysis toolset, designed to perform a range of basic, large-scale analyses in a computationally efficient manner.
#### Question 1: Data inspection
Before fitting any models, it is essential to understand the data. Use R or bash code to answer the following questions about the `gwa.qc.A1.fam`, `gwa.qc.A1.bim`, and `gwa.qc.A1.bed` files, available at the following Google Drive link: <https://drive.google.com/drive/folders/11meVqGCY5yAyI1fh-fAlMEXQt0VmRGuz?usp=drive_link>. Please download all three files from this link and place them in `02_activities/data/`.
(i) Read the .fam file. How many samples does the dataset contain?
```
# Your answer here...
```
(ii) What is the 'variable type' of the response variable (i.e.Continuous or binary)?
```
# Your answer here...
```
(iii) Read the .bim file. How many SNPs does the dataset contain?
```
# Your answer here...
```
#### Question 2: Allele Frequency Estimation
(i) Load the genotype matrix for SNPs rs1861, rs3813199, rs3128342, and rs11804831 using additive coding. What are the allele frequencies (AFs) for these four SNPs?
```
# Your code here...
```
(ii) What are the minor allele frequencies (MAFs) for these four SNPs?
```
# Your code here...
```
#### Question 3: Hardy–Weinberg Equilibrium (HWE) Test
(i) Conduct the Hardy–Weinberg Equilibrium (HWE) test for all SNPs in the .bim file. Then, load the file containing the HWE p-value results and display the first few rows of the resulting data frame.
```
# Your code here...
```
(ii) What are the HWE p-values for SNPs rs1861, rs3813199, rs3128342, and rs11804831?
```
# Your code here...
```
#### Question 4: Genetic Association Test
(i) Conduct a linear regression to test the association between SNP rs1861 and the phenotype. What is the p-value?
```
# Your code here...
```
(ii) How would you interpret the beta coefficient from this regression?
```
# Your answer here...
```
(iii) Plot the scatterplot of phenotype versus the genotype of SNP rs1861. Add the regression line to the plot.
```
# Your code here...
```
(iv) Convert the genotype coding for rs1861 to recessive coding.
```
# Your code here...
```
(v) Conduct a linear regression to test the association between the recessive-coded rs1861 and the phenotype. What is the p-value?
```
# Your code here...
```
(vi) Plot the scatterplot of phenotype versus the recessive-coded genotype of rs1861. Add the regression line to the plot.
```
# Your code here...
```
(vii) Which model fits better? Justify your answer.
```
# Your answer here...
```
### Criteria
| Criteria | Complete | Incomplete |
|------------------------|------------------------|------------------------|
| **Data Inspection** | Correct sample/SNP counts and variable type identified. | Missing or incorrect counts or variable type. |
| **Allele Frequency Estimation** | Correct allele and minor allele frequencies computed. | Frequencies missing or wrong. |
| **Hardy–Weinberg Equilibrium Test** | Correct PLINK command and p-value extraction in R. | PLINK command or extraction incorrect/missing. |
| **Genetic Association Test** | Correct regressions, plots, coding, and interpretation. | Regression, plots, or interpretation missing/incomplete. |
### Submission Information
📌 Please review our [Assignment Submission Guide](https://github.com/UofT-DSI/onboarding/blob/main/onboarding_documents/submissions.md) for detailed instructions on how to format, branch, and submit your work. Following these guidelines is crucial for your submissions to be evaluated correctly.
#### Note:
If you like, you may collaborate with others in the cohort. If you choose to do so, please indicate with whom you have worked with in your pull request by tagging their GitHub username. Separate submissions are required.
------------------------------------------------------------------------
#### Submission Parameters
- Submission Due Date: `11:59 PM – 16/03/2026`
- Branch name for your repo should be: `assignment-1`
- What to submit for this assignment:
- Populate this Quarto document (`assignment_1.qmd`).
- Render the document with Quarto: `quarto render assignment_1.qmd`.
- Submit both `assignment_1.qmd` and the rendered HTML file `assignment_1.html` in your pull request.
- What the pull request link should look like for this assignment: `https://github.com/<your_github_username>/gen_data/pull/<pr_id>`
- Open a private window in your browser. Copy and paste the link to your pull request into the address bar. Make sure you can see your pull request properly. This helps the technical facilitator and learning support team review your submission easily.
------------------------------------------------------------------------
Checklist:
- Created a branch with the correct naming convention.
- Ensured that the repository is public.
- Reviewed the PR description guidelines and adhered to them.
- Verified that the link is accessible in a private browser window.
- Confirmed that both `assignment_1.qmd` and `assignment_1.html` are included in the pull request.
If you encounter any difficulties or have questions, please don't hesitate to reach out to our team via our Slack help channel. Our technical facilitators and learning support team are here to help you navigate any challenges.