statdivlab / corncob

Count Regression for Correlated Observations with the Beta-binomial
102 stars 22 forks source link

glance_significant_models Error #175

Closed mlkleinbest closed 4 months ago

mlkleinbest commented 4 months ago

Hi there,

I've been running code off of the vignette simply substituting in my own phyloseq object.

I have a treatment * day model for the effect of a supplement over time:

phyloseq-class experiment-level object otu_table() OTU Table: [ 1281 taxa and 96 samples ] sample_data() Sample Data: [ 96 samples by 25 sample variables ] tax_table() Taxonomy Table: [ 1281 taxa by 7 taxonomic ranks ] phy_tree() Phylogenetic Tree: [ 1281 tips and 1280 internal nodes ] refseq() DNAStringSet: [ 1281 reference sequences ]

The following code delivers a relative abundance plot diffdata <- data %>% phyloseq::tax_glom("Genus")

ex6 <- differentialTest(formula = ~ TreatmentDay, phi.formula = ~ Treatment Day , formula_null = ~ 1, phi.formula_null = ~ Day, data = diffdata, test = "Wald", boot = FALSE, fdr_cutoff = 0.05) plot(ex6)

However, I cannot extract the data into a table.

Running this code returns an error: glance_significant_models(ex6) %>% filter(fdr < 0.1) %>% filter(!grepl("Intercept", covariate)) %>% left_join(physeq_genus_tax_table)

Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'left_join': unused arguments (covariate, estimate, std_error, t_value, fdr = pr_t, taxa_name)

Any input would be greatly appreciated!

svteichman commented 4 months ago

Hi @mlkleinbest

When did you install corncob? And which vignette are you running off of? It seems that you might be using an outdated version of the package and vignette (for example, corncob currently doesn't have a function called glance_significant_models()), and I'm not sure if that was something that existed in a past release).

This seems to be a problem with connecting the output of the model to the phyloseq taxon table, which is slightly out of the scope for us to address in terms of corncob issues. However, from your error message, it looks like there are perhaps no shared variables between glance_significant_models(ex6) (I'm not familiar with this function so I don't know what it outputs) and physeq_genus_tax_table to join on. I'd check to see if your taxa_name from ex6 matches any of the columns in your physeq_genus_tax_table.

Best, Sarah

mlkleinbest commented 4 months ago

Hi Sarah,

Ah yep I wasn't in the vignette, it was code from this post:

"From raw metagenome reads to taxonomic differential abundance with sourmash and corncob" reference: https://taylorreiter.github.io/2022-08-29-From-raw-metagenome-reads-to-taxonomic-differential-abundance-with-sourmash-and-corncob/

Do you know, is there a simple way to extract the figure info into a table?

Best, Matt

svteichman commented 4 months ago

Hi Matt,

We don't have a specific function to extract the figure info into a table (if you wanted you could look at the code inside plot_differentialTest and adapt that as you need), but it seems that Taylor has come up with a great way to do it in her post with the glimpse_significant_models function.

I'd suggest that to debug what is going wrong with that, check out the variable taxa_name from glance_significant_models(ex6) %>% filter(fdr < 0.1) %>% filter(!grepl("Intercept", covariate)) and then check manually whether there is a matching variable in physeq_genus_tax_table, and if not figure out how to add that in order to do the left_join.

For now I'm going to close this issue because it relates to code not written or maintained by the StatDivLab, but feel free to re-open if you have other questions about functions within corncob.

Best, Sarah