R Under development (unstable) (2020-01-30 r77751) -- "Unsuffered Consequences" Copyright (C) 2020 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > pkgname <- "NNLM" > source(file.path(R.home("share"), "R", "examples-header.R")) > options(warn = 1) > library('NNLM') > > base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') > base::assign(".old_wd", base::getwd(), pos = 'CheckExEnv') > cleanEx() > nameEx("nnlm") > ### * nnlm > > flush(stderr()); flush(stdout()) > > ### Name: nnlm > ### Title: Non-negative linear model/regression (NNLM) > ### Aliases: nnlm > > ### ** Examples > > > # without negative value > x <- matrix(runif(50*20), 50, 20); > beta <- matrix(rexp(20*2), 20, 2); > y <- x %*% beta + 0.1*matrix(runif(50*2), 50, 2); > beta.hat <- nnlm(x, y, loss = 'mkl'); /data/gannet/ripley/R/test-clang/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:1223:23: runtime error: reference binding to null pointer of type 'const unsigned int' #0 0x7fe2fc9fe948 in arma::subview::colptr(unsigned int) /data/gannet/ripley/R/test-clang/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:1223:12 #1 0x7fe2fc9fe948 in arma::subview_col::subview_col(arma::Mat const&, unsigned int) /data/gannet/ripley/R/test-clang/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:3047:25 #2 0x7fe2fc9f8ad8 in arma::Mat::col(unsigned int) const /data/gannet/ripley/R/test-clang/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:2956:10 #3 0x7fe2fc9f8ad8 in .omp_outlined._debug__ /data/gannet/ripley/R/packages/tests-clang-SAN/NNLM/src/update_with_missing.cpp:47:60 #4 0x7fe2fc9f8ad8 in .omp_outlined. /data/gannet/ripley/R/packages/tests-clang-SAN/NNLM/src/update_with_missing.cpp:30:2 #5 0x7fe2fc8a1a22 in __kmp_invoke_microtask (/usr/local/clang/lib64/libomp.so+0x8fa22) #6 0x7fe2fc84a17a in __kmp_fork_call (/usr/local/clang/lib64/libomp.so+0x3817a) #7 0x7fe2fc83dbbe in __kmpc_fork_call (/usr/local/clang/lib64/libomp.so+0x2bbbe) #8 0x7fe2fc9f78d1 in update(arma::Mat&, arma::Mat const&, arma::Mat const&, arma::Mat const&, arma::Col const&, unsigned int, double, int, int) /data/gannet/ripley/R/packages/tests-clang-SAN/NNLM/src/update_with_missing.cpp:29:2 #9 0x7fe2fc9af43c in c_nnlm(arma::Mat const&, arma::Mat const&, arma::Col const&, arma::Mat const&, arma::Mat const&, unsigned int, double, int, int) /data/gannet/ripley/R/packages/tests-clang-SAN/NNLM/src/nnlm.cpp:47:11 #10 0x7fe2fc97d06e in _NNLM_c_nnlm /data/gannet/ripley/R/packages/tests-clang-SAN/NNLM/src/RcppExports.cpp:24:34 #11 0x6ed6da in R_doDotCall /data/gannet/ripley/R/svn/R-devel/src/main/dotcode.c:629:17 #12 0x856771 in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7610:21 #13 0x83b175 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:688:8 #14 0x89e323 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c #15 0x89b28a in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1779:16 #16 0x85a65a in bcEval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:7022:12 #17 0x83b175 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:688:8 #18 0x89e323 in R_execClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c #19 0x89b28a in Rf_applyClosure /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:1779:16 #20 0x83bfdb in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:811:12 #21 0x8abe8b in do_set /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:2920:8 #22 0x83b7b3 in Rf_eval /data/gannet/ripley/R/svn/R-devel/src/main/eval.c:763:12 #23 0x975266 in Rf_ReplIteration /data/gannet/ripley/R/svn/R-devel/src/main/main.c:264:2 #24 0x9797e0 in R_ReplConsole /data/gannet/ripley/R/svn/R-devel/src/main/main.c:314:11 #25 0x9795c5 in run_Rmainloop /data/gannet/ripley/R/svn/R-devel/src/main/main.c:1113:5 #26 0x4da36a in main /data/gannet/ripley/R/svn/R-devel/src/main/Rmain.c:29:5 #27 0x7fe30d768f42 in __libc_start_main (/lib64/libc.so.6+0x23f42) #28 0x43037d in _start (/data/gannet/ripley/R/R-clang-SAN/bin/exec/R+0x43037d) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /data/gannet/ripley/R/test-clang/RcppArmadillo/include/armadillo_bits/subview_meat.hpp:1223:23 in > > # with negative values > x2 <- 10*matrix(rnorm(50*20), 50, 20); > y2 <- x2 %*% beta + 0.2*matrix(rnorm(50*2), 50, 2); > beta.hat2 <- nnlm(x, y); > > > > > cleanEx() > nameEx("nnmf") > ### * nnmf > > flush(stderr()); flush(stdout()) > > ### Name: nnmf > ### Title: Non-negative matrix factorization > ### Aliases: nnmf > > ### ** Examples > > > # Pattern extraction, meta-gene > set.seed(123); > > data(nsclc, package = 'NNLM') > str(nsclc) num [1:200, 1:100] 7.06 6.41 7.4 9.38 5.74 ... - attr(*, "dimnames")=List of 2 ..$ : chr [1:200] "PTK2B" "CTNS" "POLE" "NIPSNAP1" ... ..$ : chr [1:100] "P001" "P002" "P003" "P004" ... > > decomp <- nnmf(nsclc[, 1:80], 3, rel.tol = 1e-5); 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| > > heatmap(decomp$W, Colv = NA, xlab = 'Meta-gene', ylab = 'Gene', margins = c(2,2), + labRow = '', labCol = '', scale = 'column', col = cm.colors(100)); > heatmap(decomp$H, Rowv = NA, ylab = 'Meta-gene', xlab = 'Patient', margins = c(2,2), + labRow = '', labCol = '', scale = 'row', col = cm.colors(100)); > > # missing value imputation > set.seed(123); > nsclc2 <- nsclc; > index <- sample(length(nsclc2), length(nsclc2)*0.3); > nsclc2[index] <- NA; > > # impute using NMF > system.time(nsclc2.nmf <- nnmf(nsclc2, 2)); 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| user system elapsed 0.326 0.041 0.554 > nsclc2.hat.nmf <- with(nsclc2.nmf, W %*% H); > > mse.mkl(nsclc[index], nsclc2.hat.nmf[index]) MSE MKL 0.43887321 0.03159232 > > > > > cleanEx() > nameEx("predict.nnmf") > ### * predict.nnmf > > flush(stderr()); flush(stdout()) > > ### Name: predict.nnmf > ### Title: Methods for nnmf object returned by 'nnmf' > ### Aliases: predict.nnmf print.nnmf > > ### ** Examples > > > x <- matrix(runif(50*20), 50, 20) > r <- nnmf(x, 2) 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| > r Non-negative matrix factorization: Algorithm: Sequential coordinate-wise descent Loss: Mean squared error MSE: 0.06796673 MKL: 0.07985837 Target: 0.03398336 Rel. tol.: 8.56e-05 Total epochs: 468 # Interation: 21 Running time: user system elapsed 0.013 0.000 0.017 > newx <- matrix(runif(50*30), 50, 30) > pred <- predict(r, newx, 'H') > > > > > ### *