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

Creating pathway error bar plots... Error in $<-.data.frame(*tmp*, "group", value = c(2L, 1L, 2L, 2L, : replacement has 179 rows, data has 1 In addition: Warning message: In cbind(sample = colnames(sub_relative_abundance_mat), group = Group, : number of rows of result is not a multiple of vector length (arg 2) #129

Open
Liviacmg opened this issue Nov 28, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@Liviacmg
Copy link

Hey guys,

I am facing this error, does anyone know what can it be?

Creating pathway error bar plots...

Error in $<-.data.frame(*tmp*, "group", value = c(2L, 1L, 2L, 2L, :
replacement has 179 rows, data has 1
In addition: Warning message:
In cbind(sample = colnames(sub_relative_abundance_mat), group = Group, :
number of rows of result is not a multiple of vector length (arg 2)

@Liviacmg Liviacmg added the bug Something isn't working label Nov 28, 2024
@jveix
Copy link

jveix commented Dec 4, 2024

Hi, I had the same error. In fact, it's a bug. In my case it seems to happen when I have only one significant feature (p_adjust < threshold). My workaround was to look for that feature (daa_results_df %>% filter(p_adjust < 0.05) %>% select(c("feature","p_adjust")), as suggested in the package), set the p threshold to something like 0.5 and manually select the significant feature and other random feature, as the code needs two features to create the plot.

@Liviacmg
Copy link
Author

Liviacmg commented Dec 5, 2024

Hi, I had the same error. In fact, it's a bug. In my case it seems to happen when I have only one significant feature (p_adjust < threshold). My workaround was to look for that feature (daa_results_df %>% filter(p_adjust < 0.05) %>% select(c("feature","p_adjust")), as suggested in the package), set the p threshold to something like 0.5 and manually select the significant feature and other random feature, as the code needs two features to create the plot.

Thank you!!

@cafferychen777
Copy link
Owner

Hi @Liviacmg,
Thank you for reporting this issue. The error you're encountering in the pathway_errorbar function typically occurs when there's a mismatch between your abundance data samples and the Group vector length. This usually happens in two scenarios:

  1. Only one significant feature exists (p_adjust < threshold)
  2. Sample mismatch between abundance data and group assignments

Here are the detailed solutions:

  1. For single significant feature cases:

# Option 1: Increase p-value threshold
p <- pathway_errorbar(
  abundance = kegg_abundance,
  daa_results_df = daa_results_df,
  Group = metadata$Diagnosis,
  p_values_threshold = 0.1,  # Higher threshold to include more features
  ko_to_kegg = TRUE
)

# Option 2: Manually select multiple features
significant_features <- daa_results_df %>% 
  arrange(p_adjust) %>% 
  slice(1:2) %>%  # Get top 2 features
  pull(feature)

p <- pathway_errorbar(
  abundance = kegg_abundance,
  daa_results_df = daa_results_df,
  Group = metadata$Diagnosis,
  select = significant_features,
  ko_to_kegg = TRUE
)
  1. For sample mismatch cases:

# Verify sample matching
print("Abundance samples:")
print(colnames(kegg_abundance))
print("Group assignments:")
print(metadata$Diagnosis)

# Ensure sample order consistency
matching_samples <- intersect(colnames(kegg_abundance), metadata$SampleID)
kegg_abundance <- kegg_abundance[, matching_samples]
metadata <- metadata[match(matching_samples, metadata$SampleID), ]

Please let me know if you need any clarification or encounter other issues!

Best regards,
Chen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants