statdivlab / enviromtx

A package to analyze environmental metatranscriptomics data
Other
1 stars 1 forks source link

raoBust::gee_test and enviromtx::fit_mgx_model not playing nice #5

Closed adw96 closed 6 months ago

adw96 commented 8 months ago

I am struggling to solve the following issue and would love the help of @svteichman 🙏

The high level goal is I am trying to add a GEE fitting procedure to allow for correlation due to technical replicates.

The challenge is that I am having trouble getting enviromtx and raoBust to work together. When enviromtx::fit_mgx_model calls raoBust::gee_test, it can't seem to find the relevant formulas and datasets. It needs to find the relevant datasets so it can add in id (which denotes the technical replicates) as well as to add in GEE details.

raoBust::gee_test appears to work fine on its own (ie outside of enviromtx). See raoBust's test-replicates for some examples.

@svteichman could you please help me get fit_mgx_model with argument replicates up and running? Here's an example of a script that keeps resulting in errors for me 😿

install.packages("/Users/adwillis/software/raoBust_0.0.2.1.tar.gz", repos = NULL, type = "source")

library(devtools)
library(enviromtx)
library(raoBust)
devtools::install()
n <- 20
xx1 <- rpois(n, lambda=100)
xstar1 <- rpois(n, lambda=20)
beta0 <- 1
beta1 <- -4
reps <- rep(1:4, each = 5)

yy1 <- rpois(n, xx1 * beta0 * (xstar1/xx1)^beta1)
yy1
# 
load_all()
fit_mgx_model(yy = yy1,
              xstar = xstar1,
              xx = xx1,
              replace_zeros=1) ## works fine
# 
fit_mgx_model(yy = yy1,
              xstar = xstar1,
              xx = xx1,
              replicates = reps,
              replace_zeros=1) ### does not work

Just FYI, part of the reason I am fussing around with reordering is that geeglm needs all same-id variables to be contiguous in the dataset. Why they don't just reorder an input dataset themselves is unknown -- it would save a lot of developers working on code that uses it some headaches.

Thanks so much for your help!

adw96 commented 6 months ago

Hi @svteichman -- circling back to this -- I would love your help!

I've added this as part of a test (test-replicates), which is currently failing.

Any help appreciated!

adw96 commented 6 months ago

Huge thanks for looking into this and merging the PR -- confirming I no longer have this issue