1
$\begingroup$

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

enter image description here

And to some data

$\endgroup$
  • $\begingroup$ Could you add an example of what a lollipop is? (a link or something like that?) And what have you tried to make that plot (To avoid suggesting to do the same and help you more specifically) $\endgroup$ – llrs Jun 23 '18 at 14:29
  • $\begingroup$ Thank you, I edited my post. Actually lollipop plot itself dose not matter that can be replaced by any other plots. The problem is that I could not figure out how to plot the same as picture and what I have tried up to now did not answer my question :( $\endgroup$ – Angel Jun 23 '18 at 18:11
  • 1
    $\begingroup$ could you further explain how this picture doesn't help you ?. I am still trying to figure out how I can help $\endgroup$ – llrs Jun 25 '18 at 8:46
  • $\begingroup$ Thank you, because on gene seems to be compressed at the end and does not allow to another gene to be cleared. I don't know how to have another gene on another axis or showing y axis in log10 $\endgroup$ – Angel Jun 25 '18 at 10:51
  • 1
    $\begingroup$ So, your problem is how to convert an axis to log10? This is answered in Stack Overflow and other venues. In ggplot2 you can't have two axis by design: it is against the grammar of graphics. $\endgroup$ – llrs Jun 25 '18 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.