oloBion / Retip

Retip - Retention Time prediction for metabolomics
31 stars 15 forks source link

The last step of creating predicted RT doesn’t work using inbuilt database in retip such as HMDB #1

Closed h2002766 closed 3 years ago

h2002766 commented 4 years ago

hmdb_pred <- RT.spell(training,target="HMBD",model=keras,output="MSFINDER")

PaoloBnn commented 4 years ago

I see. I miss to actualize the guide in retip.app. Sorry about that. Now we have two different function: first you have to do the prediction and then export. Like this:

if you will use MSFINDER i suggest predicting ALL compounds and then inside MSFINDER just select the HMDB filter. Also, will be easier for you as you have all compounds for a next time you want to have more db.

all_pred <- RT.spell(training,target="ALL",model=xgb) export_rtp <- RT.export(all_pred, program="MSFINDER",pol="pos")

Consider that if you use keras you should save your model. If you quit R and then restart keras model do not work anymore, you should restore from saved one or recompute.

h2002766 commented 4 years ago

Still getting this below error after running the below code: all_pred <- RT.spell(training,target="ALL",model=xgb)

Error in eval(predvars, data, env) : object 'Fsp3' not found

On Thu, Jun 4, 2020 at 2:04 AM Paolo Bonini notifications@github.com wrote:

I see. I miss to actualize the guide in retip.app. Sorry about that. Now we have two different function: first you have to do the prediction and then export. Like this:

if you will use MSFINDER i suggest predicting ALL compounds and then inside MSFINDER just select the HMDB filter. Also, will be easier for you as you have all compounds for a next time you want to have more db.

all_pred <- RT.spell(training,target="ALL",model=xgb) export_rtp <- RT.export(all_pred, program="MSFINDER",pol="pos")

Consider that if you use keras you should save your model. If you quit R and then restart keras model do not work anymore, you should restore from saved one or recompute.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PaoloBnn/Retip/issues/1#issuecomment-638719555, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBKLUR43OOUEM6KAKODEC3RU5PR7ANCNFSM4NRKASZQ .

PaoloBnn commented 4 years ago

Did you install Retiplib ?

h2002766 commented 4 years ago

Yes, Retiplib is installed

On Thu, Jun 4, 2020 at 11:13 AM Paolo Bonini notifications@github.com wrote:

Did you install Retiplib ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PaoloBnn/Retip/issues/1#issuecomment-639020044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBKLUV4FZOAJT2P46ZMP53RU7P6HANCNFSM4NRKASZQ .

h2002766 commented 4 years ago

[image: image.png]

On Thu, Jun 4, 2020 at 11:29 AM Sangaraju Dewakar h2002766@gmail.com wrote:

Yes, Retiplib is installed

On Thu, Jun 4, 2020 at 11:13 AM Paolo Bonini notifications@github.com wrote:

Did you install Retiplib ?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/PaoloBnn/Retip/issues/1#issuecomment-639020044, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBKLUV4FZOAJT2P46ZMP53RU7P6HANCNFSM4NRKASZQ .

PaoloBnn commented 4 years ago

Please try to run this code and let see where is the problem

# apply the prediction to HMDB with XGboost model
retip_lib_v2 <- data.frame(Retip::retip_lib_head,Retiplib::retip_lib_v1)
target <- dplyr::filter(retip_lib_v2 , retip_lib_v2[,7] != "N/A")

# use only descriptors column present in custom rt original library
target_desc_f <- target[names(target) %in% names(training)]
# build again dataframe with description column
target_db <- data.frame(target[,c(1:3)],target_desc_f)
# remuove na values
target_db <- target_db [stats::complete.cases(target_db), ]
# separate column with descriptions
target_head <- target_db[,c(1:3)]
# convert to matrix to work with keras and lightgbm
target_desc <-target_db[,-c(1:3)]
# set number of columns
ncol1 <- ncol(target_desc)
# predict RT with the model selected
pred1_target <- stats::predict(xgb, target_desc[,1:ncol1])
# convert from vector to dataframe
pred2_target <- data.frame(pred1_target)
# add again description column and round prediction to 2 decimals
pred_target <- data.frame(target_head,round((pred2_target),2))
# add name to retention time prediction column
colnames(pred_target)[4] <- "RTP"

View(pred_target)