I have seen example1 and How to overlay density plots in R? and Overlapped density plots in ggplot2 about how to make density plot. I can make a density plot with the codes in the second link. However I am wondering how can I make such a graph in ggplot
or plotly
?
I have looked at all the examples but cannot figure it out for my problem.
I have a toy data frame with gene expression leukemia data description, which columns in it refers to 2 groups of individuals
leukemia_big <- read.csv("http://web.stanford.edu/~hastie/CASI_files/DATA/leukemia_big.csv")
df <- data.frame(class= ifelse(grepl("^ALL", colnames(leukemia_big),
fixed = FALSE), "ALL", "AML"), row.names = colnames(leukemia_big))
plot(density(as.matrix(leukemia_big[,df$class=="ALL"])),
lwd=2, col="red")
lines(density(as.matrix(leukemia_big[,df$class=="AML"])),
lwd=2, col="darkgreen")