Coder Social home page Coder Social logo

trac's People

Contributors

jacobbien avatar muellsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

trac's Issues

still can't run with mac

I installed python and classo but it seems not working when I run the example in mac??

fit <- trac(ztr, ytr, A = sCD14$A, min_frac = 1e-2, nlam = 30)
Error: Python module classo was not found.

Detected Python configuration:

python: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
libpython: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/config-3.9-darwin/libpython3.9.dylib
pythonhome: /Library/Frameworks/Python.framework/Versions/3.9:/Library/Frameworks/Python.framework/Versions/3.9
version: 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53) [Clang 6.0 (clang-600.0.57)]
numpy: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy
numpy_version: 1.21.1
classo: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/classo

NOTE: Python version was forced by RETICULATE_PYTHON

Include a demonstration data set

This could be a small synthetic data set, that would include x, y, and tax. We could then add examples to all of our functions showing how they are used.

Add remotes for ggb

Hi Jacob,

great package! One minor suggestion: As long as ggb stays on Github, maybe you could add a remotes line for ggb to the DESCRIPTION file, like this:

Remotes: jacobbien/ggb

This way, the installation of trac using install_github should directly search for ggb on Github, not on CRAN. Otherwise users of trac will get an error

Error: Failed to install 'trac' from GitHub:
  (converted from warning) package ‘ggb’ is not available for this version of R

when trying to install trac (and some users might not know where to search for ggb then). Alternatively: Add one line of explanation to your README.

Awesome work!
David

Error running the example

Hello.
I think trac will be quite useful for something I want to do but I haven't been able to get it to run correctly. When I try to run the example, R crashes. I'm using R 4.1.1.

fit <- trac(ztr, ytr, A = sCD14$A, min_frac = 1e-2, nlam = 30)

*** caught segfault ***
address (nil), cause 'memory not mapped'

Traceback:
1: py_call_impl(callable, dots$args, dots$keywords)
2: prob$solve()
3: trac(ztr, ytr, A = sCD14$A, min_frac = 0.01, nlam = 30)

can't run the example in vignette

I tried to run the example in the vignette, it gives me the error

library(trac)
names(sCD14)
set.seed(123)
ntot <- length(sCD14$y)
n <- round(2/3 * ntot)
tr <- sample(ntot, n)
log_pseudo <- function(x, pseudo_count = 1) log(x + pseudo_count)
ytr <- sCD14$y[tr]
yte <- sCD14$y[-tr]
ztr <- log_pseudo(sCD14$x[tr, ])
zte <- log_pseudo(sCD14$x[-tr, ])
fit <- trac(ztr, ytr, A = sCD14$A, min_frac = 1e-2, nlam = 30)

Error in diag(1/w[[iw]]) %*% delta : non-conformable arguments

cannot fit for only a single value for lambda

Suppose I have already chosen a penalization parameter lambda, and I want to fit trac() on a dataset with only that value of lambda .

This situation arises if I want to perform the cross-validation for selection of regularization parameter lambda outside of trac(), for instance.

Let's suppose I want to use lambda = 0.15. Following the vignette, the following attempt causes an error in c-lasso:

# from the vignette:
library(trac)
names(sCD14)
set.seed(123)
ntot <- length(sCD14$y)
n <- round(2/3 * ntot)
tr <- sample(ntot, n)
log_pseudo <- function(x, pseudo_count = 1) log(x + pseudo_count)
ytr <- sCD14$y[tr]
yte <- sCD14$y[-tr]
ztr <- log_pseudo(sCD14$x[tr, ])
zte <- log_pseudo(sCD14$x[-tr, ])

# use fraclist to select a single value for lambda.
fit <- trac(ztr, ytr, A = sCD14$A, fraclist = 0.15 ) # lambda = 0.15 is my favorite.

The error message is:

Error in py_call_impl(callable, dots$args, dots$keywords) :
  TypeError: 'float' object is not subscriptable

