malucalle / selbal

selbal: selection of balances for microbial signatures
32 stars 15 forks source link

cv.selbal: Error in xtfrm.data.frame(x) : cannot xtfrm data frames #32

Open mariamaseng opened 1 year ago

mariamaseng commented 1 year ago

Hi! I am trying this amazing package for the first time, and are encountering a problem. It says it finished, defining the optimal number of variables as 6, but trying to access the object (CV.BAL.dic) it is not found. I am getting an error message I dont understand, see below.

This is the code:

x = final_selbal_df[,1:150] #dim(x) 667 150
y = final_selbal_df[,151] #length(y) 667
CV.BAL.dic = selbal.cv(x, y, n.fold = 5, n.iter = 10,logit.acc = "AUC")

And this is the output: ############################################################### STARTING selbal.cv FUNCTION ###############################################################

-------------------------------------------------------------

ZERO REPLACEMENT . . .

Warning: Column(s) containing more than 80% zeros/unobserved values were found (check it out using zPatterns). (You can use the z.warning argument to modify the warning threshold).Warning: Row(s) containing more than 80% zeros/unobserved values were found (check it out using zPatterns). (You can use the z.warning argument to modify the warning threshold). , . . . FINISHED.

-------------------------------------------------------------

-------------------------------------------------------------

Starting the cross - validation procedure . . .Warning: already exporting variable(s): logit.acc

. . . finished.

-------------------------------------------------------------

###############################################################

The optimal number of variables is: 6

Warning: Column(s) containing more than 80% zeros/unobserved values were found (check it out using zPatterns). (You can use the z.warning argument to modify the warning threshold).Warning: Row(s) containing more than 80% zeros/unobserved values were found (check it out using zPatterns). (You can use the z.warning argument to modify the warning threshold).Warning: Ignoring unknown parameters: linewidthWarning: The <scale> argument of guides() cannot be FALSE. Use "none" instead as of ggplot2 3.3.4.Error in xtfrm.data.frame(x) : cannot xtfrm data frames

mariamaseng commented 1 year ago

Additional messages:

image

peter0k commented 1 year ago

Additional messages:

image

Hi! I am also a first time user and having the same issue (R version 4.3.1).

peter0k commented 1 year ago

Additional messages:

image

Modified

RESUME.BAL <- RESUME.BAL[,c(ncol(RESUME.BAL), ncol(RESUME.BAL)-1,
                            order(RESUME.BAL[nrow(RESUME.BAL),
                                             -c(ncol(RESUME.BAL),
                                                ncol(RESUME.BAL)-1)],
                                  decreasing = T))]

to

RESUME.BAL <- RESUME.BAL[,c(ncol(RESUME.BAL), ncol(RESUME.BAL)-1,
                            order(as.numeric(RESUME.BAL[nrow(RESUME.BAL),
                                             -c(ncol(RESUME.BAL),
                                                ncol(RESUME.BAL)-1)],
                                  decreasing = T)))]
Rivera5 commented 1 year ago

Hi @peter0k and @mariamaseng!

Did you solve the issue with Error in xtfrm.data.frame(x) : cannot xtfrm data frames?

peter0k commented 1 year ago

Hi @peter0k and @mariamaseng!

Did you solve the issue with Error in xtfrm.data.frame(x) : cannot xtfrm data frames?

Yes I sourced Selbal_Functions.R with the modification I posted above into my script. It didn't produce the error mentioned.