Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MicrobiomeStat::generate_beta_test_single represents errors #52

Open
HuaZou opened this issue May 17, 2024 · 2 comments
Open

MicrobiomeStat::generate_beta_test_single represents errors #52

HuaZou opened this issue May 17, 2024 · 2 comments
Labels
Not a Bug - Solution Provided This behavior is intentional as part of our design. However, we've provided a solution to accommodat

Comments

@HuaZou
Copy link

HuaZou commented May 17, 2024

Hello, when I ran the One-Click Reports Generation by using mStat_generate_report_single, it showed the error information.

in `colnames<-`:
! attempt to set 'colnames' on an object with less than two dimensions
Backtrace:
 1. MicrobiomeStat::generate_beta_test_single(...)
 2. GUniFrac::PermanovaG2(formula, data = data.obj$meta.dat)
 3. GUniFrac::adonis3(as.formula(paste("Y", "~", rhs)), data, ...)
 4. base::`colnames<-`(`*tmp*`, value = colnames(lhs))
                                                                                                                                                                                      
Error in `colnames<-`(`*tmp*`, value = colnames(lhs)) :

after debuging the code, the error actually was from GUniFrac::adonis3. I have no idea on how to solve it. Could you please give me some help?

The following codes were that I ran

data(peerj32.obj)

data.obj = peerj32.obj

# Specify variable names
group.var = "group" # Variable used for grouping samples, primary variable of interest
vis.adj.vars = c("sex") # Covariates whose effects need to be removed before visualization
test.adj.vars = c("sex") # Covariates whose effects need to be adjusted in statistical tests
subject.var = "subject" # Variable used for subject identification
time.var = "time" # Variable used for time points

# Specify diversity indices
alpha.name = c("shannon", "observed_species") # Alpha diversity indices to calculate
dist.name = c("BC",'Jaccard') # Beta diversity indices to calculate

# Specify feature levels for visualization and testing
vis.feature.level = c("Phylum", "Family", "Genus") # Feature levels for visualization to have an overview of the data
test.feature.level = "Family" # Feature level to use for testing

# Specify other parameters
feature.dat.type = "count" # Type of the feature data
theme.choice = "bw" # Theme choice for the plots
base.size = 20 # Base size for the plots

# Parameters for multiple testing. Following setting is just for illustration. In real data analysis, multiple testing correction should always be applied.  
feature.mt.method = "none" # Multiple testing method for differential feature analysis
feature.sig.level = 0.2 # Significance level cutoff for highlighting differential features 

# Specify output file
output.file = "mStat_generate_report_single_example.pdf" # Replace with your own file path for the output report

# Specify optional parameters
dist.obj = NULL # Replace with a pre-computed distance matrix if available
alpha.obj = NULL # Replace with a pre-computed alpha diversity matrix if available
depth = NULL # Replace with a desired rarefaction depth, if NULL, minimum depth will be used
t.level = "1" # Replace with a desired time level if time points have multiple levels
feature.box.axis.transform = "sqrt" # Axis transformation for feature boxplots
strata.var = "sex" # Variable to stratify on in visualization

# Specify parameters for feature retention
bar.area.feature.no = 20 # Number of top abundant features to retain in barplot and areaplot
heatmap.feature.no = 20 # Number of top abundant features to retain in heatmap
dotplot.feature.no = 40 # Number of top abundant features to retain in dotplot

# Run the function
mStat_generate_report_single(
   data.obj = data.obj,
   dist.obj = dist.obj,
   alpha.obj = alpha.obj,
   group.var = group.var,
   vis.adj.vars = vis.adj.vars,
   test.adj.vars = test.adj.vars,
   subject.var = subject.var,
   time.var = time.var,
   alpha.name = alpha.name,
   depth = depth,
   dist.name = dist.name,
   t.level = t.level,
   feature.box.axis.transform = feature.box.axis.transform,
   strata.var = strata.var,
   vis.feature.level = vis.feature.level,
   test.feature.level = test.feature.level,
   feature.dat.type = feature.dat.type,
   bar.area.feature.no = bar.area.feature.no,
   heatmap.feature.no = heatmap.feature.no,
   dotplot.feature.no = dotplot.feature.no,
   feature.mt.method = feature.mt.method,
   feature.sig.level = feature.sig.level,
   theme.choice = theme.choice,
   base.size = base.size,
   output.file = output.file
 )

