cafferychen777 / MicrobiomeStat

Track, Analyze, Visualize: Unravel Your Microbiome's Temporal Pattern with MicrobiomeStat
https://www.microbiomestat.wiki/
31 stars 5 forks source link

Could not find function "mStat_convert_phyloseq_to_data_obj" #34

Open QGaelle opened 8 months ago

QGaelle commented 8 months ago

Hello,

I am excited to use the MicrobioStat package in order to test for differences in alpha diversity accross timepoints. I have been working with phyloseq object so far and I would like to convert my Phyloseq object to a MicrobiomeStat data object.

I have been following the installation guide but somehow I keep getting the following error: Error in mStat_convert_phyloseq_to_data_obj(peerj32.phy) : could not find function "mStat_convert_phyloseq_to_data_obj"

I am working on Mac and I am using R version 4.3.1 (2023-06-16)

Here is the script I used:

Install MicroBiomStat

install.packages("MicrobiomeStat")

For complete set of functionalities

install.packages("devtools") devtools::install_github("cafferychen777/MicrobiomeStat")

List of packages to install

packages_to_install <- c( "rlang", ....) # I have copied the list of packages as indicated in the installation guide

Installing packages

install.packages(packages_to_install)

Required package

library(microbiome) library(MicrobiomeStat)

Load the dataset

data(peerj32) peerj32.phy <- peerj32$phyloseq

data.obj <- mStat_convert_phyloseq_to_data_obj(peerj32.phy) Error in mStat_convert_phyloseq_to_data_obj(peerj32.phy) : could not find function "mStat_convert_phyloseq_to_data_obj"

I am very sorry for the trivial question and for struggling on the very first step of using MicrobioStat. Hope you can help. Gaëlle

cafferychen777 commented 8 months ago

Dear @QGaelle,

Thank you for your interest in using MicrobiomeStat. I apologize for the error you encountered with the mStat_convert_phyloseq_to_data_obj() function.

It seems there may be an issue importing or finding that function. As a first step, please try running library(phyloseq)before calling mStat_convert_phyloseq_to_data_obj(). Explicitly loading the phyloseq package first may help resolve the issue.

If that does not work, please try re-installing MicrobiomeStat using the latest version from GitHub with:

devtools::install_github("cafferychen777/MicrobiomeStat")

Please let me know if the issue persists after trying those steps. I'm happy to help troubleshoot further so you can start leveraging MicrobiomeStat for your analysis. Apologies again for the inconvenience.

Best regards, Chen YANG

QGaelle commented 8 months ago

Dear Chen Yang, Thanks a lot for your prompt reply and your help. I restarted R, re-installed MicrobiomeStat using the latest version from GitHub and loaded the phyloseq package as you suggested and it worked! I could use the mStat_convert_phyloseq_to_data_obj() function. I can now proceed to the next step of my analyses and will for sure have more questions coming up. Cheers, Gaëlle

J5886 commented 7 months ago

Dear @QGaelle,

Thank you for your interest in using MicrobiomeStat. I apologize for the error you encountered with the mStat_convert_phyloseq_to_data_obj() function.

It seems there may be an issue importing or finding that function. As a first step, please try running library(phyloseq)before calling mStat_convert_phyloseq_to_data_obj(). Explicitly loading the phyloseq package first may help resolve the issue.

If that does not work, please try re-installing MicrobiomeStat using the latest version from GitHub with:

devtools::install_github("cafferychen777/MicrobiomeStat")

Please let me know if the issue persists after trying those steps. I'm happy to help troubleshoot further so you can start leveraging MicrobiomeStat for your analysis. Apologies again for the inconvenience.

Best regards, Chen YANG

Hello @cafferychen777 I'm having the same problem with converting phyloseq to MicrobiomeStat object

I installed the latest version from devtools::install_github("cafferychen777/MicrobiomeStat") library("MicrobiomeStat"); packageVersion("MicrobiomeStat")’ [1] ‘1.1

