forked from diazale/gt-dimred
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UKBB_plotting.Rmd
executable file
·84 lines (72 loc) · 2.79 KB
/
UKBB_plotting.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
---
title: "London alpha plotting"
author:
- name: Alex Diaz-Papkovich
affiliation:
- &cruk Quantitative Life Sciences, McGill University, Montreal, Canada
date: '`r format(Sys.Date(), "%Y-%B-%d")`'
output:
html_notebook:
df_print: paged
code_folding: show
toc: yes
toc_float:
collapsed: false
smooth_scroll: false
---
## Plotting UKBB stuff
Python's plotting is getting on my nerves. I want to make a scatterplot where I specify each point's colour and alpha values.
# Import libraries
```{r}
library(ggplot2)
library(tidyverse)
```
# Import the data
```{r}
data_dir <- "/Volumes/Stockage/alex/ukbb_other/data/london_alphas.csv"
ukbb_plotting_data <- read.csv(data_dir)
ukbb_plotting_data <- ukbb_plotting_data[!(ukbb_plotting_data$eth_txt %in% c('British', 'Irish', 'Any other white background')),]
out_dir <- "/Volumes/Stockage/alex/ukbb_images/london_alpha"
fname <- "UKBB_UMAP_PC10_NN15_MD05_2018328174511_within50km"
h <- 15
w <- 15
p_scatter <- ggplot(ukbb_plotting_data, aes(x=x_coords, y=y_coords)) +
geom_point(colour=ukbb_plotting_data$colour, alpha=ukbb_plotting_data$London_alpha, stroke=0) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())
p_scatter
ggsave(paste(out_dir, paste(fname,".jpeg",sep=""), sep="/"), device = "jpeg", height = h, width = w, units = "in")
```
# What about those outside of 50k from London?
```{r}
data_dir <- "/Volumes/Stockage/alex/ukbb_other/data/london_alphas.csv"
ukbb_plotting_data <- read.csv(data_dir)
ukbb_plotting_data <- ukbb_plotting_data[!(ukbb_plotting_data$eth_txt %in% c('British', 'Irish', 'Any other white background')),]
ukbb_plotting_data$Outside_London <- ifelse(ukbb_plotting_data$London_alpha==0,1,0)
out_dir <- "/Volumes/Stockage/alex/ukbb_images/london_alpha"
fname <- "UKBB_UMAP_PC10_NN15_MD05_2018328174511_outside_50km"
h <- 15
w <- 15
p_scatter <- ggplot(ukbb_plotting_data, aes(x=x_coords, y=y_coords)) +
geom_point(colour=ukbb_plotting_data$colour, alpha=ukbb_plotting_data$Outside_London, stroke=0) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.border = element_blank(),
panel.background = element_blank())
p_scatter
ggsave(paste(out_dir, paste(fname,".jpeg",sep=""), sep="/"), device = "jpeg", height = h, width = w, units = "in")
```