## Not run:
# ##############################################################
# #
# # Outlier Detection for Mass Spectrometry Data
# # Section 3. Illustration
# # by HyungJun Cho and Soo-Heang Eo,
# # Dept of Statistics, Korea University, Seoul, Korea
# #
# ##############################################################
#
# #####
# # Load a package OutlierDM
#
# # If an OutlierDM package is not installed on your system, type
# #install.package('OutlierDM', dependency = TRUE)
# library(OutlierDM)
#
# #####
# # Sec 3.1 When the number of replicates is large enough
# ## Load toy dataset
# data(toy)
# head(toy)
# pairs(log2(toy), pch = 20, cex = .7)
#
# #####
# # Fit 1. Z-score based criterion
# fit1 = odm(x = toy, method = "Zscore", k = 3)
# fit1
# summary(fit1)
# head(input(fit1))
# head(output(fit1))
# print(outliers(fit1), digits = 3)
# plot(fit1)
# rect(1, -4, 10, 4, col = heat.colors(20,alpha = 0.3), border = heat.colors(20,alpha = 0.5))
# oneplot(object = fit1, i = 4)
# title("Outlier Detection by the Z-score criterion")
#
# # Add a peptide name on a dot-plot
# #oneplot(fit1, 191,1)
# #title("Outlier Detection by the Z-score criterion")
#
# #####
# # Fit 2. Grubbs test criteria
# fit2 = odm(x = toy, method ="grubbs", alpha = 0.01)
# fit2
# summary(fit2)
# head(output(fit2))
# print(outliers(fit2), digits = 3)
# oneplot(object = fit2, i = 1)
# title("Outlier Detection by the Grubbs criterion")
#
# # Add text
# #oneplot(fit2, 191,1)
# #title("Outlier Detection by the Grubbs criterion")
#
# #####
# # Fit 3. IQR criteria
# fit3 = odm(x = toy, method = "iqr", k = 3)
# fit3
# summary(fit3)
# print(outliers(fit3), digits = 3)
# plot(fit3)
# rect(1, -4, 10, 40, col = heat.colors(20,alpha = 0.3), border = heat.colors(20,alpha = 0.5))
# oneplot(fit3, 1)
# title("Outlier Detection by the IQR criterion")
#
# # Add a peptide name on a dot-plot
# #oneplot(fit3, 1, 1)
# #title("Outlier Detection by the IQR criterion")
#
# #####
# # Fit 4. SIQR criteria
# fit4 = odm(x = toy, method = "siqr", k = 3)
# fit4
# summary(fit4)
# print(outliers(fit4), digits = 3)
# plot(fit4)
# rect(1, -4, 10, 4, col = heat.colors(20,alpha = 0.3), border = heat.colors(20,alpha = 0.5))
# oneplot(fit4, 1)
# title("Outlier Detection by the SIQR criterion")
#
# #####################
# ## Real data example
# #####################
# data(lcms3)
# head(lcms3)
# pairs(log2(lcms3), pch = 20, cex = .7)
#
# #####
# # Fit 5. OutlierD
# fit5 = odm(lcms3[,1:2], method = "pair", k = 3)
# fit5
# summary(fit5)
# head(output(fit5))
# print(outliers(fit5), digits = 3)
# plot(fit5)
# title("Outlier Detection by the OutlierD algorithm")
#
# #####
# # Fit 6. OutlierDM
# fit6 = odm(lcms3, method = "proj", k = 3, center = TRUE)
# fit6
# summary(fit6)
# print(outliers(fit6), digits = 3)
# plot(fit6)
# title("Outlier Detection by the OutlierDM algorithm")
# oneplot(fit6, 18)
# #oneplot(fit6, 18, 1)
# title("The dotplot for the 18th samples of the lcms3 data")
# ### End of the illustration
#
#
# #####
# # Other OutlierDM algorithms
# data(lcms3)
#
# ## Load
# ## Fit projection approaches
# fit.proj.const <- odm(lcms3, quantreg="constant")
# fit.proj.linear <- odm(lcms3, quantreg="linear")
# fit.proj.nonlin <- odm(lcms3, quantreg="nonlin")
# fit.proj.nonpara <- odm(lcms3, quantreg="nonpar", lbda = 1)
#
# par(mfrow = c(2,2))
# plot(fit.proj.const, main = "Constant")
# plot(fit.proj.linear, main = "Linear")
# plot(fit.proj.nonlin, main = "NonLinear")
# plot(fit.proj.nonpara, main = "Nonparametric")
#
# ## End(Not run)
Run the code above in your browser using DataLab