I have 209 cells. I want to show the expression of two genes by ordering my cells. Imagine something like a plot on which y axis shows the read counts range from 0 to 10000 and x axis shows the number of cells (there is a link of an example picture that I wish to produce the same). So that two colours bars each colour for a gene.
I have used this code but result is not as I want at all
# Library library(tidyverse) # Create data value1=abs(rnorm(26))*2 data=data.frame(x=LETTERS[1:26], value1=value1, value2=value1+1+rnorm(26, sd=1) ) # Reorder data using average? data = data %>% rowwise() %>% mutate( mymean = mean(c(value1,value2) )) %>% arrange(mymean) %>% mutate(x=factor(x, x)) # plot ggplot(data) + geom_segment( aes(x=x, xend=x, y=value1, yend=value2), color="grey") + geom_point( aes(x=x, y=value1), color=rgb(0.2,0.7,0.1,0.5), size=3 ) + geom_point( aes(x=x, y=value2), color=rgb(0.7,0.2,0.1,0.5), size=3 ) + coord_flip()
This is link of my data and my result picture
And to some data