-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
161 lines (102 loc) · 8.89 KB
/
README.Rmd
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
156
157
158
159
160
161
---
title: "About the Project"
output:
github_document:
html_preview: false
toc: true
toc_depth: 2
html_document:
toc: false
css: Templates/my-CSS-theme.css
df_print: paged
keep_md: true
---
```{r cover-image, fig.align = 'center', fig.alt = "Cover image displaying the text 'Insulin in the Brain' with background graphics of a rat, a neuron and a cartoon representation of insulin", echo=F}
knitr::include_graphics(here::here("Figures/Presentation-Images/Cover-Image.png"))
```
## Background
Insulin is a hormone associated with processes like blood glucose regulation, and it also acts in the brain. For my honours project, I explored the effect of insulin on neurons in a brain region called the dorsomedial hypothalamus (DMH). DMH neurons stimulate appetite and they also have insulin receptors, but almost nothing is known about the effect of insulin on neuronal activity in the DMH.
I used whole-cell patch clamp electrophysiology to record from the living DMH neurons of young, male and female Sprague-Dawley rats. I recorded excitatory evoked currents (a measure of synaptic transmission) and action potentials (a measure of excitability) before and after exposing neurons to 500 nM of insulin.
```{r methods-summary, fig.align = 'center', fig.alt = "A visual summary of the experiment. I removed rat brains, stimulated DMH neurons, and recorded the resulting currents. This allowed me to compare currents before and after exposing the neurons to insulin. I also compared action potentials before and after adding insulin.", echo=F}
knitr::include_graphics(here::here("Figures/Methods-Schematic-with-APs.png"))
```
## What do you want to do?
### I want to read the thesis!
Here is a link to the [Thesis.pdf](Thesis/Thesis.pdf) file. You may find it easier to download and read the PDF outside of GitHub. The download button is on the top right of the screen.
<div align="center">
<img src="Figures/Download-button-github.png" width=50% height=50%>
</div>
### I want to explore the code!
Scroll further to find instructions, metadata, and additional information.
## Goals
I developed this code to achieve the following goals:
- Analyze changes in current amplitudes (evoked excitatory post-synaptic currents; eEPSCs) over time
- Analyze changes in action potential parameters before and after insulin exposure
- Group and summarize the raw data into publication-ready plots
- Perform appropriate statistical tests on the raw data
- Compile my thesis in a print-ready format with embedded code and figures
## Instructions
You could clone the repository using git clone:
```
git clone https://github.com/christelinda-laureijs/honours-thesis.git
```
Or, if you don't have GitHub set up, you could also download the repository as a zip file.
Either way, be sure to click on the `honours-thesis.Rproj` file. This will open RStudio and set the working directory to the project folder on your computer.
> IMPORTANT: If you don’t open RStudio through the .Rproj file, R will not know where to find any of the scripts, and you will see error messages about missing files.
Read through the comments in the file (`Thesis.Rmd` or `Scripts-from-Thesis-Rmd.R`) and run each section in groups (press Ctrl+Enter to run chunks at a time). To minimize error messages, go from the top to the bottom and don’t skip lines.
The file `Scripts/Scripts-from-Thesis-Rmd.R` contains just the R code contained within the `Thesis/Thesis.Rmd` file. This is useful if you want to quickly run the same script without needing to scroll past the thesis text. It is also useful for debugging; just make sure that you make changes within the main `Thesis.Rmd`file, not the script.
When adding new recordings, use the `P1-Analysis-Script.Rmd` in the `Scripts` folder. Be sure to read the instructions contained within the comments there.
If you just want to quickly view the plots, make sure that you have run the `Thesis.Rmd` file at least up to the "Begin statistical analysis" code. This will ensure that the data are processed and ready for plotting. Then, you can open and run the `Figures/Quick-Plot-Viewer.Rmd` file.
## Important variables
There are two variables near the top of the scripts that you may want to change.
`save_choice`: Change this to "no" if you do not want to save the plots each time the file is run. This is useful for debugging or when repeatedly running the script, since it will significantly reduce the run time.
`my_colours`: Use these to define the colours globally. The main project palette is:
```{r fig.align = 'center', fig.alt = "Cover image displaying the text 'Insulin in the Brain' with background graphics of a rat, a neuron and a cartoon representation of insulin", echo=F}
knitr::include_graphics(here::here("Figures/Colour-Palette.png"))
```
To generate the thesis as a PDF file, go to the **Thesis/** folder, open the `Thesis.Rmd` file and click the `Knit` button. If you just want to run the script and get statistical output and plots, you could click on the `Run` button.
> Note: The thesis is best viewed as a PDF. LaTeX features (like figure cross-referencing) will not work in the other outputs and you will receive an error message.
## Where to find things
**Data/** - Contains raw data including metadata (`eEPSC-metadata.csv`), which can also be found below in the [metadata table](#metadata).
- `Output-Data-from-R` contains the processed and cleaned data as R object files (`.RDS`). These are required to run the plots document. These are generated using the scripts within `Thesis.Rmd`.
- `Raw-CSVs` contains the CSV files from copying and pasting from Clampfit on the lab computer. This will mainly contain action potential parameters such as threshold and half-width.
**Figures/** - Folder containing all figures. Figures generated from the `Thesis.Rmd` document will automatically go into folders with names starting with **Output-**. Also contains the folders **Gap-Free-Plots/**, **Pruned Summary Plots/**, and **Representative-Traces/**.
**Scripts/** - Folder containing R scripts.
- *Functions.r* contains custom functions that I wrote to create the summary plots. I put this as an external .R file instead of keeping it within `Thesis.Rmd` so that I could use it elsewhere.
- *Scripts-from-Thesis-Rmd.R* contains just the R code contained within code chunks of the `Thesis.Rmd` file. This is useful if you want to quickly run the same script without needing to scroll past the thesis text. It is also useful for debugging; just make sure that you make changes within the main `Thesis.Rmd`file, not the script.
Use the following code to extract just the scripts from the thesis:
```{r eval=F, message=F, warning=F}
knitr::purl(
input = here::here("Thesis/Thesis.Rmd"),
output = here::here("Scripts/Scripts-from-Thesis-Rmd.R"),
documentation = 0
)
```
**Templates/** - Contains my custom style templates:
- *MtA-Thesis-Preamble.tex* for PDF
- *my-CSS-theme.css* for HTML
- *thesis-citations.bib* for all in-text citations.
- *packages.bib* for all R packages used in my scripts
> The MtA-Thesis-Preamble.tex requires additional LaTeX packages, and it may take some time to run the first time as it installs them. This also requires the font EB Garamond, which is a sub-folder in **Templates/**.
**Thesis/** - Contains the `Thesis.Rmd` file used to generate my thesis, as well as its PDF output.
**R-Work.Rproj -** The project file, which sets the working directory for scripts and ensures that the relative paths work properly. Please click on this to open up R, otherwise the file paths will not work.
## Metadata {#metadata}
These are all variables included the [Raw-eEPSC-Data.csv file](Data/Raw-eEPSC-Data.csv). Values marked with a \* will be automatically generated during the R script.
```{r import-variable-explanations, echo=FALSE, warning=FALSE, message=FALSE}
variable_explanations <- read.csv("Data/Variable-Explanations.csv", header = T)
knitr::kable(variable_explanations)
```
Additional notes about some variables:
**Category**: I assigned each experiment type with its own number ID and used this convention for all scripts.
1. HFS in control conditions
2. Adding insulin in control conditions
3. HFS in the presence of insulin
**HFS**: High frequency stimulation was 100 Hz applied for 4 seconds, which was repeated again after a 20-second interval.
**Treatment**:
- *None* indicates no additional drugs or modifications.
- *HNMPA* is a tyrosine kinase inhibitor that blocks insulin receptors.
- *PPP* is an insulin-like growth factor 1 receptor blocker.
- *AM251* blocks CB1 cannabinoid receptors.
- *Fasting* marks experiments in which I removed food from the rats 24 hours before euthanization.
**P1 and P2**: Although the raw values were in pA, I normalized these values relative to the baseline current for each cell. The resulting percent data has `_transformed` in the variable name.
**Interval**: I named each interval 't_to\_' to avoid using numbers and special characters in variable names.