This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Issue with 2D PCA score plot in MetaboAnalystR

Hi There,

Im having trouble getting a 2D PCA score plot from my mSet object. Here is my code so far (Im working on the example dataset and have followed the code given in the vignette.

mSet <- InitDataObjects("mspeak", "stat", FALSE)
# Unzips the uploaded zip file/s, removes it and saves it as "upload"
UnzipUploadedFile("lcms_3col_peaks.zip", "upload", F)
# Read peak lists/intensity files
(mSet <- Read.PeakList(mSet, "upload"))

##################################################################################
########################### Data Preprocessing ###################################
##################################################################################

### Peaks in NMR or MS peak lists that represent the same metabolite need to be combined 
mSet <- GroupPeakList(mSet,0.025,30.0)
# clean peak groups
(mSet <- SetPeakList.GroupValues(mSet))
# View message resulting from peak grouping 
mSet$dataSet$proc.msg

### Integrity Check: Is data suitable for subsequent analsysis
mSet <- SanityCheckData(mSet)
# to view any messages from sanity check:
mSet$dataSet$check.msg

#######################################################################################
########################## Data Processing ############################################
########################################################################################

########## Remove missing values

### Replace missing/zero values with a minimum positive value (can be perfomed before or after normalization)
mSet <- ReplaceMin(mSet)
# View messages collected during ReplaceMin()
mSet$msgSet$replace.msg

# Check if the sample size is too small (returns a 0 if the data passes the check)
mSet<-IsSmallSmplSize(mSet)

######### Nomalise

###Perform log transformation
mSet<-PreparePrenormData(mSet)
mSet <- Normalization(mSet, rowNorm = "NULL", transNorm = "LogNorm", scaleNorm = "AutoNorm", ref="NULL", ratio=FALSE, ratioNum=20)

# View feature normalization (sends these to working directory)
mSet<-PlotNormSummary(mSet, "feature_norm", format="png", dpi=300, width=0)
# View sample normalization
mSet<-PlotSampleNormSummary(mSet, "sample_norm", format="pdf", width=NA)

######### Filter

# 3 components of the FilterVariable function
(mSet <- FilterVariable(mSetObj = mSet,
                                filter = "mad", # user specified method for filtering (median absolute deviaton)
                                qcFilter = F, # Filter variables based on QC samples (if true then filter = "none")
                                rsd = 30))       # Define relative standard deviation cut off (variables greater then this removed)

### Remove samples
# Check for outliers
PlotPCA2DScore(mSetObj = mSet,
               imgName = "2D PCA score plot",
               format = "png",
               dpi = 300,
               width = 0,
               pcx = 1,
               pcy = 2,
               reg = 0.95,
               show = 1,
               grey.scale = 0)

Im coming out with the following error:

Error in var(cbind(pc1[inx], pc2[inx]), na.rm = T) : 'x' is NULL

Could someone help me with this? Thank you

r pca

0 answers

No answers yet.

Log in to answer this question.