I followed what you suggested above but still gave me the same error data.obj <- mStat_convert_phyloseq_to_data_obj(physeq2) Error in mStat_convert_phyloseq_to_data_obj(physeq2) : could not find function "mStat_convert_phyloseq_to_data_obj"

any suggestions? Regards!

cafferychen777 commented 7 months ago

Dear @J5886,

Thank you for reaching out and I apologize for the inconvenience you are experiencing. It seems that the installation of the latest version of MicrobiomeStat may not have been successful. The version you mentioned, 1.1, is the one available on CRAN, while the GitHub version should be 1.1.3.

Could you please check if there were any error messages during the installation process after running devtools::install_github("cafferychen777/MicrobiomeStat")? If there were, could you share those error messages with me?

Additionally, to reduce the likelihood of installation issues, you might want to ensure that all dependencies are installed before attempting to install MicrobiomeStat from GitHub. You can do this by running the following code to install the necessary packages:

# List of packages to install
packages_to_install <- c(
  "rlang",
  "tibble",
  "ggplot2",
  "matrixStats",
  "lmerTest",
  "foreach",
  "modeest",
  "dplyr",
  "pheatmap",
  "tidyr",
  "ggh4x",
  "GUniFrac",
  "stringr",
  "rmarkdown",
  "knitr",
  "pander",
  "tinytex",
  "vegan",
  "scales",
  "ape",          # Used only in mStat_convert_phyloseq_to_data_obj and mStat_import_mothur_as_data_obj
  "ggrepel",       # Used only in the linda.plot function
  "parallel",      # Utilized only when setting parallel in linda
  "ggprism",       # Active only when theme.choice is set to “prism”
  "aplot",         # Operates exclusively in generate_beta_ordination_single
  "philentropy",   # Used when dist.name is set to "JS"
  "forcats",       # Comes into play only within barplot and areaplot
  "yaml",          # Employed solely in mStat_import_qiime2_as_data_obj
  "biomformat",    # Used in mStat_import_biom_as_data_obj
  "Biostrings"     # Required for mStat_import_qiime2_as_data_obj and mStat_import_dada2_as_data_obj
)

# Installing packages
install.packages(packages_to_install)

After installing these packages, please try running devtools::install_github("cafferychen777/MicrobiomeStat") again.

I hope this helps, and please let me know if you encounter any further issues.

Best regards, Chen Yang

J5886 commented 7 months ago

data.obj <- mStat_convert_phyloseq_to_data_obj(physeq2) Error in mStat_convert_phyloseq_to_data_obj(physeq2)

Hi @cafferychen777 thanks a lot for your prompt response,

I removed the old version from the R packages folder and then used the devtools::install_github("cafferychen777/MicrobiomeStat")

It worked properly.

Regards!

J5886 commented 3 months ago

Hi @cafferychen777 again I have a problem with generate_taxa_trend_test_long function, the error is because of matrix package as follows:

Fit linear mixed effects models ... Error in fun(i) : task 1 failed - "function 'cholmod_factor_ldetA' not provided by package 'Matrix'"

