Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57 from d3b-center/alluv-color
Browse files Browse the repository at this point in the history
update alluvial plot colors
  • Loading branch information
rjcorb authored Apr 19, 2024
2 parents 39fbe86 + 4187d24 commit 4539efb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions analyses/add-histologies/03-alluvial_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,25 @@ alluvial_df <- as.data.frame(table(ancestry$predicted_ancestry, ancestry$race, a

# Generate alluvial plot
p1 <- ggplot(alluvial_df, aes(y = Freq, stratum = Group, alluvium = alluvium, x = x, fill = Group)) +
geom_alluvium(show.legend = F) +
geom_stratum(show.legend = F) +
scale_fill_manual(values = c("Asian" = "#009E73", "SAS" = "#D55E00", "EAS" = "#009E73",
"White" = "#0072B2", "EUR" = "#0072B2",
"Black/Afr. Am." = "#E69F00", "AFR" = "#E69F00",
"NHPI" = "skyblue", "AMR" = "#56B4E9",
"AI/AN" = "#56B4E9",
"Race Unknown" = "grey", ">1 Race" = "brown",
"Hispanic/Latino" = "#56B4E9",
"Not Hispanic/Latino" = "#0072B2",
geom_alluvium(show.legend = F, size = 0.3) +
geom_stratum(show.legend = F, size = 0.3) +
scale_fill_manual(values = c("Asian" = "#4B0055", "SAS" = "#D55E00", "EAS" = "#009E73",
"White" = "#7ED357", "EUR" = "#0072B2",
"Black/Afr. Am." = "#353E7C", "AFR" = "#E69F00",
"NHPI" = "#00B28A", "AMR" = "#56B4E9",
"AI/AN" = "#FDE333",
"Race Unknown" = "grey", ">1 Race" ="#008298",
"Hispanic/Latino" = "#CC79A7",
"Not Hispanic/Latino" = "#882255",
"Unknown" = "grey")) +
xlab("") +
ylab("Number of Patients") +
scale_x_discrete(labels = c("predicted ancestry", "reported race", "reported ethnicity")) +
theme_Publication()

# colors used for reported race
hcl.colors(n = 6)

# Create separate ancestry, race, and ethnicity dfs for legend generation
race_df <- data.frame(race = c("Asian", "Black/Afr. Am.", "AI/AN",
"NHPI", "White", ">1 Race",
Expand All @@ -114,12 +117,12 @@ lgd_race <- ggplot(race_df, aes(x = value, y = factor(race, levels = c("Race Unk
fill = race)) +
geom_tile(show.legend = T, color = "black",
lwd = 0.5, linetype = 1) +
scale_fill_manual(values = c("Asian" = "#009E73",
"White" = "#0072B2",
"Black/Afr. Am." = "#E69F00",
"AI/AN" = "#56B4E9",
"NHPI" = "skyblue",
">1 Race" = "brown",
scale_fill_manual(values = c("Asian" = "#4B0055",
"White" = "#7ED357",
"Black/Afr. Am." = "#353E7C",
"AI/AN" = "#FDE333",
"NHPI" = "#00B28A",
">1 Race" = "#008298",
"Race Unknown" = "grey"),
breaks = c("Asian",
"Black/Afr. Am.",
Expand Down Expand Up @@ -157,8 +160,8 @@ lgd_ethn <- ggplot(ethnicity_df, aes(x = value, y = factor(ethnicity,
geom_tile(show.legend = T, col = "black",
lwd = 0.5, linetype = 1) +
#xlim() +
scale_fill_manual(values = c("Hispanic/Latino" = "#56B4E9",
"Not Hispanic/Latino" = "#0072B2",
scale_fill_manual(values = c("Hispanic/Latino" = "#CC79A7",
"Not Hispanic/Latino" = "#882255",
"Unknown" = "grey")) +
labs(fill = "Reported Ethnicity") +
theme_Publication()
Expand All @@ -174,10 +177,10 @@ final_p <- plot_grid(p1, leg,
nrow = 1,
align = "none",
axis = "t",
rel_widths = c(1,0.45))
rel_widths = c(1,0.4))

pdf(file.path(plots_dir, "ancestry-race-ethnicity-alluvial.pdf"),
width = 10, height = 6)
width = 9, height = 6)

final_p

Expand Down
Binary file not shown.

0 comments on commit 4539efb

Please sign in to comment.