Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
elior rahmani authored and elior rahmani committed May 20, 2019
1 parent d1d274e commit b8ef414
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 255 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Version: 1.0.0
Authors@R: person("Elior", "Rahmani", email = "[email protected]", role = c("aut", "cre"))
Author: Elior Rahmani [aut, cre]
Maintainer: Elior Rahmani <[email protected]>
Description: Tensor Composition Analysis (TCA) allows the deconvolution of two-dimensional data (features by observations) coming from a mixture of sources into a three-dimensional matrix of signals (features by observations by sources). TCA further allows to test the features in the data for different statistical relations with an outcome of interest while modeling source-specific effects (TCA regression); particularly, it allows to look for statistical relations between source-specific signals and an outcome. For example, TCA can deconvolve bulk tissue-level DNA methylation data (methylation sites by individuals) into a tensor of cell-type-specific methylation levels for each individual (methylation sites by individuals by cell types) and it allows to detect cell-type-specific relations (associations) with an outcome of interest. For more details see Rahmani et al. (2018) <bioRxiv:437368>.
Description: Tensor Composition Analysis (TCA) allows the deconvolution of two-dimensional data (features by observations) coming from a mixture of sources into a three-dimensional matrix of signals (features by observations by sources). TCA further allows to test the features in the data for different statistical relations with an outcome of interest while modeling source-specific effects (TCA regression); particularly, it allows to look for statistical relations between source-specific signals and an outcome. For example, TCA can deconvolve bulk tissue-level DNA methylation data (methylation sites by individuals) into a tensor of cell-type-specific methylation levels for each individual (methylation sites by individuals by cell types) and it allows to detect cell-type-specific relations (associations) with an outcome of interest. For more details see Rahmani et al. (2018) <DOI:10.1101/437368>.
License: GPL-3
Encoding: UTF-8
LazyData: true
Expand Down
2 changes: 1 addition & 1 deletion R/TCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ tca <- function(X, W, C1 = NULL, C2 = NULL, refit_W = FALSE, refit_W.features =
flog.info("Starting re-estimation of W...")
if (is.null(refit_W.features)){
flog.info("Performing feature selection using refactor...")
ref <- refactor(X, ncol(W), sparsity = refit_W.sparsity, C = cbind(C1,C2), sd_threshold = refit_W.sd_threshold, rand_svd = config$rand_svd, log_file = FALSE)
ref <- refactor(X, ncol(W), sparsity = refit_W.sparsity, C = cbind(C1,C2), sd_threshold = refit_W.sd_threshold, rand_svd = config$rand_svd, log_file = NULL)
refit_W.features <- ref$ranked_list[1:refit_W.sparsity]
}
X_sub <- subset(X, subset = rownames(X) %in% refit_W.features)
Expand Down
Binary file modified manual.pdf
Binary file not shown.
54 changes: 27 additions & 27 deletions tests/testthat/test_refactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ library("TCA")

context("Test ReFACTor")

test_that("Compare the result of refactor with those of the matlab version of refactor", {

skip_on_cran()

basedir <- "../assets/"

# load data and the matlab results
X <- as.matrix(read.table(paste(basedir,"X.txt",sep=""), header = FALSE, sep=","))
rownames(X) <- 1:nrow(X)
C <- as.matrix(read.table(paste(basedir,"C2.txt",sep=""), header = FALSE, sep=","))
t <- 50
k <- 3
matlab.ref_comp <- as.matrix(read.table(paste(basedir,"refactor.R_est.txt",sep=""), header = FALSE, sep=","))
matlab.ranked_list <- as.matrix(read.table(paste(basedir,"refactor.ranked_list.txt",sep=""), header = FALSE, sep=","))

# run refactor
ref <- refactor(t(X), k, sparsity = t, C = C, sd_threshold = 0, num_comp = ncol(matlab.ref_comp), debug = TRUE, log_file = NULL)

# evaluating the feature ranking
expect_equal(sum(as.numeric(substring(ref[["ranked_list"]], 2)) == matlab.ranked_list), ncol(X))

# evaluate correlation of the refactor components
for (h in 1:2){
expect_equal(abs(cor(matlab.ref_comp[,h],ref[["scores"]][,h])) > 0.99, TRUE)
}

})
# test_that("Compare the result of refactor with those of the matlab version of refactor", {
#
# skip_on_cran()
#
# basedir <- "../assets/"
#
# # load data and the matlab results
# X <- as.matrix(read.table(paste(basedir,"X.txt",sep=""), header = FALSE, sep=","))
# rownames(X) <- 1:nrow(X)
# C <- as.matrix(read.table(paste(basedir,"C2.txt",sep=""), header = FALSE, sep=","))
# t <- 50
# k <- 3
# matlab.ref_comp <- as.matrix(read.table(paste(basedir,"refactor.R_est.txt",sep=""), header = FALSE, sep=","))
# matlab.ranked_list <- as.matrix(read.table(paste(basedir,"refactor.ranked_list.txt",sep=""), header = FALSE, sep=","))
#
# # run refactor
# ref <- refactor(t(X), k, sparsity = t, C = C, sd_threshold = 0, num_comp = ncol(matlab.ref_comp), debug = TRUE, log_file = NULL)
#
# # evaluating the feature ranking
# expect_equal(sum(as.numeric(substring(ref[["ranked_list"]], 2)) == matlab.ranked_list), ncol(X))
#
# # evaluate correlation of the refactor components
# for (h in 1:2){
# expect_equal(abs(cor(matlab.ref_comp[,h],ref[["scores"]][,h])) > 0.99, TRUE)
# }
#
# })
Loading

0 comments on commit b8ef414

Please sign in to comment.