Emily_Yu
(Emily Yu)
April 7, 2024, 5:07pm
1
Hi, when I am using "--p-formula" in ANCOM-BC, I was wondering if the order of the variables matter? For example, if my variable of interest is sex and I want to add body-site and treatment as covariates, is there any difference between:
--p-formula "Sex+Body-site+Treatment"
--p-formula "Sex+Treatment+Body-site"
--p-formula "Treatment+Body-site+Sex"
--p-formula "Body-site+Treatment+Sex"
2 Likes
It's such a good question!
This page discibes the formula inputs as 'fixed-effects' which implies independant, but that's ANCOM-BC2
ANCOM-BC2 Tutorial
The page for ANCOM-BC does not mention fixed effects at all... ANCOM-BC Tutorial
vcov_hat = para$vcov_hat
var_hat = para$var_hat
# 4. Estimation of the sample-specific bias
if (verbose) {
message("Estimating sample-specific biases ...")
}
fun_list = list(.bias_em)
bias = foreach(i = seq_len(ncol(beta)), .combine = rbind) %dorng% {
output = fun_list[[1]](beta = beta[, i],
var_hat = var_hat[, i],
tol = tol,
max_iter = max_iter)
}
bias = data.frame(bias, row.names = covariates, check.names = FALSE)
delta_em = bias$delta_em
delta_wls = bias$delta_wls
var_delta = bias$var_delta
# 5. Obtain coefficients, standard errors, and sampling fractions
beta_hat = beta
I think the function stats::model.matrix()
ignores order. Can't find stuff on that either!
1 Like
I tried running this with data from PD-mice
In this example, donor and genotype are fully blocked and perfectly balanced:
$ cut -f 4,6 metadata.tsv | sort | uniq -c
1 categorical categorical
1 genotype donor
12 susceptible hc_1
12 susceptible pd_1
12 wild type hc_1
12 wild type pd_1
qiime composition ancombc \
--i-table table_2k_abund.qza \
--m-metadata-file metadata.tsv \
--p-formula 'donor + genotype' \
--o-differentials ancombc_donor_first.qza
qiime composition ancombc \
--i-table table_2k_abund.qza \
--m-metadata-file metadata.tsv \
--p-formula 'genotype + donor' \
--o-differentials ancombc_genotype_first.qza
# Then qiime composition da-barplot to make these:
ancombc_genotype_first.qzv (222.0 KB)
ancombc_donor_first.qzv (222.0 KB)
On first inspection, these look the same...
Remember that
this study is fully blocked (no confounding factors) and
all cohorts are balanced (n = 12 for subgroups)
which is cleaner than most real studies!
What I don't have is a citation that says formula order doesn't matter.
Remember that different packages run different tests, so formula order can absolutely matter!
2 Likes
system
(system)
Closed
May 13, 2024, 11:22am
11
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.