This function computes correlation based on best picked lags. The lags indicate delayed changes.

corr.bestlag(data, timepoints, max.lag = NULL, C = NULL,
  penalty = "high", iter = 10)

Arguments

data

a matrix or data frame with rows representing genes and columns representing different timepoints. If data is a data frame, the gene names can be specified using the row.names().

timepoints

a vector of time points used in the dataset

max.lag

a integer value of the maximum lags allowed in the dataset, if null, defaults to the floor of the number of timepoints divided by 4

C

a numeric value of C used in computing weighted correlation, if null, a default is computed based on the penalty argument

penalty

a factor with two levels high and low penalty on the weighted correlation

iter

an integer indicating the number of C values to test for low penalty

Value

a list containing weighted correlation and best lags used in each row

Examples

corr.bestlag(array(rnorm(30), c(5, 6)), max.lag = 1, timepoints = c(0, 5, 10, 15, 20, 25), C = 10, penalty = "high")
#> $corr #> 1 2 3 4 #> 2 -0.42000485 #> 3 -0.39753686 -0.63640974 #> 4 -0.32406819 -0.45352765 0.66776179 #> 5 -0.82938601 0.66038159 -0.04060399 -0.07683003 #> #> $lags #> [1] 1 0 0 0 0 #> #> $C #> [1] 10 #>
corr.bestlag(array(runif(40, 0, 20), c(4, 10)), timepoints = c(0, 0.5, 1.5, 3, 6, 12, 18, 26, 39, 50), penalty = "high")
#> $corr #> 1 2 3 #> 2 -0.70014226 #> 3 0.44803649 -0.06757151 #> 4 0.44937358 0.06441000 0.33544992 #> #> $lags #> [1] 0 1 0 0 #> #> $C #> [1] 145.7281 #>
corr.bestlag(matrix(data = rexp(n = 40, 2), nrow = 8), timepoints = c(0, 5, 15, 20, 40), penalty = "low", iter = 5)
#> $corr #> 1 2 3 4 5 6 7 #> 2 0.1165434 #> 3 -0.6134928 0.6342942 #> 4 0.2647404 0.1890557 -0.3092350 #> 5 0.4886498 0.5343446 -0.1617593 0.8589109 #> 6 -0.6891120 0.3297292 0.8930882 -0.3590924 -0.3540430 #> 7 0.8761933 0.3717267 -0.4380442 0.6462569 0.8149260 -0.7068592 #> 8 0.6999832 -0.4231984 -0.9586673 0.5263167 0.4358409 -0.9149395 0.6330580 #> #> $lags #> [1] 0 -1 -1 1 -1 0 1 -1 #> #> $C #> [1] 2680.662 #>