toLonger <- function(expressionMatrix) {
expressionMatrix <- longExpressionMatrix <- expressionMatrix %>%
as.data.frame() %>%
rownames_to_column("gene") %>%
pivot_longer(cols = !gene,
values_to = "Expression",
names_to = "sample_id")
return(expressionMatrix)
}
toLonger(dge_cpmlogtwo) %>%
ggplot(aes(x = Expression, color = sample_id)) +
geom_density() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
I want to make the colors in the third last line stand out more? I found this reply but was not able to understand how to apply it to my code.
Lastly is there a way to ensure my plots will be color blind frinedly?
Regarding colorblind friendly palettes, you could consult these two links which address the issue:
I don't have access to your data, but you should be able to click around to find a palette you like, and apply it to your ggplot with the info linked above, good luck!
Here's an example of how it might apply to your case:
toLonger(dge_cpmlogtwo) %>%
ggplot(aes(x = Expression, color = sample_id)) +
geom_density() +
scale_color_brewer(palette="BrBG") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
Also it is aparently not very clear how to find the palette codes in question, eg BrBG, but one way would be like this:
palette= argument for eg. scale_color_brewer , like I have done above.See this image to see what I mean, on it I have the cookbook-r.com and colorbrewer2.org pages from above opened in two windows. Red rectangular highlight is added by me:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With