Jfortin1 / neuroCombat_Rpackage

neuroCombat R package
20 stars 8 forks source link

Error in apply / 'MARGIN' does not match dim(X) #2

Closed aliceballerini closed 2 years ago

aliceballerini commented 2 years ago

Hello Dr. Fortin,

I've always used you amazing package on R successfully, but after the update it doesn't work anymore. I try several time, I also tried to run your example, but I always got the same error: Error in apply(x, 3L, qr.default, ...) : 'MARGIN' does not match dim(X)

Here's the code:

library(neuroCombat) p=10000 n=10 batch = c(1,1,1,1,1,2,2,2,2,2) dat = matrix(runif(p*n), p, n) data.harmonized <- neuroCombat(dat=dat, batch=batch) [neuroCombat] Performing ComBat with empirical Bayes [neuroCombat] Found 2 batches Error in apply(x, 3L, qr.default, ...) : 'MARGIN' does not match dim(X) traceback() 7: stop("'MARGIN' does not match dim(X)") 6: apply(x, 3L, qr.default, ...) 5: qr.array(design) 4: qr(design) 3: .checkDesign(design, n.batch) 2: getDataDict(batch, mod, mean.only = mean.only, ref.batch = ref.batch, verbose = verbose) 1: neuroCombat(dat = dat, batch = batch)

What is your advice to fix that?

Jfortin1 commented 2 years ago

Hi @aliceballerini, I cannot reproduce the problem. Did you restart your R session and try again? It could be due to an incompatible package that was loaded in your session.

BS1125 commented 2 years ago

The error disappeared after I restarted the R session.

stevencenusc commented 2 years ago

data.harmonized <- neuroCombat(dat=rad, batch=sitecode, mod=mod) [neuroCombat] Performing ComBat with empirical Bayes [neuroCombat] Found 5 batches [neuroCombat] Adjusting for 3 covariate(s) or covariate level(s) [neuroCombat] Standardizing Data across features [neuroCombat] Fitting L/S model and finding priors [neuroCombat] Finding parametric adjustments [neuroCombat] Adjusting the Data Warning message: In xtfrm.data.frame(x) : cannot xtfrm data frames mod.csv sitecode.csv sitecode_s.csv mod_s.csv rad_s.csv