The bioBakery help forum

Error "`x` and `y` must share the same src," when trying to include covariates in lm_meta

Dear all,

I already used MMUPHin with MetaPhlAn data but now while including HUMAnN pathways results and after reading a little more about the program I tried to include 2 covariates like “age”, “sex”. These covariates are not present in one study. I also tried MaAsLin2 to explore this results too.

When I try the tutorial with my own data…

pathway <- read_tsv("~/andres/HUMAnN/mmuphin_pathsX.tsv")
MeTa <- read_tsv("~/andres/HUMAnN/mmuphin_metadataX.csv")

pathway <- pathway %>% map_if(is.numeric, ~./sum(.)) %>% as.data.frame() %>% 
  column_to_rownames("ID") %>% as.matrix() # transform the data between 0-1
MeTa <- MeTa %>% column_to_rownames("ID") # with rownames

fit_lm_cov <- lm_meta(feature_abd = pathway,
                      batch = "study",
                      exposure = "response",
                      covariates = c("age", "sex"),
                      data = MeTa,
                      control = list(verbose = FALSE))

I got this error…

Error: `x` and `y` must share the same src, set `copy` = TRUE (may be slow).
Run `rlang::last_error()` to see where the error occurred.
Además: Warning messages:
1: In check_batch(df_batch[[batch]], min_n_batch = 2) :
  Batch variable is not a factor as provided and will be converted to one.
2: In lm_meta(feature_abd = pathway, batch = "study", exposure = "response",  :
  Covariate age is missing or has only one non-missing value in the following batches; will be excluded from model for these batches:
montes
3: In lm_meta(feature_abd = pathway, batch = "study", exposure = "response",  :
  Covariate sex is missing or has only one non-missing value in the following batches; will be excluded from model for these batches:
montes

Omitting the covariates…

fit_lm_cov <- lm_meta(feature_abd = pathway,
                      batch = "study",
                      exposure = "response",
                      data = MeTa,
                      control = list(verbose = FALSE))

This worked fine but with results only considering ‘response’ as a variable.

If I omit ‘montes’ from both files and rerun it and I got the same error

Error: `x` and `y` must share the same src, set `copy` = TRUE (may be slow).

I wonder if I can include these covariates in this step maybe I am missing something with the format. Thank you very much for your help

I am attaching the pathways file here
metadata = mmuphin_metadataX.csv (6.4 KB)

Best,

Andrés

Hi Andrés. This error has to do with how you have age encoded as A,B,C. Right now MMUPHin can’t handle fixed effects for categorical variables with more than two categories.

Tagging @sma to discuss the fix. I think if the control argument to lm_meta can take an entry for reference and then pass that to Maaslin2_wrapper, that should make it work. Will that be feasible Siyuan?

Thanks for your help Andrew, we coded the age as a discrete variable to use LEfSe first, we kept that in MaAsLin… then by inertia it got dragged as discrete into MMUPHin. I went back to the original numbers and the analysis run fine. Thanks for your help.

The package is great, maybe it is planned for future iterations like it was commented for MaAsLin but a follow up question or request would be to ask if there is a way to manually adjust the size of the ‘feature label’ in the forest .pdf plot, with pathways or broadly speaking HUMAnN data the large name is abbreviated since it can’t fit the page.

I don’t think exposing plot options to the user is planned at the moment. Probably the easiest thing for you to do is get your results into R, regenerate the figure using metafor::forest (the same function we use), then tweak it as necessary from there.

I will try that, thanks for the help again.

Hi all - yes, confirmed this appears to be an issue right now. I think Maaslin2 now requires multi-level variables to start with numerics to specify the reference level. In Andrés’ case the internal Maaslin2 runs are failing as a consequence. I might just throw the original error instead of having Maaslin2 fail silently and then report a nondescript one in its place. Thanks for bringing to my attention!