the code used was test.list <- generate_taxa_trend_test_long( data.obj = data.obj, subject.var = "DONOR", time.var = "TIME", group.var = "TREATMENT", adj.vars = "TREATMENT2", prev.filter = 0, #already filtered abund.filter = 0.001, feature.level = c("Family"), feature.dat.type = c("count") ) I'm using R v 4.3.1 MicrobiomeStat v1.2.0 Matrix v1.6.1.1

any suggestions?

thank you

cafferychen777 commented 3 months ago

Hi @J5886,

Thank you for sharing your issue. Based on the information you provided and the previous solution, I suggest trying the following steps:

  1. First, try updating the Matrix and lme4 packages. Run the following commands in your R console:
install.packages("Matrix")
install.packages("lme4")
  1. If you're using RStudio, make sure to run it with administrator privileges, as regular user permissions may not allow updating packages in the system library.

  2. After updating the packages, restart your R session and try running your code again.

  3. If the problem persists, you might need to check the dependencies of the MicrobiomeStat package. Try reinstalling MicrobiomeStat:

install.packages("MicrobiomeStat")
  1. If the above steps don't resolve the issue, you can try using an older version of the Matrix package:
install.packages("Matrix", version = "1.5-3")

Then restart your R session and try your code again.

I hope these suggestions help you resolve the issue. If the problem continues, further investigation and support may be needed.

Best, Chen

J5886 commented 3 months ago

Hi @cafferychen777

thanks a lot for your reply I did all what you suggested but still have the same error

Regards!

cafferychen777 commented 3 months ago

Dear @J5886,

Thank you for your continued efforts in troubleshooting this issue. I apologize that the problem persists despite following the suggested steps.

Based on the information you've provided, it seems that the main cause of the error is likely related to the Matrix package. In theory, the steps we've outlined should resolve this issue. However, to better assist you, I wonder if you'd be willing to share your dataset with me? This would allow me to replicate the problem and test potential solutions directly.

If you're comfortable sharing your data, please send it to me, and I'll run some tests to identify the root cause of the error. Rest assured, I'll handle your data with the utmost confidentiality.

In the meantime, could you also confirm that you've updated the Matrix package to the latest version? Sometimes, ensuring all dependencies are up-to-date can resolve unexpected conflicts.

Thank you for your patience as we work to resolve this issue. I'm committed to helping you get MicrobiomeStat working smoothly for your analysis.

Best regards, Chen Yang

J5886 commented 3 months ago

Dear @cafferychen777 thanks a lot for your response, Yes, the problem is with the matrix package and I'm sure it's updated to the latest version. I will try the new R version, see if it will solve the issue, and let you know.

I appreciate your help

regards!

J5886 commented 3 months ago

Hi @cafferychen777,

the R was updated to the latest version 4.4.1, and the issue with the matrix was solved. I'm creating the obj after converting from phyloseq object and it works properly with me. But, when trying to create the object with mStat_import_qiime2_as_data_obj an error exists with read biom function Loading feature table... Unzipping the .qza file... Locating the metadata file... Reading the metadata... Processing the file based on its format... Error in read_biom(file) : could not find function "read_biom"

this issue was faced in old and new R versions any suggestion?

Thank you

cafferychen777 commented 3 months ago

Dear J5886,

Thank you for the update on your progress with MicrobiomeStat. I'm glad to hear that updating to R 4.4.1 resolved the Matrix package issue.

Regarding the error you're encountering with the mStat_import_qiime2_as_data_obj function, it seems that the read_biom function is not being found. This function is part of the biomformat package, which may not be loaded or installed.

To resolve this, please try the following steps:

  1. First, ensure that the biomformat package is installed:

    if (!requireNamespace("biomformat", quietly = TRUE)) {
     install.packages("biomformat")
    }
  2. Then, load the package explicitly before using the mStat_import_qiime2_as_data_obj function:

    library(biomformat)
  3. After loading the package, try running your mStat_import_qiime2_as_data_obj function again.

If you're still experiencing issues after these steps, please let me know, and I'll be happy to help you troubleshoot further.

Best regards, Chen Yang

J5886 commented 3 months ago

I'm grateful, @cafferychen777 for your help and response,

that solved the error, but another one was raised `Loading feature table... Unzipping the .qza file... Locating the metadata file... Reading the metadata... Processing the file based on its format... File processed successfully! Loading feature annotations... Unzipping the .qza file... Locating the metadata file... Reading the metadata... Processing the file based on its format... File processed successfully! Loading sample metadata... Loading phylogenetic tree... Unzipping the .qza file... Locating the metadata file... Reading the metadata... Error in file(file, "rt", encoding = fileEncoding) : invalid 'description' argument In addition: Warning messages: 1: In strsplit(conditionMessage(e), "\n") : unable to translate 'lexical error: invalid char in json text.

<89>HDF  (right here) ------^ ' to a wide string 2: In strsplit(conditionMessage(e), "\n") : input string 1 is invalid 3: In utils::unzip(file, exdir = temp) : error 1 in extracting from zip file` anyway it's not important, I'll keep using phyloseq and convert that to the MicrobiomeStat object I appreciate your patience and help once again Kind regards!