Detailed traceback:
  File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/solver.py", line 133, in solve
    self.solution.PATH = solution_PATH(
  File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/solver.py", line 845, in __init__
    out = pathlasso(
  File "/data1/packages/python_3.8_venv_20210618/lib/python3.8/site-packages/classo/compact_func.py", line 208, in pathlasso
    if lambdas[0] < lambdas[-1]:

It looks like it fails because c-lasso requires at least two values of lambda in order to work.

In support of that hypothesis, the same error message is returned if I try to execute trac() as in the vignette but restricting nlam=1:

fit <- trac(ztr, ytr, A = sCD14$A, min_frac = 1e-2, nlam = 1)

tax_table_to_phylo does not return the right column name for internal nodes

Hi, with the new update of ape to version 5.5 the names of the node labels returned by tax_table_to_phylo are not informative. More precisely, it only returns the name of the root of the taxonomic tree. This behaviour could be linked to the updated read.tree function from ape in version 5.5.

Reproducible example (relevant outputs in the comments):

library(phyloseq)
library(trac)
# data generated based on http://joey711.github.io/phyloseq/import-data.html
set.seed(1)
# construct a example tax table
taxmat <- matrix(sample(letters, 70, replace = TRUE), nrow = 10, ncol = 7)
# construct 2 different kingdoms --> aggregation at least for these 2
taxmat[, 1] <- c(rep("a", times = 5), rep("b", times = 5))
rownames(taxmat) <- paste0("OTU", 1:10)
colnames(taxmat) <- c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species")
tax <- tax_table(taxmat)


# Copied from https://github.com/jacobbien/trac-reproducible/blob/main/AmericanGut/1prep_data_all_levels.R
tax <- [email protected]
prefix <- paste0(c("k", "p", "c", "o", "f", "g", "s"), "__")
for (i in seq_len(length(prefix))) tax[, i] <- paste0(prefix[i], tax[, i])
tax <- cbind("Life", tax); colnames(tax)[1] <- "Rank0"
# add an OTU column
tax <- cbind(tax, rownames(tax))
colnames(tax)[ncol(tax)] <- "OTU"

# cumulative labels are harder to read but easier to work with:
for (i in 2:9) {
  tax[, i] <- paste(tax[, i-1], tax[, i], sep = "::")
}
tax <- as.data.frame(tax, stringsAsFactors = TRUE)

# form phylo object:
tree1 <- tax_table_to_phylo(~Rank0/Kingdom/Phylum/Class/Order/Family/Genus/Species/OTU,
                            data = tax, collapse = TRUE)
tree1$node.label
# would expect at least c("Life", "Life:k__a", Life::k__b") but get
# c("Life" "Life" "Life" "Life")


# convert this to an A matrix to be used for aggregation:
A <- phylo_to_A(tree1)
as.matrix(A)
# still works but the column names for the nodes are all "Life"

sessionInfo()
# R version 4.0.3 (2020-10-10)
# Platform: x86_64-apple-darwin17.0 (64-bit)
# Running under: macOS Catalina 10.15.7
# 
# Matrix products: default
# BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
# LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
# 
# locale:
#   [1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
# 
# attached base packages:
#   [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
#   [1] trac_0.0.1      phyloseq_1.34.0
# 
# loaded via a namespace (and not attached):
#   [1] reticulate_1.20     progress_1.2.2      tidyselect_1.1.1    reshape2_1.4.4      purrr_0.3.4        
# [6] splines_4.0.3       lattice_0.20-41     rhdf5_2.34.0        colorspace_2.0-1    vctrs_0.3.8        
# [11] generics_0.1.0      stats4_4.0.3        mgcv_1.8-33         survival_3.2-7      utf8_1.2.1         
# [16] rlang_0.4.11        pillar_1.6.0        glue_1.4.2          DBI_1.1.1           BiocGenerics_0.36.0
# [21] foreach_1.5.1       lifecycle_1.0.0     plyr_1.8.6          stringr_1.4.0       zlibbioc_1.36.0    
# [26] Biostrings_2.58.0   munsell_0.5.0       gtable_0.3.0        codetools_0.2-18    Biobase_2.50.0     
# [31] permute_0.9-5       IRanges_2.24.1      biomformat_1.18.0   parallel_4.0.3      fansi_0.4.2        
# [36] Rcpp_1.0.6          scales_1.1.1        vegan_2.5-7         S4Vectors_0.28.1    jsonlite_1.7.2     
# [41] XVector_0.30.0      png_0.1-7           ggplot2_3.3.3       hms_1.0.0           stringi_1.6.1      
# [46] dplyr_1.0.6         grid_4.0.3          ade4_1.7-16         tools_4.0.3         rhdf5filters_1.2.0 
# [51] magrittr_2.0.1      tibble_3.1.1        cluster_2.1.0       crayon_1.4.1        ape_5.5            
# [56] pkgconfig_2.0.3     MASS_7.3-53         ellipsis_0.3.2      Matrix_1.3-2        data.table_1.13.6  
# [61] prettyunits_1.1.1   assertthat_0.2.1    rstudioapi_0.13     iterators_1.0.13    Rhdf5lib_1.12.1    
# [66] R6_2.5.0            multtest_2.46.0     igraph_1.2.6        nlme_3.1-152        compiler_4.0.3     

add refit_trac function

This should not call cvxr but instead use linear algebra since it is a quadratic objective subject to linear equality constraints.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.