cafferychen777 / ggpicrust2

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

pathway_daa(): Error in Math.factor(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, : ‘round’ not meaningful for factors #56

Closed nicharee22 closed 8 months ago

nicharee22 commented 9 months ago

Hello @cafferychen777,

I'm very new to picrust2 and ggpicrust2 is really interesting! I tried to run the pathway_daa() and got the error message:

Error in Math.factor(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, : ‘round’ not meaningful for factors

How can I fix that?

cafferychen777 commented 9 months ago

Hello @nicharee22 ,

Thank you for bringing this to my attention. The error message you received seems to suggest an issue with a factor variable being used in a function that is expecting a numerical variable.

To better assist you, I would need to see an example dataset and the exact code you're using. This will help me reproduce the error on my end and pinpoint the exact cause.

Could you please provide:

  1. A small subset of your input data that reproduces the error.
  2. The exact code or command you ran when encountering the error.

With this information, I can help you find a solution more efficiently.

Best regards, Chen YANG

nicharee22 commented 9 months ago

Appreciate your prompt reply!

I used the example dataset and changed the name a little bit

1.metadata.txt ---> metadata_example.txt 2.pred_metagenome_unstrat.tsv ----> pred_metagenome_unstrat_example.tsv

this is my code:

library(readr) library(ggpicrust2) library(tibble) library(tidyverse) library(ggprism) library(patchwork)

metadata_example <- read_delim("metadata_example.txt", delim = "\t", escape_double = FALSE, trim_ws = TRUE)

kegg_abundance_example <- ko2kegg_abundance("pred_metagenome_unstrat_example.tsv")

daa_results_df_example <- pathway_daa(abundance = kegg_abundance_example, metadata = metadata_example, group = "Environment", daa_method = "ALDEx2", select = NULL, reference = NULL)

and got the error like this: Sample names extracted. Identifying matching columns in metadata... Matching columns identified: sample_name . This is important for ensuring data consistency. Using all columns in abundance. Converting abundance to a matrix... Reordering metadata... Converting metadata to a matrix and data frame... Extracting group information... Running ALDEx2 with two groups. Performing t-test... Error in Math.factor(c(1L, 1L, 1L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, : ‘round’ not meaningful for factors

cafferychen777 commented 9 months ago

Hello @nicharee22,

Thank you for providing detailed information on the issue.

I've taken the time to reproduce the steps you mentioned using the dataset names and the code you provided. Interestingly, I did not encounter the error you've described. The issue you're facing might be due to specific versions of the packages or some other underlying factors on your system.

Here are a few suggestions to resolve the issue:

  1. Reinstall ggpicrust2 and ALDEx2: Sometimes, reinstalling the package can resolve underlying issues. You can do this with:

    remove.packages("ggpicrust2")
    remove.packages("ALDEx2")
    install.packages("ggpicrust2")
    install.packages("ALDEx2")
  2. Check Versions: Ensure that you are using the latest versions of both ggpicrust2 and ALDEx2. If not, please update them. You can check your package versions with packageVersion("ggpicrust2") and packageVersion("ALDEx2").

  3. Session Info: If the issue persists, could you please share the output of sessionInfo()? This provides a snapshot of your current R environment, which can help in diagnosing the problem.

Let me know how these steps work out for you, and I'm here to help further if needed.

Best regards,

Chen YANG

Screenshot 2023-09-18 at 09 52 22
nicharee22 commented 9 months ago

I reinstalled ggpicrust2 and ALDEx2, and they work!

Thank you so much!