cafferychen777 / ggpicrust2

Make Picrust2 Output Analysis and Visualization Easier
https://cafferychen777.github.io/ggpicrust2/
Other
91 stars 11 forks source link

error with MicrobiomeStat #100

Open saassli21 opened 3 months ago

saassli21 commented 3 months ago

**Hello,

Thank you for you interactivity in advance I've been using the same script since December 2023, and I've tested it on my dataset. However, after changing my PC and reinstalling the various packages, I encountered an error that appears to be related to MicrobiomeStat ( not sure). It's worth noting that I'm still utilizing the same dataset as before.**

Warning message: In MicrobiomeStat::linda(abundance, LinDA_metadata_df, formula = "~Group_groupnonsense", : Some features have less than 3 nonzero values! They have virtually no statistical power. You may consider filtering them in the analysis!

We are connecting to the KEGG database to get the latest results, please wait patiently. The following pathways are missing annotations and have been excluded: ko00072 You can use the 'pathway_annotation' function to add annotations for these pathways. Registered S3 method overwritten by 'GGally': method from
+.gg ggplot2 The Sample Names in order from left to right are: SRR8351974_pass_R1.fastq.gz, SRR8351976_pass_R1.fastq.gz, SRR8351980_pass_R1.fastq.gz, SRR8351983_pass_R1.fastq.gz, SRR8351985_pass_R1.fastq.gz, SRR8351987_pass_R1.fastq.gz, SRR8351988_pass_R1.fastq.gz, SRR8351990_pass_R1.fastq.gz, SRR8351991_pass_R1.fastq.gz, SRR8351992_pass_R1.fastq.gz, SRR8351994_pass_R1.fastq.gz, SRR8351995_pass_R1.fastq.gz, SRR8351996_pass_R1.fastq.gz, SRR8351997_pass_R1.fastq.gz, SRR8351998_pass_R1.fastq.gz, SRR8351999_pass_R1.fastq.gz, SRR8352000_pass_R1.fastq.gz, SRR8352001_pass_R1.fastq.gz, SRR8352002_pass_R1.fastq.gz, SRR8352003_pass_R1.fastq.gz, SRR8352005_pass_R1.fastq.gz, SRR8352009_pass_R1.fastq.gz, SRR8352010_pass_R1.fastq.gz, SRR8352012_pass_R1.fastq.gz, SRR8352013_pass_R1.fastq.gz, SRR8352015_pass_R1.fastq.gz, SRR8352021_pass_R1.fastq.gz, SRR8352022_pass_R1.fastq.gz, SRR8352023_pass_R1.fastq.gz, SRR8352024_pass_R1.fastq.gz, SRR8352026_pass_R1.fastq.gz, SRR8352028_pass_R1.fastq.gz, SRR8352029_pass_R1.fastq.gz, SRR8352030_pass_R1.fastq.gz, SRR8352032_pass_R1.fastq.gz, SRR8352033_pass_R1.fastq.gz, SRR8352035_pass_R1.fastq.gz, SRR8352037_pass_R1.fastq.gz, SRR8352041_pass_R1.fastq.gz, SRR8352045_pass_R1.fastq.gz, SRR8352046_pass_R1.fastq.gz, SRR8352053_pass_R1.fastq.gz, SRR8352056_pass_R1.fastq.gz, SRR8352058_pass_R1.fastq.gz, SRR8352059_pass_R1.fastq.gz, SRR8352060_pass_R1.fastq.gz, SRR8352064_pass_R1.fastq.gz, SRR8352066_pass_R1.fastq.gz, SRR8352068_pass_R1.fastq.gz, SRR8352070_pass_R1.fastq.gz, SRR8352073_pass_R1.fastq.gz, SRR8352075_pass_R1.fastq.gz, SRR8352078_pass_R1.fastq.gz, SRR8352080_pass_R1.fastq.gz, SRR8352082_pass_R1.fastq.gz, SRR8352085_pass_R1.fastq.gz, SRR8352087_pass_R1.fastq.gz, SRR8352089_pass_R1.fastq.gz, SRR8352092_pass_R1.fastq.gz, SRR8352094_pass_R1.fastq.gz, SRR8352097_pass_R1.fastq.gz, SRR8352099_pass_R1.fastq.gz, SRR8352106_pass_R1.fastq.gz, SRR8352107_pass_R1.fastq.gz, SRR8352109_pass_R1.fastq.gz, SRR8352110_pass_R1.fastq.gz, SRR8352112_pass_R1.fastq.gz, SRR8352115_pass_R1.fastq.gz, SRR8352117_pass_R1.fastq.gz, SRR8352119_pass_R1.fastq.gz, SRR8352121_pass_R1.fastq.gz, SRR8352122_pass_R1.fastq.gz, SRR8351975_pass_R1.fastq.gz, SRR8351977_pass_R1.fastq.gz, SRR8351978_pass_R1.fastq.gz, SRR8351979_pass_R1.fastq.gz, SRR8351981_pass_R1.fastq.gz, SRR8351982_pass_R1.fastq.gz, SRR8351984_pass_R1.fastq.gz, SRR8351986_pass_R1.fastq.gz, SRR8351989_pass_R1.fastq.gz, SRR8351993_pass_R1.fastq.gz, SRR8352004_pass_R1.fastq.gz, SRR8352006_pass_R1.fastq.gz, SRR8352007_pass_R1.fastq.gz, SRR8352008_pass_R1.fastq.gz, SRR8352011_pass_R1.fastq.gz, SRR8352014_pass_R1.fastq.gz, SRR8352016_pass_R1.fastq.gz, SRR8352017_pass_R1.fastq.gz, SRR8352018_pass_R1.fastq.gz, SRR8352019_pass_R1.fastq.gz, SRR8352020_pass_R1.fastq.gz, SRR8352025_pass_R1.fastq.gz, SRR8352027_pass_R1.fastq.gz, SRR8352031_pass_R1.fastq.gz, SRR8352034_pass_R1.fastq.gz, SRR8352036_pass_R1.fastq.gz, SRR8352038_pass_R1.fastq.gz, SRR8352039_pass_R1.fastq.gz, SRR8352040_pass_R1.fastq.gz, SRR8352042_pass_R1.fastq.gz, SRR8352043_pass_R1.fastq.gz, SRR8352044_pass_R1.fastq.gz, SRR8352047_pass_R1.fastq.gz, SRR8352048_pass_R1.fastq.gz, SRR8352049_pass_R1.fastq.gz, SRR8352050_pass_R1.fastq.gz, SRR8352051_pass_R1.fastq.gz, SRR8352052_pass_R1.fastq.gz, SRR8352054_pass_R1.fastq.gz, SRR8352055_pass_R1.fastq.gz, SRR8352057_pass_R1.fastq.gz, SRR8352061_pass_R1.fastq.gz, SRR8352062_pass_R1.fastq.gz, SRR8352063_pass_R1.fastq.gz, SRR8352065_pass_R1.fastq.gz, SRR8352067_pass_R1.fastq.gz, SRR8352069_pass_R1.fastq.gz, SRR8352071_pass_R1.fastq.gz, SRR8352072_pass_R1.fastq.gz, SRR8352074_pass_R1.fastq.gz, SRR8352076_pass_R1.fastq.gz, SRR8352077_pass_R1.fastq.gz, SRR8352079_pass_R1.fastq.gz, SRR8352081_pass_R1.fastq.gz, SRR8352083_pass_R1.fastq.gz, SRR8352084_pass_R1.fastq.gz, SRR8352086_pass_R1.fastq.gz, SRR8352088_pass_R1.fastq.gz, SRR8352090_pass_R1.fastq.gz, SRR8352091_pass_R1.fastq.gz, SRR8352093_pass_R1.fastq.gz, SRR8352095_pass_R1.fastq.gz, SRR8352096_pass_R1.fastq.gz, SRR8352098_pass_R1.fastq.gz, SRR8352100_pass_R1.fastq.gz, SRR8352101_pass_R1.fastq.gz, SRR8352102_pass_R1.fastq.gz, SRR8352103_pass_R1.fastq.gz, SRR8352104_pass_R1.fastq.gz, SRR8352105_pass_R1.fastq.gz, SRR8352108_pass_R1.fastq.gz, SRR8352111_pass_R1.fastq.gz, SRR8352113_pass_R1.fastq.gz, SRR8352114_pass_R1.fastq.gz, SRR8352116_pass_R1.fastq.gz, SRR8352118_pass_R1.fastq.gz, SRR8352120_pass_R1.fastq.gz, SRR8352123_pass_R1.fastq.gz, SRR8352124_pass_R1.fastq.gz, SRR8352125_pass_R1.fastq.gz The Group Levels in order from left to right are: HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, HC, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD, PD Error in plot_theme(): ! The legend.text.align theme element is not defined in the element hierarchy. Backtrace: ▆

  1. └─ggplot2::ggsave(...)
  2. ├─... %||% "transparent"
  3. ├─ggplot2::calc_element("plot.background", plot_theme(plot))
  4. └─ggplot2:::plot_theme(plot)
  5. └─ggplot2:::validate_theme(theme)
  6. └─base::mapply(...)
  7. └─ggplot2 (local) <fn>(...)
  8. └─cli::cli_abort(...)
  9. └─rlang::abort(...) Execution halted

I'm wondering you have update the MicrobiomeStat package recently ? I'm installing MicrobiomStat using this command : if (!"MicrobiomeStat" %in% installed.packages()) { devtools::install_github("cafferychen777/MicrobiomeStat" , ref="MicrobiomeStat_Version_1.1.2") #version 1.1.2 }

cafferychen777 commented 3 months ago

Hi @saassli21,

Thank you for reporting this issue. It appears that the error is being caused by a recent update to the ggplot2 package, rather than an issue with MicrobiomeStat. Downgrading ggplot2 to version 3.4 should resolve the problem.

To downgrade:

install.packages("ggplot2", version = "3.4.0")

Please let me know if downgrading ggplot2 fixes the errors you are seeing. If not, feel free to provide some more details and we can troubleshoot further. But my suspicion is that the latest ggplot2 update introduced some breaking changes that are causing conflicts.

I appreciate you taking the time to report this - it helps me improve the package. Let me know if you have any other questions!

saassli21 commented 3 months ago

Hi @saassli21,

Thank you for reporting this issue. It appears that the error is being caused by a recent update to the ggplot2 package, rather than an issue with MicrobiomeStat. Downgrading ggplot2 to version 3.4 should resolve the problem.

To downgrade:

install.packages("ggplot2", version = "3.4.0")

Please let me know if downgrading ggplot2 fixes the errors you are seeing. If not, feel free to provide some more details and we can troubleshoot further. But my suspicion is that the latest ggplot2 update introduced some breaking changes that are causing conflicts.

I appreciate you taking the time to report this - it helps me improve the package. Let me know if you have any other questions!

thank you for responding

what I did first is installing bioconductor envirment using this yml file : name: my_bioconductor_env channels:

Load required libraries

library(readr) library(tibble) library(tidyverse) library(ggprism) library(patchwork) library(KEGGREST) library(ggh4x) library(plotly) library(R.utils)

Check if 'dplyr' package is installed, and install if not

if (!"dplyr" %in% installed.packages()) { devtools::install_github("tidyverse/dplyr/" , ref="dplyr 1.1.3") #version 1.1.3 }

library(dplyr)

Check if 'ggplot2' package is installed, and install if not

if (!"ggplot2" %in% installed.packages()) { devtools::install_github("tidyverse/ggplot2/" , ref="ggplot2 3.4.4") #version 3.4.4 }

library(ggplot2)

Check if 'MicrobiomeStat' package is installed, and install if not

if (!"MicrobiomeStat" %in% installed.packages()) { devtools::install_github("cafferychen777/MicrobiomeStat" , ref="MicrobiomeStat_Version_1.1.2") #version 1.1.2 }

library(MicrobiomeStat)

Check if 'ggpicrust2' package is installed, and install if not

if (!"ggpicrust2" %in% installed.packages()) { devtools::install_github('cafferychen777/ggpicrust2' , ref = 'ggpicrust2_1.7.1.tgz') #version 1.7.1 }

library(ggpicrust2)

print("START") print(sessionInfo()) print("end")

the output of this script

── Attaching core tidyverse packages ────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ── ✔ dplyr 1.1.4 ✔ purrr 1.0.2 ✔ forcats 1.0.0 ✔ stringr 1.5.1 ✔ ggplot2 3.5.0 ✔ tidyr 1.3.1 ✔ lubridate 1.9.3
── Conflicts ──────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag() ℹ Use the conflicted package (http://conflicted.r-lib.org/) to force all conflicts to become errors

Attaching package: ‘ggh4x’

The following object is masked from ‘package:ggplot2’:

guide_axis_logticks

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

last_plot

The following object is masked from ‘package:stats’:

filter

The following object is masked from ‘package:graphics’:

layout

Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.

Attaching package: ‘R.oo’

The following object is masked from ‘package:R.methodsS3’:

throw

The following objects are masked from ‘package:methods’:

getClasses, getMethods

The following objects are masked from ‘package:base’:

attach, detach, load, save

R.utils v2.12.2 (2022-11-11 22:00:03 UTC) successfully loaded. See ?R.utils for help.

Attaching package: ‘R.utils’

The following object is masked from ‘package:tidyr’:

extract

The following object is masked from ‘package:utils’:

timestamp

The following objects are masked from ‘package:base’:

cat, commandArgs, getOption, isOpen, nullfile, parse, warnings

Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages -> startsWith -> contrib.url Execution halted

as you can see the ggplot2 version installed is 3.5.0 not 3.4.4 :/ The versions that I'm mentioning are the ones that I'm used to using before encountering this new issue.

saassli21 commented 3 months ago

Hi @saassli21, Thank you for reporting this issue. It appears that the error is being caused by a recent update to the ggplot2 package, rather than an issue with MicrobiomeStat. Downgrading ggplot2 to version 3.4 should resolve the problem. To downgrade: install.packages("ggplot2", version = "3.4.0") Please let me know if downgrading ggplot2 fixes the errors you are seeing. If not, feel free to provide some more details and we can troubleshoot further. But my suspicion is that the latest ggplot2 update introduced some breaking changes that are causing conflicts. I appreciate you taking the time to report this - it helps me improve the package. Let me know if you have any other questions!

thank you for responding

what I did first is installing bioconductor envirment using this yml file : name: my_bioconductor_env channels:

  • conda-forge
  • bioconda dependencies:
  • r-base==4.3.2 #111
  • r-tidyverse==2.0.0
  • r-readr==2.1.4
  • r-tibble==3.2.1
  • r-ggprism==1.0.4
  • r-patchwork==1.1.3 # not the same 1.2.0
  • r-ggh4x==0.2.6 # not the same 0.2.8
  • r-devtools==2.4.5 # absent
  • r-biocmanager==1.30.22 #absent
  • r-lme4==1.1_35.1 # same
  • r-lmerTest==3.1_3 # absent
  • r-nloptr==2.0.3 #
  • r-rversions==2.1.2
  • r-roxygen2==7.2.3
  • r-pkgdown==2.0.7
  • r-urlchecker==1.0.1
  • r-r.utils==2.12.2
  • bioconductor-phyloseq==1.44.0
  • bioconductor-summarizedexperiment==1.30.2
  • bioconductor-biobase==2.60.0
  • bioconductor-complexheatmap==2.16.0
  • bioconductor-biocgenerics==0.46.0
  • bioconductor-aldex2==1.32.0
  • bioconductor-metagenomeseq==1.42.0
  • bioconductor-maaslin2==1.14.1
  • bioconductor-edger==3.42.4
  • bioconductor-lefser==1.10.0
  • bioconductor-limma==3.56.2
  • bioconductor-keggrest==1.40.0
  • bioconductor-deseq2==1.40.2
  • r-remotes==2.4.2.1
  • r-plotly==4.10.3 after that I runned this R script :

Load required libraries

library(readr) library(tibble) library(tidyverse) library(ggprism) library(patchwork) library(KEGGREST) library(ggh4x) library(plotly) library(R.utils)

Check if 'dplyr' package is installed, and install if not

if (!"dplyr" %in% installed.packages()) { devtools::install_github("tidyverse/dplyr/" , ref="dplyr 1.1.3") #version 1.1.3 }

library(dplyr)

Check if 'ggplot2' package is installed, and install if not

if (!"ggplot2" %in% installed.packages()) { devtools::install_github("tidyverse/ggplot2/" , ref="ggplot2 3.4.4") #version 3.4.4 }

library(ggplot2)

Check if 'MicrobiomeStat' package is installed, and install if not

if (!"MicrobiomeStat" %in% installed.packages()) { devtools::install_github("cafferychen777/MicrobiomeStat" , ref="MicrobiomeStat_Version_1.1.2") #version 1.1.2 }

library(MicrobiomeStat)

Check if 'ggpicrust2' package is installed, and install if not

if (!"ggpicrust2" %in% installed.packages()) { devtools::install_github('cafferychen777/ggpicrust2' , ref = 'ggpicrust2_1.7.1.tgz') #version 1.7.1 }

library(ggpicrust2)

print("START") print(sessionInfo()) print("end")

the output of this script

── Attaching core tidyverse packages ────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ── ✔ dplyr 1.1.4 ✔ purrr 1.0.2 ✔ forcats 1.0.0 ✔ stringr 1.5.1 ✔ ggplot2 3.5.0 ✔ tidyr 1.3.1 ✔ lubridate 1.9.3 ── Conflicts ──────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ── ✖ dplyr::filter() masks stats::filter() ✖ dplyr::lag() masks stats::lag() ℹ Use the conflicted package (http://conflicted.r-lib.org/) to force all conflicts to become errors

Attaching package: ‘ggh4x’

The following object is masked from ‘package:ggplot2’:

guide_axis_logticks

Attaching package: ‘plotly’

The following object is masked from ‘package:ggplot2’:

last_plot

The following object is masked from ‘package:stats’:

filter

The following object is masked from ‘package:graphics’:

layout

Loading required package: R.oo Loading required package: R.methodsS3 R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help. R.oo v1.26.0 (2024-01-24 05:12:50 UTC) successfully loaded. See ?R.oo for help.

Attaching package: ‘R.oo’

The following object is masked from ‘package:R.methodsS3’:

throw

The following objects are masked from ‘package:methods’:

getClasses, getMethods

The following objects are masked from ‘package:base’:

attach, detach, load, save

R.utils v2.12.2 (2022-11-11 22:00:03 UTC) successfully loaded. See ?R.utils for help.

Attaching package: ‘R.utils’

The following object is masked from ‘package:tidyr’:

extract

The following object is masked from ‘package:utils’:

timestamp

The following objects are masked from ‘package:base’:

cat, commandArgs, getOption, isOpen, nullfile, parse, warnings

Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages -> startsWith -> contrib.url Execution halted

as you can see the ggplot2 version installed is 3.5.0 not 3.4.4 :/ The versions that I'm mentioning are the ones that I'm used to using before encountering this new issue.

@cafferychen777 , could you please help me with this !!

cafferychen777 commented 3 months ago

Hello @saassli21,

Thank you for sharing the details of your environment setup. It looks like you're using a Conda environment for your R packages. To ensure that ggplot2 version 3.4.0 is installed in your Conda environment, you can modify your environment YAML file to specify the ggplot2 version. Here's how you can do it:

  1. Open your my_bioconductor_env.yml file and update the r-tidyverse and r-ggplot2 dependencies to specify the versions you need:

    dependencies:
     - r-base==4.3.2
     - r-tidyverse==2.0.0
     - r-ggplot2==3.4.0
     ...
  2. After saving the changes, update your Conda environment using the following command:

    conda env update --file my_bioconductor_env.yml
  3. Activate your Conda environment:

    conda activate my_bioconductor_env
  4. Verify that the correct version of ggplot2 is installed:

    library(ggplot2)
    packageVersion("ggplot2")

This should ensure that ggplot2 version 3.4.0 is installed in your Conda environment. If you encounter any issues with this process, please let me know, and we can explore further solutions.

saassli21 commented 3 months ago

Hello @saassli21,

Thank you for sharing the details of your environment setup. It looks like you're using a Conda environment for your R packages. To ensure that ggplot2 version 3.4.0 is installed in your Conda environment, you can modify your environment YAML file to specify the ggplot2 version. Here's how you can do it:

  1. Open your my_bioconductor_env.yml file and update the r-tidyverse and r-ggplot2 dependencies to specify the versions you need:
    dependencies:
     - r-base==4.3.2
     - r-tidyverse==2.0.0
     - r-ggplot2==3.4.0
     ...
  2. After saving the changes, update your Conda environment using the following command:
    conda env update --file my_bioconductor_env.yml
  3. Activate your Conda environment:
    conda activate my_bioconductor_env
  4. Verify that the correct version of ggplot2 is installed:
    library(ggplot2)
    packageVersion("ggplot2")

This should ensure that ggplot2 version 3.4.0 is installed in your Conda environment. If you encounter any issues with this process, please let me know, and we can explore further solutions.

Thank you very much. It does change my ggplot2 version in the conda environment. However, once I call the other packages, the ggplot2 version becomes 3.5.0. So, here is what I did:

Load required libraries

library(tibble) library(tidyverse) library(ggprism) library(patchwork) library(KEGGREST) library(ggh4x) library(dplyr) library(plotly) library(R.utils)

Check if 'MicrobiomeStat' package is installed, and install if not

if (!"MicrobiomeStat" %in% installed.packages()) { devtools::install_github("cafferychen777/MicrobiomeStat" , ref="MicrobiomeStat_Version_1.1.2") #version 1.1.2 } library(MicrobiomeStat)

Check if 'ggpicrust2' package is installed, and install if not

if (!"ggpicrust2" %in% installed.packages()) { devtools::install_github('cafferychen777/ggpicrust2' , ref = 'ggpicrust2_1.7.1.tgz') #version 1.7.1 } library(ggpicrust2)

library(remotes)

Specify the repository URL containing the package version you want

Replace 'repo_url' with the URL of the repository

repo_url <- "https://cran.r-project.org/src/contrib/Archive/ggplot2/ggplot2_3.4.4.tar.gz"

Install the desired package version from the specified repository

install_url(repo_url) library(ggplot2)

if (!requireNamespace("remotes", quietly = TRUE)) { install.packages("remotes") } remotes::install_cran("readr") library(readr)