Giter Club home page Giter Club logo

Comments (4)

FrederickHuangLin avatar FrederickHuangLin commented on June 15, 2024 1

Hi @stan-iakhno,

The error message means the group variable you specified in the ancombc function contains less than 2 categories or levels.

Suppose your metadata is called meta_data and the group variable is called group, you can check the number of levels it has by executing :

length(unique(meta_data[, group])).

If it turns out to be less than 2, you can consider either using a different group variable or specifying group = NULL in the ancombc function.

Best,

Huang

from ancombc.

stan-iakhno avatar stan-iakhno commented on June 15, 2024

Thanks for your reply @FrederickHuangLin ! I was trying to replicate the issue myself and got a different error.

Error in tapply(present_table[i, ], group_data, function(x) mean(x, na.rm = TRUE)) : 
  arguments must have same length
In addition: Warning message:
In data_prep(phyloseq, group, zero_cut, lib_cut, global = global) :
  The multi-group comparison will be deactivated as the group variable has < 3 categories.

What could go wrong here?

Here is the code I run:

ps.zip

library(dplyr)
library(nloptr)
library(ANCOMBC)

out = ancombc(phyloseq = ps, formula = "diet",
              p_adj_method = "holm", zero_cut = 0.90, lib_cut = 1000,
              group = "diet", struc_zero = TRUE, neg_lb = FALSE,
              tol = 1e-5, max_iter = 100, conserve = TRUE,
              alpha = 0.05, global = TRUE)

KR. Stan

from ancombc.

FrederickHuangLin avatar FrederickHuangLin commented on June 15, 2024

Hi @stan-iakhno,

You caught a BUG! It turns out the ANCOMBC algirithm assumes that rownames are taxa names by default. The following codes should work:

otu_mat = as(otu_table(ps), "matrix")
meta = as(sample_data(ps), "data.frame")
tax_mat = as(tax_table(ps), "matrix")
OTU = otu_table(t(otu_mat), taxa_are_rows = TRUE)
META = sample_data(meta)
TAX = tax_table(tax_mat)
ps2 = phyloseq(OTU, META, TAX)
out = ancombc(phyloseq = ps2, formula = "diet",
              p_adj_method = "holm", zero_cut = 0.90, lib_cut = 1000,
              group = "diet", struc_zero = TRUE, neg_lb = FALSE,
              tol = 1e-5, max_iter = 100, conserve = TRUE,
              alpha = 0.05, global = TRUE)

Again, thanks for catching this and I will update the package accordingly.

Best,

Huang

from ancombc.

stan-iakhno avatar stan-iakhno commented on June 15, 2024

Hi @FrederickHuangLin,

It is a pleasure! Thanks for a very nice piece of scientific work!

Best. Stanislav

from ancombc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.