Stuck with a PCA code in mixOmics

I am trying to perform PCA with a microbiome data and visualize it with my outcome. After opening the data in wide format with counts from each bacteria as a column, I can see that they are all in numeric format. However, when I try to run PCA, it gives me a strange error, which I could not find easily through a google search. Below is my code:

`phylum_s1 <- read_dta(“phylum_wide_s1.dta”)
colnames(phylum_s1)
table(phylum_s1$periogroup)
is.numeric(phylum_s1$periogroup)
#phylum_s1$periogroup<-as.numeric(phylum_s1$periogroup)

PCA for SHIP-1

pca1<- pca(phylum_s1[,20:37],ncomp=2, center=FALSE, scale=FALSE)`

After the final code, I get the error “Error in ph.new/drop(sqrt(crossprod(ph.new))) : non-conformable arrays”. If someone has a solution, it would be really helpful for me.

hi @dr.vinay.muc,

Potentially you have too many zeroes (zeroes across all variables), or too many missing values in these variables, and the algorithm is running on empty matrices.
Also check that you input data in PCA are actually numeric (not characters).

Kim-Anh

Hi @kimanh.lecao

Thanks for your reply. My data is in numeric format, but you are right with having many zeros across variables. I will try re-selecting cases and get back here in case of troubles.