Skip to content

Commit

Permalink
2023-12-09
Browse files Browse the repository at this point in the history
Updated procedure for the combination of MS1 deisotoping and 13C allowance.
  • Loading branch information
qzhang503 committed Dec 10, 2023
1 parent 676c56e commit d395f8f
Show file tree
Hide file tree
Showing 7 changed files with 269 additions and 104 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: mzion
Type: Package
Title: Proteomics Database Searches of Mass-spectrometrirc Data.
Version: 1.3.5
Version: 1.3.5.1
Authors@R:
person(given = "Qiang",
family = "Zhang",
Expand Down
171 changes: 86 additions & 85 deletions R/mgfs.R
Original file line number Diff line number Diff line change
Expand Up @@ -312,48 +312,49 @@ readMGF <- function (filepath = NULL, filelist = NULL, out_path = NULL,

message("Loading '", file, "'.")

out[[i]] <- read_mgf_chunks(filepath = filepath,
temp_dir = temp_dir,
raw_id = i,
topn_ms2ions = topn_ms2ions,
ms1_charge_range = ms1_charge_range,
ms1_scan_range = ms1_scan_range,
ret_range = ret_range,
min_mass = min_mass,
max_mass = max_mass,
ppm_ms1 = ppm_ms1,
ppm_ms2 = ppm_ms2,
min_ms2mass = min_ms2mass,
max_ms2mass = max_ms2mass,
mgf_cutmzs = mgf_cutmzs,
mgf_cutpercs = mgf_cutpercs,
type_mgf = type_mgf,
n_bf_begin = n_bf_begin,
n_spacer = n_spacer,
n_hdr = n_hdr,
n_to_pepmass = n_to_pepmass,
n_to_title = n_to_title,
n_to_scan = n_to_scan,
n_to_rt = n_to_rt,
n_to_charge = n_to_charge,
sep_ms2s = sep_ms2s,
nfields_ms2s = nfields_ms2s,
sep_pepmass = sep_pepmass,
nfields_pepmass = nfields_pepmass,
raw_file = raw_files[[i]],
tmt_reporter_lower = tmt_reporter_lower,
tmt_reporter_upper = tmt_reporter_upper,
exclude_reporter_region = exclude_reporter_region,
use_defpeaks = use_defpeaks,
deisotope_ms2 = deisotope_ms2,
max_ms2_charge = max_ms2_charge,
maxn_dia_precurs = maxn_dia_precurs,
maxn_mdda_precurs = maxn_mdda_precurs,
n_mdda_flanks = n_mdda_flanks,
ppm_ms1_deisotope = ppm_ms1_deisotope,
ppm_ms2_deisotope = ppm_ms2_deisotope,
quant = quant,
digits = digits)
out[[i]] <- read_mgf_chunks(
filepath = filepath,
temp_dir = temp_dir,
raw_id = i,
topn_ms2ions = topn_ms2ions,
ms1_charge_range = ms1_charge_range,
ms1_scan_range = ms1_scan_range,
ret_range = ret_range,
min_mass = min_mass,
max_mass = max_mass,
ppm_ms1 = ppm_ms1,
ppm_ms2 = ppm_ms2,
min_ms2mass = min_ms2mass,
max_ms2mass = max_ms2mass,
mgf_cutmzs = mgf_cutmzs,
mgf_cutpercs = mgf_cutpercs,
type_mgf = type_mgf,
n_bf_begin = n_bf_begin,
n_spacer = n_spacer,
n_hdr = n_hdr,
n_to_pepmass = n_to_pepmass,
n_to_title = n_to_title,
n_to_scan = n_to_scan,
n_to_rt = n_to_rt,
n_to_charge = n_to_charge,
sep_ms2s = sep_ms2s,
nfields_ms2s = nfields_ms2s,
sep_pepmass = sep_pepmass,
nfields_pepmass = nfields_pepmass,
raw_file = raw_files[[i]],
tmt_reporter_lower = tmt_reporter_lower,
tmt_reporter_upper = tmt_reporter_upper,
exclude_reporter_region = exclude_reporter_region,
use_defpeaks = use_defpeaks,
deisotope_ms2 = deisotope_ms2,
max_ms2_charge = max_ms2_charge,
maxn_dia_precurs = maxn_dia_precurs,
maxn_mdda_precurs = maxn_mdda_precurs,
n_mdda_flanks = n_mdda_flanks,
ppm_ms1_deisotope = ppm_ms1_deisotope,
ppm_ms2_deisotope = ppm_ms2_deisotope,
quant = quant,
digits = digits)

local({
dir2 <- file.path(filepath, gsub("\\.[^.]*$", "", file))
Expand Down Expand Up @@ -550,8 +551,7 @@ read_mgf_chunks <- function (filepath, temp_dir, raw_id = 1L,
ppm_ms1_deisotope = ppm_ms1_deisotope,
ppm_ms2_deisotope = ppm_ms2_deisotope,
quant = quant,
digits = digits
)
digits = digits)
}
else {
n_cores <- min(detect_cores(32L), len)
Expand All @@ -576,47 +576,48 @@ read_mgf_chunks <- function (filepath, temp_dir, raw_id = 1L,
envir = environment(mzion::matchMS)
)

out <- parallel::clusterApply(cl, file.path(temp_dir, filelist),
proc_mgf_chunks,
topn_ms2ions = topn_ms2ions,
ms1_charge_range = ms1_charge_range,
ms1_scan_range = ms1_scan_range,
ret_range = ret_range,
min_mass = min_mass,
max_mass = max_mass,
ppm_ms1 = ppm_ms1,
ppm_ms2 = ppm_ms2,
min_ms2mass = min_ms2mass,
max_ms2mass = max_ms2mass,
mgf_cutmzs = mgf_cutmzs,
mgf_cutpercs = mgf_cutpercs,
type_mgf = type_mgf,
n_bf_begin = n_bf_begin,
n_spacer = n_spacer,
n_hdr = n_hdr,
n_to_pepmass = n_to_pepmass,
n_to_title = n_to_title,
n_to_scan = n_to_scan,
n_to_rt = n_to_rt,
n_to_charge = n_to_charge,
sep_ms2s = sep_ms2s,
nfields_ms2s = nfields_ms2s,
sep_pepmass = sep_pepmass,
nfields_pepmass = nfields_pepmass,
raw_file = raw_file,
tmt_reporter_lower = tmt_reporter_lower,
tmt_reporter_upper = tmt_reporter_upper,
exclude_reporter_region = exclude_reporter_region,
deisotope_ms2 = deisotope_ms2,
max_ms2_charge = max_ms2_charge,
use_defpeaks = use_defpeaks,
maxn_dia_precurs = maxn_dia_precurs,
maxn_mdda_precurs = maxn_mdda_precurs,
n_mdda_flanks = n_mdda_flanks,
ppm_ms1_deisotope = ppm_ms1_deisotope,
ppm_ms2_deisotope = ppm_ms2_deisotope,
quant = quant,
digits = digits)
out <- parallel::clusterApply(
cl, file.path(temp_dir, filelist),
proc_mgf_chunks,
topn_ms2ions = topn_ms2ions,
ms1_charge_range = ms1_charge_range,
ms1_scan_range = ms1_scan_range,
ret_range = ret_range,
min_mass = min_mass,
max_mass = max_mass,
ppm_ms1 = ppm_ms1,
ppm_ms2 = ppm_ms2,
min_ms2mass = min_ms2mass,
max_ms2mass = max_ms2mass,
mgf_cutmzs = mgf_cutmzs,
mgf_cutpercs = mgf_cutpercs,
type_mgf = type_mgf,
n_bf_begin = n_bf_begin,
n_spacer = n_spacer,
n_hdr = n_hdr,
n_to_pepmass = n_to_pepmass,
n_to_title = n_to_title,
n_to_scan = n_to_scan,
n_to_rt = n_to_rt,
n_to_charge = n_to_charge,
sep_ms2s = sep_ms2s,
nfields_ms2s = nfields_ms2s,
sep_pepmass = sep_pepmass,
nfields_pepmass = nfields_pepmass,
raw_file = raw_file,
tmt_reporter_lower = tmt_reporter_lower,
tmt_reporter_upper = tmt_reporter_upper,
exclude_reporter_region = exclude_reporter_region,
deisotope_ms2 = deisotope_ms2,
max_ms2_charge = max_ms2_charge,
use_defpeaks = use_defpeaks,
maxn_dia_precurs = maxn_dia_precurs,
maxn_mdda_precurs = maxn_mdda_precurs,
n_mdda_flanks = n_mdda_flanks,
ppm_ms1_deisotope = ppm_ms1_deisotope,
ppm_ms2_deisotope = ppm_ms2_deisotope,
quant = quant,
digits = digits)

parallel::stopCluster(cl)

Expand Down
10 changes: 8 additions & 2 deletions R/msmsmatches.R
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,8 @@ matchMS <- function (out_path = "~/mzion/outs",
nes_fdr_group = nes_fdr_group,
out_path = out_path)

ans <- post_pepfdr(prob_cos, out_path)
ans <- post_pepfdr(prob_cos = prob_cos, maxn_mdda_precurs = maxn_mdda_precurs,
n_13c = n_13c, out_path = out_path)

if (svm_reproc) {
message("SVM reprocessing of peptide probabilities.")
Expand Down Expand Up @@ -1543,7 +1544,8 @@ matchMS <- function (out_path = "~/mzion/outs",
locmods = locmods,
is_notched = is_notched,
topn_mods_per_seq = topn_mods_per_seq,
topn_seqs_per_query = topn_seqs_per_query)
topn_seqs_per_query = topn_seqs_per_query,
maxn_mdda_precurs = maxn_mdda_precurs)
}

## Protein accessions
Expand Down Expand Up @@ -1608,6 +1610,10 @@ matchMS <- function (out_path = "~/mzion/outs",
qs::qsave(df, file_protfdr, preset = "fast")
}

# second removals after combining pep_mod_group's
df <- rm_dup13c(df, maxn_mdda_precurs = maxn_mdda_precurs, n_13c = n_13c)

# add optional reporters
df <- add_rptrs(df, quant, out_path)

## Clean-ups
Expand Down
Loading

0 comments on commit d395f8f

Please sign in to comment.