Question: Correlation plot by correlation values in R
gravatar for F
4 days ago by
F3.2k wrote:


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

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

But this is not similar to what I want at all

rna-seq correlation R • 292 views
ADD COMMENTlink modified 2 days ago by Nicolas Rosewick7.2k • written 4 days ago by F3.2k

What have you tried? What is the ggplot code you have written so far?

Side note: Two ways to spell tumor are tumor or tumour. "Toumor" is not a valid word.

ADD REPLYlink modified 4 days ago • written 4 days ago by RamRS20k

Hi Thank you

I have found a function to calculate correlation, then I need to plot these correlations

ADD REPLYlink modified 3 days ago • written 4 days ago by F3.2k

Trying to "adjust" your data to a function found somewhere won't really work well. You have a good grasp on what you need, why not start at the basics and try plotting a correlation plot between two vectors of numbers, then expand step-by-step until you get to where you want? That's how you'll learn, not by trying to fit datasets into random code.

ADD REPLYlink written 4 days ago by RamRS20k

You al right Sorry for that

ADD REPLYlink modified 2 days ago • written 4 days ago by F3.2k

"I need to complete this soon" cannot be a reason for not learning. If you need to get it done soon, you can always hire an expert to do it for you. You have spent enough time and invested enough effort to take your time and get it done right.

ADD REPLYlink modified 4 days ago • written 4 days ago by RamRS20k
gravatar for Nicolas Rosewick
2 days ago by
Belgium, Brussels
Nicolas Rosewick7.2k wrote:

use geom_jitter from ggplot


dat <- data.frame(
    rnorm(n=40,mean = 0.7,sd=0.1),
    rep("Other NSCLC",20))

#      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
  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

enter image description here

ADD COMMENTlink modified 2 days ago • written 2 days ago by Nicolas Rosewick7.2k

Thanks a lot

This is the same code I was looking for since last week

But I don't know what is going wrong with my data pasted in this post that my plot is too ugly

enter image description here

ADD REPLYlink written 2 days ago by F3.2k

Simply reduce the width size of your plot. And your score seems not so widely distributed (between -1 and 1) as the plot you showed in your post (more between -0.1 and 0.1)

ADD REPLYlink written 2 days ago by Nicolas Rosewick7.2k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1205 users visited in the last hour