I have a data.frame which I'd like to draw edcf lines. There are approximately 96 pos ecdf lines and 96 neg ecdf lines. I'd like to color the pos lines black and the neg lines red. I'd also like to add a level of transparency, or an average line, so that it doesn't look cluttered. And perhaps only include pos and neg in the legend.
Code:
simplify <- function(x){
temp = x[complete.cases(x),]
df.m = reshape2::melt(temp, id.vars = NULL)
df.m$XIST = sapply(strsplit(as.character(df.m$variable), "_", fixed=TRUE), function(x) (x[1]))
return(df.m)
}
temp = simplify(X_chr)
ggplot(temp, aes(value, colour=variable)) + stat_ecdf() + xlim(1,1000) + theme_bw()
Temp
looks something like this:
> head(temp, 10)
variable value XIST
1 pos_A1 0.00000 pos
2 pos_A1 0.00000 pos
3 pos_A1 0.00000 pos
4 pos_A1 0.00000 pos
5 pos_A1 0.00000 pos
6 pos_A1 15.66911 pos
7 pos_A1 0.00000 pos
8 pos_A1 0.00000 pos
9 pos_A1 0.00000 pos
10 pos_A1 0.00000 pos
> tail(temp, 10)
variable value XIST
210999 neg_H9 0.000000 neg
211000 neg_H9 0.000000 neg
211001 neg_H9 0.000000 neg
211002 neg_H9 0.000000 neg
211003 neg_H9 0.000000 neg
211004 neg_H9 4.466276 neg
211005 neg_H9 0.000000 neg
211006 neg_H9 0.000000 neg
211007 neg_H9 0.000000 neg
211008 neg_H9 30.033764 neg
Produces: