PowerPoint | free at university, frustrating | |
InkScape | free, open source, not great | |
Adobe Illustrator Adobe InDesign |
$$$, free at university virtual desktop |
|
Affinity Designer Affinity Publisher |
$, lifetime license |
how to use scientific colors in {ggplot2}
library(normentR)
penguins %>%
ggplot(aes(x = bill_length_mm, y = body_mass_g,
color = species)) +
geom_point(size = 2) +
scale_color_norment(discrete = TRUE,
palette = "batlow") +
theme_norment(base_size = 9)
library(scico)
penguins %>%
ggplot(aes(x = bill_length_mm, y = body_mass_g,
color = species)) +
geom_point(size = 2) +
scale_color_scico_d(palette = "batlow") +
theme_minimal(base_size = 9)
theme_minimal()
is your friend
penguins %>%
ggplot(aes(x = bill_length_mm, y = body_mass_g,
color = species)) +
geom_point(size = 2) +
scale_color_norment(discrete = TRUE,
palette = "batlow") +
theme_minimal()
### CREATE SCATTER PLOT ########################
#-- Libraries -------------------------
library(tidyverse)
library(ggtext)
library(scico)
library(patchwork)
#-- Load data ------------------------
...
### RUN XGBOOST ANALYSIS ########################
# -- Libraries -------------------------
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# -- Load data -------------------------
...
data %>%
ggplot(aes(x = gdpPercap, y = lifeExp,
size = pop)) +
geom_point(aes(color = continent)) +
geom_smooth(method = "lm") +
scale_x_log10()
data %>%
ggplot(aes(x = gdpPercap, y = lifeExp,
size = pop)) +
geom_point(aes(color = continent)) +
geom_smooth(method = "lm", show.legend = FALSE) +
scale_x_log10() +
theme_minimal() +
theme(panel.grid = element_line(colour = "grey90"))
data %>%
ggplot(aes(x = gdpPercap, y = lifeExp,
size = pop)) +
geom_point(aes(color = continent), alpha = 0.5, stroke = 0) +
geom_smooth(method = "lm", color = "grey30",
alpha = 0.15, show.legend = FALSE) +
labs(title = "Relation between GDP and life expectancy",
x = "GDP per capita",
y = "Life expectancy",
color = "Continent",
size = "Population") +
scale_x_log10() +
scale_color_scico_d(palette = "batlow") +
scale_size_continuous(range = c(1,15), labels = scales::label_number(),
guide = guide_legend(label.position = "bottom") +
theme_minimal() +
theme(plot.title = element_markdown(size = 14),
legend.box = "vertical",
legend.position = "bottom",
panel.grid = element_line(colour = "grey90")
)
ggplot(data, aes(x = x, y = y, col = as_factor(x))) +
geom_point(size = 5) +
labs(title = "test title",
subtitle = "test subtitle",
x = "my x axis",
y = "my y axis",
caption = "this is a caption",
col = "Renamed Legend") +
facet_grid(w ~ z, switch = "y") +
theme(
plot.background = element_rect(fill = "lightyellow"),
plot.title = element_text(size = 30, hjust = 0.25),
plot.subtitle = element_text(size = 20, hjust = 0.75, color = "mediumvioletred", family = "serif"),
plot.caption = element_text(size = 10, face = "italic", angle = 25),
panel.background = element_rect(fill = "lightblue", colour = "darkred", size = 4),
panel.border = element_rect(fill = NA, color = "green", size = 2),
panel.grid.major.x = element_line(color = "purple", linetype = 2),
panel.grid.minor.x = element_line(color = "orange", linetype = 3),
panel.grid.minor.y = element_blank(),
axis.title.x = element_text(face = "bold.italic", color = "blue"),
axis.title.y = element_text(family = "mono", face = "bold", size = 20, hjust = 0.25),
axis.text = element_text(face = "italic", size = 15),
axis.text.x.bottom = element_text(angle = 180), # note that axis.text options from above are inherited
strip.background = element_rect(fill = "magenta"),
strip.text.y = element_text(color = "white"),
strip.placement = "outside",
legend.background = element_rect(fill = "orangered4"), # generally will want to match w plot background
legend.key = element_rect(fill = "orange"),
legend.direction = "horizontal",
legend.position = "bottom",
legend.justification = "left",
legend.title = element_text(family = "serif", color = "white"),
legend.text = element_text(family = "mono", face = "italic", color = "limegreen")
)
$ pwd
/Users/dtroelfs/Dropbox/NORMENT/r_scripts/ica_genetics
$ tree
./
├── convert_pleio_results.m
├── compare_ic_modelorders.R
├── create_fuma_table.R
├── create_manhattan_figure.R
├── extract_pleio_qq_data.ipynb
├── extract_ukb_questionnaire_fields.R
├── figures/
│ ├── ica_weightmatrix.png
│ ├── ic_heritability.png
│ ├── ic_manhattan_plots.png
│ ├── icxic_ldsc_matrix.png
│ └── questionscores_distribution.png
├── files/
│ ├── fuma_job_names.txt
│ ├── ica_loadings.txt
│ ├── ldsc_stats.txt
│ ├── question_definitions.txt
│ └── sumstats/
│ ├── GWAS_ICA_1.sumstats.gz
│ └── GWAS_ICA_2.sumstats.gz
├── ica_genetics.Rproj
├── plot_heritability.R
├── plot_ica_weight_matrix.R
├── plot_icxic_ldsc_matrix.R
└── plot_questionnaire_scores.R
3 directories, 21 files
### PLOT ICA WEIGHT MATRIX ########################
#-- Libraries -------------------------
library(tidyverse)
#-- Load data ------------------------
data <- read_csv("files/ica_loadings.txt") %>%
janitor::clean_names()
#-- Wrangle data ------------------------
data <- data %>%
mutate(diagnosis = str_to_upper(diagnosis))
#-- Create plot ------------------------
data %>%
pivot_longer(cols = starts_with("ic"), names_to = "ic", values_to = "loading") %>%
mutate(ic = fct_reorder(ic, parse_number(ic))) %>%
ggplot(aes(x = ic, y = question, fill = loading)) +
geom_tile()
{scico}
(R package with scientific color maps){ggplot2}
-based tutorial)