NIPALS error - non-conformable arrays

Hi MixOmics,

I am trying to use NIPALS to impute my missing data for my MS proteomic block.

When I run the following command:
nipals(untargeted.ru, ncomp = 10, reconst = TRUE)

I get this error:
Error in ph.new/drop(sqrt(crossprod(ph.new))) : non-conformable arrays

untargeted.ru is my proteomic dataset; with 49 samples in rows, and 409 proteins in columns. The missing values are indicated by NA. There is a very high rate of missingness in the dataset - 8237 out of 20041 observations are NA. Is this too much missing data?

Many thanks,
Heather

Hi Heather,

Thanks for using mixOmics!

Can you please:

As a sidenote, if you have any features/samples who are all NAs (and thus/or have zero variance), please filter them beforehand. You can so so using:

untargeted.ru <- untargeted.ru[!is.na(apply(untargeted.ru , 1, function(x) var(x, na.rm = TRUE))),
                               !is.na(apply(untargeted.ru , 2, function(x) var(x, na.rm = TRUE)))]

Thanks

Al

Hi I ran into this error as well, and it seems to be caused when the maximum variance column of your data selected by th = X[, which.max(apply(X, 2, var, na.rm = TRUE))] has NA’s at indices that cover all the non-NA values of any other column. Not sure what this means in terms of the validity of the input, but it produces a divide by zero for one element of ph.new, which produces an NA when crossprod(ph.new) is called.

library(mixOmics)
data("liver.toxicity")
X <- liver.toxicity$gene[,1:100]

maxvar_idx = which.max(apply(X, 2, var, na.rm = TRUE))
# 64

na_idx = sample(1:dim(X)[1], 10, replace = F)

X[na_idx, maxvar_idx] <- NA
X[-na_idx, 5] <- NA # choose random column that is not the one with max variance

result = nipals(X, reconst = TRUE, ncomp = 10) 
Error in ph.new/drop(sqrt(crossprod(ph.new))) : non-conformable arrays

Thanks @clabornd, we will look into this with @aljabadi - we are currently changing that function.

Kim-Anh