My Environment Information

R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2

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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Asia/Shanghai
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] lubridate_1.9.3      forcats_1.0.0        stringr_1.5.1        dplyr_1.1.4          purrr_1.0.2          readr_2.1.5         
 [7] tidyr_1.3.1          ggplot2_3.5.1        tidyverse_2.0.0      MicrobiomeStat_1.1.3 tibble_3.2.1         rlang_1.1.3         

loaded via a namespace (and not attached):
 [1] utf8_1.2.4          generics_0.1.3      stringi_1.8.3       lattice_0.22-6      hms_1.1.3           statip_0.2.3       
 [7] lme4_1.1-35.1       magrittr_2.0.3      timechange_0.3.0    grid_4.3.3          iterators_1.0.14    foreach_1.5.2      
[13] Matrix_1.6-5        modeest_2.4.0       fansi_1.0.6         scales_1.3.0        stabledist_0.7-1    codetools_0.2-19   
[19] numDeriv_2016.8-1.1 cli_3.6.2           timeSeries_4032.109 munsell_0.5.0       splines_4.3.3       withr_3.0.0        
[25] tools_4.3.3         rmutil_1.1.10       parallel_4.3.3      tzdb_0.4.0          nloptr_2.0.3        stable_1.1.6       
[31] minqa_1.2.6         colorspace_2.1-0    boot_1.3-30         rpart_4.1.23        vctrs_0.6.5         R6_2.5.1           
[37] matrixStats_1.2.0   lifecycle_1.0.4     clue_0.3-65         MASS_7.3-60.0.1     cluster_2.1.6       pkgconfig_2.0.3    
[43] pillar_1.9.0        lmerTest_3.1-3      gtable_0.3.4        glue_1.7.0          Rcpp_1.0.12         xfun_0.43          
[49] tidyselect_1.2.1    rstudioapi_0.16.0   knitr_1.45          spatial_7.3-17      nlme_3.1-164        fBasics_4032.96    
[55] timeDate_4032.109   compiler_4.3.3     
@HuaZou HuaZou added the bug Something isn't working label May 17, 2024
@cafferychen777
Copy link
Owner

Hi Hua,

Thank you for reporting this issue with the MicrobiomeStat::generate_beta_test_single function. It's indeed a strange error that seems to originate from the GUniFrac::adonis3 function used internally.

I have been unable to reproduce this issue on my own machine so far. Based on the reports from some users who encountered the same problem, it appears that cleaning up the R environment and restarting the R project somehow resolves the issue.

At the moment, the exact cause of this error remains unclear to me. It's possible that there are some environment-specific factors or package conflicts contributing to it.

To help investigate further, it would be helpful if you could provide some additional details:

  1. The versions of the MicrobiomeStat and GUniFrac packages you are using
  2. Your R session info (sessionInfo() output)
  3. Steps to reproduce the error, if possible

In the meantime, as a temporary workaround, you could try the following:

  1. Restart your R session
  2. Detach any loaded packages that are not required
  3. Re-install the MicrobiomeStat and GUniFrac packages
  4. Run your code again

Please let me know if the issue persists after trying these steps. I'll do my best to investigate further and find a proper solution.

Thank you for your understanding and cooperation.

Best regards,
Caffery

@HuaZou
Copy link
Author

HuaZou commented May 20, 2024

Thank you so much. After doing 1-4 steps, the codes ran well. Here is the R pacakges version.

GUniFrac_1.8
MicrobiomeStat_1.1.3

Thank you once again for your valuable advice. The MicrobiomeStat R package is an exceptional tool in the realm of microbiome analysis within the R programming language.

@cafferychen777 cafferychen777 added Not a Bug - Solution Provided This behavior is intentional as part of our design. However, we've provided a solution to accommodat and removed bug Something isn't working labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Not a Bug - Solution Provided This behavior is intentional as part of our design. However, we've provided a solution to accommodat
Projects
None yet
Development

No branches or pull requests

2 participants