 Hi,

You please imagine I have 23 differenrially expressed genes between tumour (26 samples) and normal (30 samples) tissues.

I have calculated the Pearson correlation values between the expression of these 23 differentially expressed genes in individual samples (56 samples) and the mean of expression of this gene in tumour `(cor1)` and normal `(cor2)` like below

  

    > head(pred)
             cor1     cor2        scores    samples
    cl1   0.8824150 0.7623499  0.06003256  tomour
    cl1.1 0.7928945 0.6831890  0.05485271  tomour
    cl1.2 0.8434347 0.7933102  0.02506226  tomour
    cl1.3 0.7174795 0.5120342  0.10272268  tomour
    cl1.4 0.6571185 0.6084326  0.02434294  tomour
    cl1.5 0.5273702 0.6716480 -0.07213889  tomour

>      > dim(pred)
    [1] 56  4
    > 

And I have calculated a score like so

    (cor1 – cor2)/2 (range: −1 to +1)

+1 says this is tomour sample and -1 says this is a normail sample
    
With such tables how I can represent a correlation plot like this picture? in this plot nicely samples were divided by scores and correlation



![enter image description here][1]



By this code 

  

        b <- ggplot(pred1, aes(x = tomour, y =normal))
    
    b + geom_point(aes(color =samples, shape = samples))+
      geom_smooth(aes(color = samples, fill = samples), method = "lm") +
      geom_rug(aes(color =samples)) +
      scale_color_manual(values = c("#00AFBB", "#E7B800", "#FC4E07"))+
      scale_fill_manual(values = c("#00AFBB", "#E7B800", "#FC4E07"))

I have plotted 

![enter image description here][2]


But this is not similar to what I want at all


  [1]: https://i.ibb.co/W5Gkdtn/Untitled.jpg
  [2]: https://i.ibb.co/fCZs5j0/Rplot03.jpg
use geom_jitter from ggplot


    library(ggplot2)
    library(cowplot)
    
    dat <- data.frame(
      sample=1:10,
      score=c(
        rnorm(n=40,mean = 0.7,sd=0.1),
        rnorm(n=40,mean=0,sd=0.1),
        rnorm(n=20,mean=-0.5,sd=0.1)),
      diagnoses=c(
        rep("ADC",40),
        rep("SCC",40),
        rep("Other NSCLC",20))
      )
    
    head(dat)
    #      sample     score diagnoses
    #    1      1 0.5154322       ADC
    #    2      2 0.7057089       ADC
    #    3      3 0.6860727       ADC
    #    4      4 0.5880083       ADC
    #    5      5 0.7088662       ADC
    #    6      6 0.6122866       ADC
        
    # plot
    ggplot(dat,aes(x=1,y=score,color=diagnoses))+
      geom_jitter(size=2) +
      geom_hline(yintercept = 0) +
      geom_hline(yintercept = 0.2,linetype=2) +
      geom_hline(yintercept = -0.2,linetype=2) +
      theme(axis.title.x=element_blank(), # remove x-axis label
            axis.text.x=element_blank(),
            axis.ticks.x=element_blank())

![enter image description here][1]


  [1]: https://i.imgur.com/6fdsWXP.png