cafferychen777 / ggpicrust2

Make Picrust2 Output Analysis and Visualization Easier
https://cafferychen777.github.io/ggpicrust2/
MIT License
109 stars 13 forks source link

All my pathway results are NA #122

Open weiGu-88 opened 1 week ago

weiGu-88 commented 1 week ago

Hi, First of all, thanks for creating this tool.I encountered the same issue as #106.Could you please provide a code modification strategy? Thank you for your response.

weiGu-88 commented 1 week ago

Could you please explain the reason behind the error 'Error in aldex.clr.function(reads, conds, mc.samples, denom, verbose, : rownames(reads) cannot be empty' and suggest how to modify the code to resolve it?

cafferychen777 commented 1 day ago

Hi @weiGu-88,

Thank you for reporting this issue. The error Error in aldex.clr.function(reads, conds, mc.samples, denom, verbose): rownames(reads) cannot be empty typically occurs due to a few common reasons:

  1. Data Format Issues
    
    # Check your data structure first
    print(head(kegg_abundance))
    print(dim(kegg_abundance))
    print(head(rownames(kegg_abundance)))

Ensure proper row names

if (is.null(rownames(kegg_abundance))) {

If your first column contains pathway IDs

kegg_abundance <- kegg_abundance %>% column_to_rownames("pathway") # or whatever your pathway ID column is named }


2. **Data Transformation Fix**
```R
# Make sure your abundance data is properly formatted
kegg_abundance <- as.data.frame(kegg_abundance)

# Remove any rows with all zeros
kegg_abundance <- kegg_abundance[rowSums(kegg_abundance) > 0, ]

# Ensure numeric values
kegg_abundance <- mutate_all(kegg_abundance, as.numeric)
  1. Complete Working Example
    
    library(tidyverse)
    library(ggpicrust2)

Load and prepare data

kegg_abundance <- ko2kegg_abundance("your_file.tsv")

Verify data structure

stopifnot(!is.null(rownames(kegg_abundance))) stopifnot(nrow(kegg_abundance) > 0)

Perform pathway analysis

daa_results_df <- pathway_daa( abundance = kegg_abundance, metadata = metadata, group = "group", daa_method = "ALDEx2", select = NULL, reference = NULL )



**Additional Troubleshooting Tips:**
1. Make sure your abundance data contains no negative values
2. Verify that your metadata group column matches exactly with your sample names
3. Consider using `print(str(kegg_abundance))` to inspect the data structure

If you could share a small sample of your data (first few rows/columns), I can provide more specific guidance.

Best regards,
Chen Yang