I have two matrices like this:

> head(DEG_log[,1:4])
            cl1       cl1       cl1       cl1
ALB    4.653796  7.046317  7.732135  7.758708
AQP9   7.798208  8.231112  8.734799  8.054087
CALML5 5.791524  9.058341  6.977369  9.503477
CCL4   9.739961  7.663303  8.934939  7.324958
CDK6   9.832115  9.710043 11.439345 10.330253
CHGA   5.139340 12.024606  5.988773  8.696836

I have the same patients and genes in two separate matrices coming from two sequencing panels with the same chemistry. Each sample has a match in another panel. I want to remove genes that have low correlation between two matched samples.

I have normalised and log-transformed the data by DESeq2.

I just plotted the correlation between each pairs of samples:

ggscatter(my_data, x = "sample1", y = "sample1_1", 
          add = "reg.line", conf.int = TRUE, 
          cor.coef = TRUE, cor.method = "pearson",
          xlab = "onco", ylab = "biomarker)")

Like this:

enter image description here


corr_test(a, b, 0.95) 

I can calculate correlation, but I don't know how to remove genes with low or non-significant correlation between matched samples.

  • 2
    $\begingroup$ Welcome to the site! What have you tried? Did you found some errors or problems? Please along your wish describe your problem and what have you done so far to solve it, this way it is easier for us to suggest approaches you haven't tried or improvements on them. Do you have the same samples in both matrices (and ordered the same way)? Are the genes ordered the same way in both matrices ? $\endgroup$
    – llrs
    Jan 15, 2019 at 8:07
  • $\begingroup$ Thanks a lot, yes samples and genes are the same coming from same patients sequenced with same chemistry but separately $\endgroup$
    – Zizogolu
    Jan 15, 2019 at 10:52
  • $\begingroup$ @FereshTeh is Mahta Mira another of your accounts? $\endgroup$
    – Devon Ryan
    Jan 15, 2019 at 12:17
  • $\begingroup$ Yes, Sorry. I am logging with Facebook, last night on my laptop this account did not work so I used that but now I am with office's computer $\endgroup$
    – Zizogolu
    Jan 15, 2019 at 12:44
  • 2
    $\begingroup$ @llrs Yup, I'll look into merging the accounts, it'll be a first for me. $\endgroup$
    – Devon Ryan
    Jan 16, 2019 at 15:38

1 Answer 1


Nice data and good question.

It is called "outlier" analysis or the analysis of the residual. Its an easy analysis, but . You calculated the standard deviation using the regression slope as the 'mean' and retain data within 1.96 standard deviations. You can plot the data like this and if you are lucky will see the residual forming a nice 'normal distribution'. Outliers outside 1.96 sd can be formally excluded.

Calling (and plotting) the residual from the regression slope will be possible in R, but I use external packages because its easy. BTW you should also try Spearman's coefficient to check you are getting the same answer.

  • 1
    $\begingroup$ Thanks a lot actually I need my data cleaned from genes with low correlation because I want to combine my data sets. I was not able to find a line of code to remove such genes although I can plot them in correlation plot. $\endgroup$
    – Zizogolu
    Jan 16, 2019 at 8:18
  • $\begingroup$ The specific statistic is "standardisation", its easy to calculation, but really its just working out the SD. Any could good stats package will calculate residual, I like "DataGraph" (Mac). $\endgroup$
    – M__
    Jan 17, 2019 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.