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

Error in switch(file_format, .txt = abundance <- readr::read_delim(file, : EXPR must be a length 1 vector** #112

Open
bplet01 opened this issue Aug 8, 2024 · 2 comments

Comments

@bplet01
Copy link

bplet01 commented Aug 8, 2024

I am trying to run ggpicrust2, and am having an issue. Below is the script I'm running:
 

Load necessary data: abundance data and metadata

KO_abundance_file <- read_delim("pred_metagenome_unstrat.tsv",
delim = "\t",
escape_double = FALSE,
trim_ws = TRUE)

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

Run ggpicrust2 with input file path

KO_results_file_input <- ggpicrust2(file = KO_abundance_file,
metadata = metadata,
group = "Treatment",
pathway = "KO",
daa_method = "ALDEx2",
ko_to_kegg = TRUE,
p.adjust = "fdr",
order = "pathway_class",
p_values_bar = TRUE,
x_lab = "pathway_name")

When I start the analysis, I receive the below error message:

Starting the ggpicrust2 analysis...

Converting KO to KEGG...

Loading data from file...
Error in switch(file_format, .txt = abundance <- readr::read_delim(file, :
EXPR must be a length 1 vector

Any suggestions on how to resolve this?

Thanks!

@Salineraptor
Copy link

Also stuck here...

@cafferychen777
Copy link
Owner

Dear @bplet01 and @Salineraptor,

Thank you for bringing this issue to our attention. I apologize for any confusion this may have caused. I believe I can help clarify the problem you're encountering.

The error you're seeing is likely due to how you're passing the data into the ggpicrust2 function. I notice that you've already read the data using read_delim before calling ggpicrust2. In this case, you should use the data parameter instead of the file parameter.

Here's how you can modify your code:

# Your existing code to read the file
KO_abundance_file <- read_delim("pred_metagenome_unstrat.tsv", delim = "\t", escape_double = FALSE, trim_ws = TRUE)
metadata <- read_delim("Metadata.txt", delim = "\t", escape_double = FALSE, trim_ws = TRUE)

# Modified ggpicrust2 call
KO_results_file_input <- ggpicrust2(data = KO_abundance_file, metadata = metadata, group = "Treatment", pathway = "KO", daa_method = "ALDEx2", ko_to_kegg = TRUE, p.adjust = "fdr", order = "pathway_class", p_values_bar = TRUE, x_lab = "pathway_name")

The key change here is replacing file = KO_abundance_file with data = KO_abundance_file. The file parameter is used when you want ggpicrust2 to read the file directly, while the data parameter is used when you're passing an already-read data frame.

Please try this modification and let me know if it resolves the issue. If you encounter any further problems, don't hesitate to reach out.

Best regards,
Chen Yang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants