Hello, I have been trying to run an analysis using Maaslin2, running the program through R Studio. I have no issues calling in the input data file (which is relative metatranscriptomic data per sample) and then the metadata (which includes, discrete, binary, and continuous variables) with NA where there is no data. The program itself starts (and the demo worked), but no matter how I try to tweak the data I keep getting errors that lead to no viable output. The error code looks like:
Error in glm.fit(x = structure(numeric(0), .Dim = c(0L, 231L), .Dimnames = list( :
object āfitā not found
In addition: Warning messages:
1: In glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = NULL, :
no observations informative at iteration 1
2: glm.fit: algorithm did not converge
3: In glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = NULL, :
no observations informative at iteration 1
4: glm.fit: algorithm did not converge
Edit: On readjusting the data frames, I was able to reduce the errors to:
Error in contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
And on review of the file, it seems for some reason it is reading the metadata file in, but it is taking the header as the āvalueā, i.e. not looking past the first line. I am unsure why this is the case, given it is a tab-delimitated formatā¦
I presume it is an issue with how it is trying to compare the two input files, but I canāt seem to figure out the issue. Any help is much appreciated!
Hi JML, thanks for reaching out! Based on the message you provided, Iād say one of two things is happening:
As you suggested, Maaslin2 might not be reading in the input correctly. Iām guessing youāre providing the input metadata (parameter input_metadata) as a file path? Without looking at the file itself, I wonāt be able to tell whatās causing Maaslin2 to treat the first row as values instead of headers. However you might attempt to fix this by reading in the metadata first in R as a data frame, using functions such as read.table. The correctly processed data frame object can then be provided as the input to Maaslin2, (instead of a file path).
It could also be that you have a character column in your metadata has only one value, hence the ācontrasts can be applied only to factors with 2 or more levelsā error. Iād still say the first issue is more likely, but it might be helpful to eyeball your metadata just to check for this.
Thanks!
Siyuan
Thanks Siyuan, Iāve tried both file path and reading in the .tsv as a table, but it produces the same issue either way. Iāve tried to model my metadata to the files from the demo, so Iām still not sure the issue. The metadata and data are all continuous data, would that be the issue? Also Iāve tried to mess around with using fixed_effects, but doesnāt seem to rectify the issue. (Does it matter if the ID is pulled in as factor or num?) This is a sample of the metadata (variable names changed, but otherwise same format). Maybe Iām missing something, thank you!
Hi Jesus -
Thanks for providing the metadata sample - itās very helpful! I tried using this on a toy abundance table, and was able to run Maaslin2 without errors. The metadata file and R code are attached. Maybe you could compare this versus your code to pin point where things mightāve broke?
If this does not solve the issue, itād be great if you could provide a minimal reproducible example of the error, including R code and input files (with .txt/.tsv extensions). Feel free to mask away sensitive info or use toy data. For guidelines, refer to for example https://stackoverflow.com/help/minimal-reproducible-example.
Thanks!
Siyuan
Hi there,
Did you try to run your data following Siyuanās code? If yes, can you provide a minimal reproducible example of the error, including R code and input files (with .txt/.tsv extensions), so that we can try to recreate the issue on our end?
I got the same errors when running my own datasets.I am able to run the demo datasets, but I am not lucky to get my own dataset working. Attached are my inputs. Would you please take a look? Much appreciated. taxonomy4.tsv (22.4 KB) meta4.tsv (582 Bytes)
Blockquote
Error in glm.fit(x = structure(numeric(0), dim = c(0L, 10L), dimnames = list( :
object āfitā not found
In addition: Warning messages:
1: In glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = NULL, :
no observations informative at iteration 1
2: glm.fit: algorithm did not converge
3: In glm.fit(x = numeric(0), y = numeric(0), weights = NULL, start = NULL, :
no observations informative at iteration 1
4: glm.fit: algorithm did not converge