Skip to content

Commit b4fc29f

Browse files
committed
fix for research data without Z-scores in DIMS
1 parent e9c4a42 commit b4fc29f

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

DIMS/CollectFilled.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ for (scanmode in scanmodes) {
2828
# calculate Z-scores
2929
if (z_score == 1) {
3030
outlist_stats <- calculate_zscores_peakgrouplist(outlist_total)
31+
} else {
32+
outlist_stats <- outlist_total
3133
}
3234
# calculate ppm deviation
3335
outlist_withppm <- calculate_ppm_deviation(outlist_stats)

DIMS/GenerateQCOutput.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ dir.create(paste0(outdir, "/plots"), showWarnings = FALSE)
3737
control_label <- "C"
3838

3939
#### CHECK NUMBER OF CONTROLS ####
40-
file_name <- "Check_number_of_controls.txt"
41-
min_num_controls <- 25
42-
check_number_of_controls(outlist, min_num_controls, file_name)
40+
if (any(grepl("nr_ctrls", colnames(outlist)))) {
41+
file_name <- "Check_number_of_controls.txt"
42+
min_num_controls <- 25
43+
check_number_of_controls(outlist, min_num_controls, file_name)
44+
}
4345

4446
#### INTERNAL STANDARDS ####
4547
is_list <- outlist[grep("Internal standard", outlist[, "relevance"], fixed = TRUE), ]

DIMS/preprocessing/collect_filled_functions.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,13 @@ order_columns_peakgrouplist <- function(peakgroup_list) {
129129

130130
original_colnames <- colnames(peakgroup_list)
131131
mass_columns <- c(grep("mzm", original_colnames), grep("nrsamples", original_colnames))
132-
descriptive_columns <- grep("assi_HMDB", original_colnames):grep("avg.int", original_colnames)
132+
if (any(grepl("avg.int", original_colnames))) {
133+
descriptive_columns <- grep("assi_HMDB", original_colnames):grep("avg.int", original_colnames)
134+
} else {
135+
descriptive_columns <- grep("assi_HMDB", original_colnames):grep("ppmdev", original_colnames)
136+
}
133137
intensity_columns <- c((grep("nrsamples", original_colnames) + 1):(grep("assi_HMDB", original_colnames) - 1))
134-
# if no Z-scores have been calculated, the following two variables will be empty without consequences for outlist_total
138+
# if no Z-scores have been calculated, the following two variables will be empty without consequences for peakgroup_list
135139
control_columns <- grep ("ctrls", original_colnames)
136140
zscore_columns <- grep("_Zscore", original_colnames)
137141
# create peak group list with columns in correct order

DIMS/preprocessing/sum_intensities_adducts.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ sum_intensities_adducts <- function(peakgroup_list, hmdb_part, adducts, z_score)
3232
int_cols_pats <- grep("P", colnames(peakgroup_list)[1:which(colnames(peakgroup_list) == "avg.ctrls")])
3333
int_cols <- c(int_cols_ctrls, int_cols_pats)
3434
} else {
35-
int_cols_start <- which(colnames(peakgroup_list) == "nrsamples") + 1
36-
int_cols_end <- which(colnames(peakgroup_list) == "assi_HMDB") - 1
35+
int_cols_start <- which(colnames(peakgroup_list) == "ppmdev") + 1
36+
int_cols_end <- ncol(peakgroup_list)
3737
int_cols <- c(int_cols_start:int_cols_end)
3838
}
3939

0 commit comments

Comments
 (0)