xia-lab / MetaboAnalystR

R package for MetaboAnalyst
Other
313 stars 155 forks source link

Biomarker Analysis tutorial #10

Closed cbroeckl closed 6 years ago

cbroeckl commented 6 years ago

I have just stumbled upon this repository and am excited that you are making this R code available! I am in a core facility, rely heavily on R, and am thrilled that you are contributing your efforts. i would like to adopt them in our lab so that I do not have to maintain our own tools to perform these steps. Many thanks! I have begun with the vignettes. After successful installation, i have hit a bit of a wall in one of the biomarker tutorial steps.

# Create objects for storing processed data from biomarker analysis 
mSet<-InitDataObjects("conc", "roc", FALSE)

# Read in data and fill in the dataSet list
mSet<-Read.TextData(mSet, "http://www.metaboanalyst.ca/MetaboAnalyst/resources/data/plasma_nmr_new.csv", "rowu", "disc")

# Sanity check, replace missing values, check if the sample size is too small
mSet<-SanityCheckData(mSet)
mSet<-ReplaceMin(mSet)
mSet<-IsSmallSmplSize(mSet)

# Perform no normalization, no ratio calculation
mSet<-Normalization(mSetObj = mSet, rowNorm="NULL", transNorm="NULL", scaleNorm="NULL", ref=NULL, ratio=FALSE, ratioNum=5)

# No normalization, and compute metabolite ratios and include the top 20 
mSet<-Normalization(mSet, "NULL", "NULL", "NULL", "C01", ratio=TRUE, ratioNum=20)

# If ratio = TRUE: view the normalized dataset including the top ranked ratios
# The ratios will be towards the end of the matrix 
mSet$dataSet$norm

#If ratio = TRUE: view just the top ranked included ratios
mSet$dataSet$ratio

In particular, I pass through he first 6 lines without error, but at the seventh line I hit an error

# No normalization, and compute metabolite ratios and include the top 20 
mSet<-Normalization(mSet, "NULL", "NULL", "NULL", "C01", ratio=TRUE, ratioNum=20)

Error in if (sum(as.numeric(bdata <= 0)) > 0) { : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In Ops.factor(bdata, 0) : ‘<=’ not meaningful for factors

I have gone into the 'Normalization' function and found that the problem seems to stem from the first few if-else lines. As the code is written, it reads something like this:

if {
   }
else {
      }

I am on windows, and the only way I can get this code to run properly (that is evaluating the else as an alternate to the if), is to have the else on the same line as the closing bracket.

if {
   } else {
      }

However, I am not sure this is the problem. Once I do get it to run, the output 'data' object contains no data

data <- mSetObj$dataSet$prenorm  # the previous if statements were false
data
 [1]                                                      
 [7]                                                      
[13] cachexic cachexic cachexic cachexic cachexic cachexic
[19] cachexic cachexic cachexic cachexic cachexic cachexic
[25] cachexic cachexic cachexic cachexic cachexic cachexic
[31] cachexic cachexic cachexic cachexic cachexic cachexic
[37] cachexic cachexic cachexic cachexic cachexic cachexic
[43] cachexic cachexic cachexic cachexic cachexic cachexic
[49] cachexic cachexic cachexic cachexic cachexic control 
[55] control  control  control  control  control  control 
[61] control  control  control  control  control  control 
[67] control  control  control  control  control  control 
[73] control  control  control  control  control 
Levels:  cachexic control

And clearly this isn't something that is normalizable, so I assume the error resides in this definition of 'data'.

If this is a suitable format for feedback, I also intend to go through the rest of your tuturials, and can communicate any issues that I find.

Corey

jsychong commented 6 years ago

Hi Corey,

Thank you for your feedback! On our end, the else statements are on the same line as the closing brackets, very weird - I'm working on a Linux, perhaps this is a Windows/Linux compatibility issue?

As for the tutorial, I realize it was not very clear - the second Normalization step doesn't work as there has already been a Normalization done to the data (line 6). So it should be option 1 (Line 6) or option 2 (Line 7). I will rectify the tutorial and make it clearer that there are two options.

Please feel free to communicate any troubles by opening issues on Github.

Cheers, Jasmine

cbroeckl commented 6 years ago

Thanks jasmine,

I appreciate the feedback, and am looking forward to exploring this package further,

Corey


From: jsychong notifications@github.com Sent: Tuesday, December 19, 2017 1:01 PM To: xia-lab/MetaboAnalystR Cc: Broeckling,Corey; Author Subject: Re: [xia-lab/MetaboAnalystR] Biomarker Analysis tutorial (#10)

Hi Corey,

Thank you for your feedback! On our end, the else statements are on the same line as the closing brackets, very weird - I'm working on a Linux, perhaps this is a Windows/Linux compatibility issue?

As for the tutorial, I realize it was not very clear - the second Normalization step doesn't work as there has already been a Normalization done to the data (line 6). So it should be option 1 (Line 6) or option 2 (Line 7). I will rectify the tutorial and make it clearer that there are two options.

Please feel free to communicate any troubles by opening issues on Github.

Cheers, Jasmine

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xia-lab/MetaboAnalystR/issues/10#issuecomment-352870351, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AEuu_QzrzzaSqurSle0xq4W1uhso7eK8ks5tCBYdgaJpZM4RCaVv.

cbroeckl commented 6 years ago

Jasmine,

CreatePDFReport(mSet, "User Name") Writing to file Analysis_Report.tex Processing code chunks with options ... 1 : keep.source term verbatim (Analysis_Report.Rnw:4) 2 : keep.source term tex (Analysis_Report.Rnw:87)

Error: chunk 2 Error in CreateUnivROCTable() : could not find function "CreateUnivROCTable"

Any idea why I can't find this function in pdf reporting? Thanks, Corey

jsychong commented 6 years ago

Hi Corey,

Thanks for the catch - the function wasn't exported in the previous version. Please download the .tar.gz file which has been updated! Cheers, Jasmine