Removing genes with less than a correlation cut-off between two matrices I have two matrices like this:

&gt; 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
&gt; 


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: 

library("ggpubr")
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:



by:

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