This function computes the weighted correlation with a penalty for lags. It should only be used after the fixed lags have already been applied to the dataset and timepoints using the functions prep.data() and best.lag().
comp.corr(data, time, C)
data | a lagged matrix or data frame with rows representing genes and columns representing different timepoints (NAs added when lags are needed) |
---|---|
time | a lagged matrix with rows representing each gene's timepoint and columns representing the number of timepoints, NA is introduced when it is lagged |
C | a numeric value of C used in computing weighted correlation |
a simmilarity matrix with values between -1 and 1 (1 highly correlated, 0 no correlation)
## This function computes the correlation after the lags (or shifts) have ## been computed. In this example, the lags argument is randomly sampled ## for the sake of illustrating how prep.data() applies the lags and ## prepares a transformed dataset for comp.corr(). lagged <- prep.data(array(rnorm(30), c(3, 10)), timepoints = seq(0, 45, 5), lags = sample(c(0, 1, -1, 2, -2), size = 3)) comp.corr(data = lagged$data, time = lagged$time, C = 10)#> 1 2 #> 2 0.020033639 #> 3 0.004612629 0.166915429## This example shows how comp.corr is used in practice with real data. ## The best.lag() function is called first to pre-compute the lags, which ## are passed to prep.data(). randdata <- array(rnorm(120), c(10, 12)) bl <- best.lag(data = randdata, timepoints = 1:12, C = 5) lag.data <- prep.data(randdata, timepoints = 1:12, lags = bl) comp.corr(lag.data$data, time = lag.data$time, C = 5)#> 1 2 3 4 5 6 #> 2 0.67861143 #> 3 0.74379849 0.41604571 #> 4 -0.10883989 -0.29628916 0.29364153 #> 5 0.12171748 0.05236690 0.19625444 -0.16047194 #> 6 0.16555807 -0.15543591 0.33084530 0.12042764 0.46081170 #> 7 0.13117544 -0.01423879 0.10853907 -0.03027215 0.21047377 0.36789065 #> 8 0.32047719 0.31276718 0.18546001 0.29896231 0.49362817 0.14101381 #> 9 -0.49302349 -0.53412251 -0.14270635 -0.34752417 0.47685720 0.39360609 #> 10 -0.11940481 -0.37677106 0.32322744 0.62266654 -0.02413093 0.07260506 #> 7 8 9 #> 2 #> 3 #> 4 #> 5 #> 6 #> 7 #> 8 0.07397236 #> 9 0.12321073 -0.46186376 #> 10 -0.13460288 -0.07879476 0.16638854