Skip to content

Commit

Permalink
bump to version 1.1.0 and synch with web
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhiqiang-PANG committed Apr 1, 2023
1 parent c6668f8 commit 0133fa6
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 155 deletions.
7 changes: 1 addition & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
Package: OptiLCMS
Title: Optimized LC-MS Spectra Processing
Version: 1.0.5
Version: 1.1.0
Authors@R: c(
person(given = "Zhiqiang",
family = "Pang",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-1654-7556")),
person(given = "Jasmine",
family = "Chong",
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0002-2848-038X")),
person(given = "Jianguo",
family = "Xia",
role = c("aut"),
Expand Down
24 changes: 11 additions & 13 deletions R/Global_setting.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Setting .on.public.web (if on.public.web, the version number will be even,
# Setting .on.public.web() (if on.public.web, the version number will be even,
# local package is odd)
.on.public.web <- FALSE;
# .on.public.web <- function() {
# if (file.exists("../../css/spectrum.min.css") |
# file.exists("/Users/xia/Dropbox/") |
# file.exists("/data/glassfish/projects/metaboanalyst")) {
# return(TRUE)
# } else {
# return(FALSE)
# }
# }
#.on.public.web() <- FALSE;
.on.public.web <- function() {
if (exists("metaboanalyst_env")) {
return(TRUE)
} else {
return(FALSE)
}
}



Expand Down Expand Up @@ -123,7 +121,7 @@ MessageOutput <- function(mes = NULL,
SuppressWeb = FALSE,
sleep = 0) {
if (!is.null(mes)) {
if (.on.public.web & !SuppressWeb) {
if (.on.public.web() & !SuppressWeb) {
# write down message
write.table(
mes,
Expand All @@ -146,7 +144,7 @@ MessageOutput <- function(mes = NULL,
}

# write down progress
if (.on.public.web & !is.null(progress)) {
if (.on.public.web() & !is.null(progress)) {
progress <- as.numeric(progress)

write.table(
Expand Down
18 changes: 9 additions & 9 deletions R/Optimize_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ PerformParamsOptimization <- function(mSet,
MessageOutput(paste0("DoE Optimization Starting Now... (",
Sys.time(),")"), "\n", NULL)

if (.on.public.web){
if (.on.public.web()){
ncore <- 2;
} else if (missing(ncore)){
ncore <- ceiling(detectCores()*2/3);
Expand Down Expand Up @@ -227,7 +227,7 @@ PerformParamsOptimization <- function(mSet,
marker_record("others_c1");
}

if (.on.public.web){
if (.on.public.web()){
MessageOutput(NULL, NULL, 20.00);

if (is(p1,"simpleError")) {
Expand Down Expand Up @@ -262,7 +262,7 @@ PerformParamsOptimization <- function(mSet,

best_params <- p1;

if(.on.public.web) {
if(.on.public.web()) {
save(best_params, file = "best_params.rda");
return(best_params);
} else {
Expand Down Expand Up @@ -576,7 +576,7 @@ optimizxcms.doe.peakpicking <- function(object = NULL,
#best_settings$result <- target_value
history$best_settings <- best_settings

if(!.on.public.web){
if(!.on.public.web()){
message("best parameter settings:")
cat(paste(rbind(paste(names(xcms_parameters), sep="", ": "),
paste(xcms_parameters, sep="", "\n")), sep=""))
Expand Down Expand Up @@ -726,14 +726,14 @@ ExperimentsCluster_doe <-function(object, object_mslevel,params,
MessageOutput("If there is some unexpected bugs, please reduce the 'core' as 1.\n")
}

if (.on.public.web){
if (.on.public.web()){
nSlaves <- 2;
}

# Parallel or single core
if(nSlaves > 1) {

if (.on.public.web){
if (.on.public.web()){
nstepby <- 5;
nstep<-ceiling(length(tasks)/nstepby);

Expand Down Expand Up @@ -791,14 +791,14 @@ ExperimentsCluster_doe <-function(object, object_mslevel,params,
# Setting progress bar and start the running loop
pb <- progress_bar$new(format = "DoE Running [:bar] :percent Time left: :eta", total = nstep, clear = TRUE, width= 75)

if (.on.public.web){
if (.on.public.web()){
print_mes <- paste0("Finished: ");
write.table(print_mes,file="metaboanalyst_spec_proc.txt",append = TRUE ,row.names = FALSE,col.names = FALSE, quote = FALSE, eol = "");
}

for (w in seq_len(nstep)){

if (.on.public.web){
if (.on.public.web()){

count_tmp <- pb$tick();
totalcount <- formals(count_tmp[["initialize"]])[["total"]];
Expand Down Expand Up @@ -932,7 +932,7 @@ Statistic_doe <-function(object, object_mslevel, isotopeIdentification,

mSet_OPT$OptiParams <- xcms_parameters;

if (.on.public.web){
if (.on.public.web()){
print_mes <- paste0("Model Parsing Done !\n");
write.table(print_mes,file="metaboanalyst_spec_proc.txt",append = TRUE, row.names = FALSE,col.names = FALSE, quote = FALSE, eol = "\n");
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/Params_db.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ SetPeakParam <- function(platform = "general", Peak_method = "centWave", RT_meth
.SwapEnv$envir <- new.env();
}

if (.on.public.web & missing(platform) & missing(Peak_method) & file.exists("params.rda")){
if (.on.public.web() & missing(platform) & missing(Peak_method) & file.exists("params.rda")){
#marker_record(paste0("operators","_operators_1"));
load("params.rda");

Expand Down Expand Up @@ -2065,7 +2065,7 @@ SetPeakParam <- function(platform = "general", Peak_method = "centWave", RT_meth


#Output a table for display
if(.on.public.web){
if(.on.public.web()){

if(file.exists("params.rda")){
file.rename("params.rda", "params_last.rda")
Expand Down
32 changes: 16 additions & 16 deletions R/Perform_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ PerformPeakProfiling <-

.optimize_switch <- .SwapEnv$.optimize_switch <- FALSE;

if(.on.public.web){
if(.on.public.web()){
### Update parameters' style
write.table(
unlist(Params),
Expand All @@ -132,7 +132,7 @@ PerformPeakProfiling <-
ecol = NULL,
progress = 25)

if (.on.public.web) {
if (.on.public.web()) {
# load_biocparallel()
total_threads <- 4

Expand Down Expand Up @@ -196,7 +196,7 @@ PerformPeakProfiling <-

.SwapEnv$envir$mSet <- mSet;

if (.on.public.web) {
if (.on.public.web()) {
if (!is(mSet, "mSet")) {
MessageOutput(
mes = paste0(
Expand Down Expand Up @@ -247,7 +247,7 @@ PerformPeakProfiling <-
marker_record("peak_profiling_c2")
}

if (.on.public.web) {
if (.on.public.web()) {

if (is(mSet, "simpleError")) {
MessageOutput(
Expand Down Expand Up @@ -328,7 +328,7 @@ PerformPeakProfiling <-
progress = 88
)

if(.on.public.web){
if(.on.public.web()){
save(mSet, file = "mSet.rda");
}

Expand Down Expand Up @@ -371,7 +371,7 @@ PerformPeakProfiling <-
)

### 2. PCA plotting -----
# if (.on.public.web) {
# if (.on.public.web()) {
# load_ggplot()
# }

Expand Down Expand Up @@ -466,7 +466,7 @@ SetAnnotationParam <-
annParams <- list()
peakParams <- NULL;

if (.on.public.web) {
if (.on.public.web()) {
if(file.exists("params.rda")){
load("params.rda")
} else {
Expand Down Expand Up @@ -547,23 +547,23 @@ PerformPeakAnnotation <-
)

if(length(mSet@rawOnDisk) == 0){
if(.on.public.web){
if(.on.public.web()){
MessageOutput("ERROR: No MS data imported, please import the MS data with 'ImportRawMSData' first !", NULL, NULL)
} else {
stop("No MS data Imported, please import the MS data with 'ImportRawMSData' first !")
}
}

if(is.null(mSet@peakfilling$FeatureGroupTable)){
if(.on.public.web){
if(.on.public.web()){
MessageOutput("ERROR: No features found for annotation, please do the \"ImportRawMSData\", \"PerformPeakProfiling\", first before annotation !");
stop();
} else {
stop("No features found for annotation, please do the \"ImportRawMSData\", \"PerformPeakProfiling\", first before annotation !")
}
}

# if (.on.public.web) {
# if (.on.public.web()) {
# dyn.load(.getDynLoadPath());
#
# load_progress();
Expand Down Expand Up @@ -1360,7 +1360,7 @@ PerformPeakAnnotation <-
progress = 97)

## 6. Mass Matching
if(.on.public.web){
if(.on.public.web()){
mSet <- PerformMassMatching(mSet);
}

Expand Down Expand Up @@ -1420,7 +1420,7 @@ PerformPeakAnnotation <-
marker_record("peak_annotation_c1");
}

if(.on.public.web){
if(.on.public.web()){
save(mSet, file = "mSet.rda");
}

Expand Down Expand Up @@ -1486,7 +1486,7 @@ FormatPeakList <-
}

if(length(mSet@rawOnDisk) == 0){
if(.on.public.web){
if(.on.public.web()){
MessageOutput("ERROR: No MS data imported, please import the MS data with 'ImportRawMSData' first !", NULL, NULL)
} else {
stop("No MS data Imported, please import the MS data with 'ImportRawMSData' first !")
Expand Down Expand Up @@ -1694,7 +1694,7 @@ FormatPeakList <-
datam[, 6] <- missing_perc;

mSet@peakAnnotation$peak_result_summary <- datam;
if(.on.public.web) {
if(.on.public.web()) {
mSet@peakAnnotation[["massMatching"]][["Compound"]][is.na(mSet@peakAnnotation[["massMatching"]][["Compound"]])] <-
mSet@peakAnnotation[["massMatching"]][["Formula"]][is.na(mSet@peakAnnotation[["massMatching"]][["Formula"]])] <-
"";
Expand All @@ -1720,7 +1720,7 @@ FormatPeakList <-
9
)

if(.on.public.web){
if(.on.public.web()){
# remove isotopes and adducts directly
if (annParams$polarity == "positive") {
camera_isotopes <-
Expand Down Expand Up @@ -1903,7 +1903,7 @@ Export.PeakSummary <- function(mSet = NULL, path = getwd()){


PerformMassMatching <- function(mSet = NA) {
if(!.on.public.web) {
if(!.on.public.web()) {
message("PerformMassMatching is not supported for local version now!")
return(0)
}
Expand Down
14 changes: 7 additions & 7 deletions R/ROI_Extraction.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ PerformROIExtraction <-

datapath <- normalizePath(datapath);

if(!.on.public.web){
if(!.on.public.web()){
#Local R package running
files <- Path2Files(path = datapath);
files <- unlist(sapply(files, tools::file_path_as_absolute));
Expand Down Expand Up @@ -161,7 +161,7 @@ PerformROIExtraction <-
if (c1) {
#Select first at least 2 QC data for optimization

if (.on.public.web) {
if (.on.public.web()) {
#TODO: need to configure with the online pipeline
mSet <- NULL;
load("mSet.rda");
Expand Down Expand Up @@ -373,7 +373,7 @@ PerformROIExtraction <-
# include the 90% RT range
}

if(.on.public.web){
if(.on.public.web()){
rmConts <- FALSE;
peakParams <- NULL;
tmp_mes <- try(suppressWarnings(load("params.rda")),silent = TRUE);
Expand All @@ -386,7 +386,7 @@ PerformROIExtraction <-
if(is(tmp_mes,"try-error") | rmConts){
raw_data <- ContaminatsRemoval(raw_data, ms_list);
raw_data <- .emptyscan.remove(raw_data, ms_list);
} else if (.on.public.web) {
} else if (.on.public.web()) {

if(exists("peakParams")){
if(peakParams[["rmConts"]]){
Expand Down Expand Up @@ -474,7 +474,7 @@ PerformROIExtraction <-
if (plot == TRUE) {
MessageOutput("Chromatogram Plotting Begin...",ecol = "\n",NULL);

# if (.on.public.web) {
# if (.on.public.web()) {
# load_RColorBrewer();
# }

Expand Down Expand Up @@ -502,7 +502,7 @@ PerformROIExtraction <-

mSet@rawInMemory <- trimed_MSnExp;

if(.on.public.web){
if(.on.public.web()){
save(mSet, file = "mSet.rda");
}

Expand Down Expand Up @@ -1042,7 +1042,7 @@ PerformMSDataOutput<-function(raw_data){
#' @noRd
plot.MS_3D<-function(object) {

# if (.on.public.web){load_lattice()};
# if (.on.public.web()){load_lattice()};
#
dd <- as(object, "data.frame")
dd$rt <- dd$rt*60;
Expand Down
Loading

0 comments on commit 0133fa6

Please sign in to comment.