Error in SetCurrentMsetLib function in R?

Hi Xia Lab members,

I am currently working on an analysis using the MetaboAnalyst package Version 3.3.0 in R. I currently like to perform an enrichment analysis with the following code:

mSet<-InitDataObjects(“conc”, “msetora”, FALSE)
cmpd.vec<-ANOVA_HMDB
mSet<-Setup.MapData(mSet, cmpd.vec);
mSet<-CrossReferencing(mSet, “hmdb”);
mSet<-CreateMappingResultTable(mSet)
mSet<-SetMetabolomeFilter(mSet, F);
mSet<-SetCurrentMsetLib(mSet, “smpdb_pathway”, 2);
mSet<-CalculateHyperScore(mSet)

However, after the “SetCurrentMsetLib” step, I sometimes get the following error:

Error in if (!exists(“current.msetlib”) || mSetObj$analSet$msetlibname != :
missing value where TRUE/FALSE needed

Yesterday, I tried it once with the “KEGG_pathway” argument and switched back to smpdb and then suddenly it worked. Now, nothing works anymore. Is there an issue in my code? I am just starting using R, but it seems like this issue is above my skills.

Thank you very much for your help!

Best,
David

Love MetaboAnalyst btw!

So, I found out that it actually works when I start with

mSet<-SetCurrentMsetLib(mSet, “kegg_pathway”, 2);

and then switch it to

mSet<-SetCurrentMsetLib(mSet, “smpdb_pathway”, 2);

Probably, because “kegg” is mentioned here (copied from github):
if(libname==“self”){
ms.list ← mSetObj$dataSet$user.mset;
ms.list ← lapply(ms.list, function(x) unique(unlist(strsplit(x, "; ", fixed=TRUE))));
current.msetlib ← vector(“list”, 3)
names(current.msetlib) ← c(“name”, “member”, “reference”)
mSetObj$analSet$msetlibname ← libname;
} else {
if(!.on.public.web & grepl(“kegg”, libname)){ # api only for KEGG msets
mSetObj$api$libname ← libname
mSetObj$api$excludeNum = excludeNum
mSetObj$analSet$msetlibname ← libname
return(.set.mSet(mSetObj));
}

Best,
David

Thanks for the note. The issue is indeed related to the initial value was not set properly. Should be fixed now