-
Notifications
You must be signed in to change notification settings - Fork 4
/
PlaceFieldsvsRamps.Rmd
124 lines (102 loc) · 2.93 KB
/
PlaceFieldsvsRamps.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
---
title: "PlaceFieldsvsRamps"
author: "Matt"
date: "13/05/2020"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(cowplot)
```
```{r Make Gaussian field}
x <- 1:1000
loc <- 500
sd <- 100
field <- exp(-1*((x-loc)^2)/(2*sd^2))
tb <- tibble(x = x, y = field)
```
Make family of tidy fields
```{r}
x_f <- rep(x, 5)
id <- c(rep(1,1000), rep(2,1000), rep(3,1000), rep(4,1000), rep(5,1000))
locs <- id*200-100
fields <- exp(-1*((x_f-locs)^2)/(2*sd^2))
tb_f <- tibble(x = x_f, y = fields, id = as.factor(id))
```
```{r}
ggplot(tb, aes(x, y)) +
geom_line()
(fields <- ggplot(tb, aes(x, y)) +
geom_line() +
labs(title = "Discrete place field\n",
y = "Firing rate",
x = "Location") +
theme_cowplot() +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position="none",
axis.text.x = element_text(size=0),
axis.text.y = element_text(size=0),
legend.title = element_blank(),
text = element_text(size=17)))
ggsave(file = "Figure1_A.png", width = 4, height = 3.5)
```
Make and plot a ramp
```{r}
ramp <- x/1000
tb_r <- tibble(x = x, y = ramp)
(ramp <- ggplot(tb_r, aes(x, y)) +
geom_line() +
labs(title = "Continous ramp-like code\n",
y = "Firing rate",
x = "Location") +
theme_cowplot() +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position="none",
axis.text.x = element_text(size=0),
axis.text.y = element_text(size=0),
legend.title = element_blank(),
text = element_text(size=17)))
ggsave(file = "Figure1_B.png", width = 4, height = 3.5)
```
Assemble into a figure
```{r}
plot_grid(fields, ramp, labels = c("A", "B"), label_size = 18)
ggsave(file = "Figure1_Schematic.png", width = 10, height = 4)
```
# Now make version with multiple place fields and a resetting ramp
```{r}
(fields_ensemble <- ggplot(tb_f, aes(x, y)) +
geom_line(aes(colour = id)) +
labs(y = "Firing rate",
x = "Location") +
theme_cowplot() +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position="none",
axis.text.x = element_text(size=0),
axis.text.y = element_text(size=0),
legend.title = element_blank(),
text = element_text(size=17)))
ggsave(file = "MultipleFields.png", width = 4, height = 2)
```
```{r}
ramp_reset <- c(x/1000, x/1000)
x_2 <- c(x,1000+x)
tb_r_r <- tibble(x = x_2, y = ramp_reset)
(ramp <- ggplot(tb_r_r, aes(x, y)) +
geom_line() +
labs(y = "Firing rate",
x = "Location") +
theme_cowplot() +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
legend.position="none",
axis.text.x = element_text(size=0),
axis.text.y = element_text(size=0),
legend.title = element_blank(),
text = element_text(size=17)))
ggsave(file = "ResettingRamp.png", width = 4, height = 2)
```