Skip to content

Commit 0bc041a

Browse files
committed
v1.1
1 parent 24f2529 commit 0bc041a

27 files changed

+727
-579
lines changed
Loading

IDSL.CSA.wiki

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit b1ddbe2c6cf7d33ef3d809100c6122020f3efa3d
1+
Subproject commit d1e4d3d852a4ad8fdc6f4a1eaa9a46826fe6e8fd

IDSL.CSA/DESCRIPTION

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
Package: IDSL.CSA
22
Type: Package
3-
Title: Composite Spectra Analysis (CSA) for High-Resolution Mass
4-
Spectrometry Analyses
5-
Version: 1.0
3+
Title: Composite Spectra Analysis (CSA) for High-Resolution Mass Spectrometry Analyses
4+
Version: 1.1
65
Authors@R: c(
76
person(family = "Fakouri-Baygi", given = "Sadjad", email = "[email protected]",
8-
role = c("cre","aut"), comment = c(ORCID = "0000-0002-6864-6911")),
9-
person(family = "Barupal", given = "Dinesh", email = "dinesh.kumar@mssm.edu", role = "aut",
7+
role = "aut", comment = c(ORCID = "0000-0002-6864-6911")),
8+
person(family = "Barupal", given = "Dinesh", email = "dinesh.barupal@mssm.edu", role = c("cre","aut"),
109
comment = c(ORCID = "0000-0002-9954-8628")))
1110
Depends: R (>= 4.0)
12-
Imports: IDSL.MXP (>= 1.8), IDSL.IPA (>= 2.6), IDSL.FSA, doParallel,
13-
foreach, readxl
14-
Author: Sadjad Fakouri-Baygi [cre, aut] (<https://orcid.org/0000-0002-6864-6911>),
15-
Dinesh Barupal [aut] (<https://orcid.org/0000-0002-9954-8628>)
16-
Maintainer: Sadjad Fakouri-Baygi <[email protected]>
17-
Description: A fragmentation spectra detection pipeline for high-throughput LC/HRMS data processing using peaklists generated by the 'IDSL.IPA' package. The 'IDSL.CSA' package can deconvolute fragmentation spectra from Composite Spectra Analysis (CSA), Data Dependent Acquisition (DDA) analysis, and various Data-Independent Acquisition (DIA) methods such as MS^E, All-Ion Fragmentation (AIF) and SWATH analysis.
11+
Imports: IDSL.MXP, IDSL.IPA, IDSL.FSA, readxl
12+
Author: Sadjad Fakouri-Baygi [aut] (<https://orcid.org/0000-0002-6864-6911>),
13+
Dinesh Barupal [cre, aut] (<https://orcid.org/0000-0002-9954-8628>)
14+
Maintainer: Dinesh Barupal <[email protected]>
15+
Description: A fragmentation spectra detection pipeline for high-throughput LC/HRMS data processing using peaklists generated by the 'IDSL.IPA' workflow <doi:10.1021/acs.jproteome.2c00120>. The 'IDSL.CSA' package can deconvolute fragmentation spectra from Composite Spectra Analysis (CSA), Data Dependent Acquisition (DDA) analysis, and various Data-Independent Acquisition (DIA) methods such as MS^E, All-Ion Fragmentation (AIF) and SWATH-MS analysis. The 'IDSL.CSA' package was introduced in <doi:10.1101/2023.02.09.527886>.
1816
License: MIT + file LICENSE
1917
URL: https://github.com/idslme/idsl.csa
2018
BugReports: https://github.com/idslme/idsl.csa/issues
2119
Encoding: UTF-8
2220
Archs: i386, x64
23-
NeedsCompilation: no
24-
Packaged: 2023-01-21 00:41:52 UTC; sfbaygi

IDSL.CSA/NAMESPACE

-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import(IDSL.MXP)
33
import(IDSL.IPA)
44
import(IDSL.FSA)
55
import(parallel)
6-
import(doParallel)
7-
import(foreach)
8-
import(readxl)
96
import(stats)
107
importFrom("graphics", "legend", "lines", "mtext", "par", "text")
118
importFrom("grDevices", "png", "dev.off", "rainbow")

IDSL.CSA/R/CSA_AlignedTable_xlsxAnalyzer.R

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
CSA_AlignedTable_xlsxAnalyzer <- function(spreadsheet) {
22
##
33
checkpoint_parameter <- FALSE
4-
#
5-
if (length(spreadsheet) >= 4) {
6-
if (typeof(spreadsheet) == "list") {
4+
##
5+
if (typeof(spreadsheet) == "list") {
6+
if (ncol(spreadsheet) >= 4) {
77
PARAM_AT <- cbind(spreadsheet[, 2], spreadsheet[, 4])
88
checkpoint_parameter <- TRUE
9+
##
10+
} else if (ncol(spreadsheet) == 2) {
11+
PARAM_AT <- spreadsheet
12+
checkpoint_parameter <- TRUE
13+
##
914
} else {
1015
FSA_message("The `AlignedTable` spreadsheet tab was not produced properly!")
1116
}
12-
} else if (length(spreadsheet) == 1) {
13-
if (typeof(spreadsheet) == "character") {
17+
} else if (typeof(spreadsheet) == "character") {
18+
if (length(spreadsheet) == 1) {
1419
if (file.exists(spreadsheet)) {
1520
PARAM_AT <- readxl::read_xlsx(spreadsheet, sheet = "AlignedTable")
1621
PARAM_AT <- cbind(PARAM_AT[, 2], PARAM_AT[, 4])
@@ -24,9 +29,9 @@ CSA_AlignedTable_xlsxAnalyzer <- function(spreadsheet) {
2429
} else {
2530
FSA_message("The `AlignedTable` spreadsheet tab was not produced properly!")
2631
}
27-
##
32+
##############################################################################
2833
if (checkpoint_parameter) {
29-
############################################################################
34+
##
3035
listAlignmentFolderCheck <- IPA_peak_alignment_folder_xlsxAnalyzer(PARAM_AT, PARAM_ID = 'AT0001', checkpoint_parameter, correctedRTcheck = FALSE, CSAcheck = FALSE)
3136
PARAM_AT <- listAlignmentFolderCheck[[1]]
3237
checkpoint_parameter <- listAlignmentFolderCheck[[2]]

IDSL.CSA/R/CSA_alignedMetaSpectraCataloger.R

+25-19
Original file line numberDiff line numberDiff line change
@@ -199,46 +199,52 @@ CSA_alignedMetaSpectraCataloger <- function(address_input_msp, peakXcol, peak_he
199199
##
200200
osType <- Sys.info()[['sysname']]
201201
##
202-
if (osType == "Linux") {
202+
if (osType == "Windows") {
203203
##
204-
##########################################################################
204+
############################################################################
205205
##
206-
MSPvectorAverage <- do.call(c, mclapply(1:length(xsDiff1), function(i) {
206+
clust <- makeCluster(number_processing_threads)
207+
clusterExport(clust, setdiff(ls(), c("clust")), envir = environment())
208+
##
209+
MSPvectorAverage <- do.call(c, parLapply(clust, 1:length(xsDiff1), function(i) {
207210
call_MSPvectorAverage(i)
208-
}, mc.cores = number_processing_threads))
209-
CSA_aligned_property_table <- NULL
211+
}))
210212
##
211-
##########################################################################
213+
stopCluster(clust)
212214
##
213-
MSPvectorMAX <- do.call(c, mclapply(1:length(xsDiff1), function(i) {
214-
call_MSPvectorMAX(i)
215-
}, mc.cores = number_processing_threads))
215+
CSA_aligned_property_table <- NULL
216216
##
217-
##########################################################################
217+
############################################################################
218218
##
219-
closeAllConnections()
219+
clust <- makeCluster(number_processing_threads)
220+
clusterExport(clust, setdiff(ls(), c("clust")), envir = environment())
220221
##
221-
} else if (osType == "Windows") {
222+
MSPvectorMAX <- do.call(c, parLapply(clust, 1:length(xsDiff1), function(i) {
223+
call_MSPvectorMAX(i)
224+
}))
222225
##
223-
clust <- makeCluster(number_processing_threads)
224-
registerDoParallel(clust)
226+
stopCluster(clust)
227+
############################################################################
228+
##
229+
} else {
225230
##
226231
##########################################################################
227232
##
228-
MSPvectorAverage <- foreach(i = 1:length(xsDiff1), .combine = 'c', .verbose = FALSE) %dopar% {
233+
MSPvectorAverage <- do.call(c, mclapply(1:length(xsDiff1), function(i) {
229234
call_MSPvectorAverage(i)
230-
}
235+
}, mc.cores = number_processing_threads))
231236
CSA_aligned_property_table <- NULL
232237
##
233238
##########################################################################
234239
##
235-
MSPvectorMAX <- foreach(i = 1:length(xsDiff1), .combine = 'c', .verbose = FALSE) %dopar% {
240+
MSPvectorMAX <- do.call(c, mclapply(1:length(xsDiff1), function(i) {
236241
call_MSPvectorMAX(i)
237-
}
242+
}, mc.cores = number_processing_threads))
238243
##
239244
##########################################################################
240245
##
241-
stopCluster(clust)
246+
closeAllConnections()
247+
##
242248
}
243249
}
244250
##############################################################################

IDSL.CSA/R/CSA_alignedPeaksTanimotoCoefficientCalculator.R

+58-36
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
141141
peakXmsp <- peakXmsp[order(peakXmsp[, 1], decreasing = TRUE), ]
142142
peakXmsp <- peakXmsp[order(peakXmsp[, 2], decreasing = TRUE), ]
143143
##
144+
peakXcol <- NULL
144145
LXDF <- dim(peakXmsp)[1]
145146
##
146147
##########################################################################
@@ -179,24 +180,30 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
179180
##
180181
IDTC <- NULL
181182
}
183+
##
182184
############################################################################
183185
##
184186
} else {
185187
##
186188
osType <- Sys.info()[['sysname']]
187189
##
188-
if (osType == "Linux") {
190+
if (osType == "Windows") {
189191
##
190192
##########################################################################
191193
##
192-
peakXmsp <- do.call(cbind, mclapply(seqMSP, function(i) {
194+
clust <- makeCluster(number_processing_threads)
195+
clusterExport(clust, setdiff(ls(), c("clust", "L_MSP")), envir = environment())
196+
##
197+
peakXmsp <- do.call(cbind, parLapply(clust, 1:L_MSP, function(i) {
193198
iCheck <- i %in% seqMSP
194199
if (iCheck) {
195200
call_peakXmsp(i)
196201
} else {
197202
rep0LpeakXcol
198203
}
199-
}, mc.cores = number_processing_threads))
204+
}))
205+
##
206+
stopCluster(clust)
200207
##
201208
##########################################################################
202209
##
@@ -212,16 +219,22 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
212219
##
213220
########################################################################
214221
##
215-
numberCSAdetFreq <- do.call(c, mclapply(1:L_peakXcol, function(i) {
222+
clust <- makeCluster(number_processing_threads)
223+
clusterExport(clust, c("peakXmsp"), envir = environment())
224+
##
225+
numberCSAdetFreq <- do.call(c, parLapply(clust, 1:L_peakXcol, function(i) {
216226
length(which(peakXmsp[i, ] > 0))
217-
}, mc.cores = number_processing_threads))
227+
}))
228+
##
229+
stopCluster(clust)
218230
##
219231
xDetFreq <- which(numberCSAdetFreq/L_MSP >= minPercenetageDetection/100)
220232
##
221233
peakXmsp <- cbind(xDetFreq, peakXcol[xDetFreq, 2:3], peakXmsp[xDetFreq, ])
222234
peakXmsp <- peakXmsp[order(peakXmsp[, 1], decreasing = TRUE), ]
223235
peakXmsp <- peakXmsp[order(peakXmsp[, 2], decreasing = TRUE), ]
224-
##
236+
##
237+
peakXcol <- NULL
225238
LXDF <- dim(peakXmsp)[1]
226239
##
227240
########################################################################
@@ -232,10 +245,15 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
232245
##
233246
########################################################################
234247
##
235-
peakXlist <- mclapply(1:LXDF, function(i) {
248+
clust <- makeCluster(number_processing_threads)
249+
clusterExport(clust, c("peakXmsp", "Lsamples"), envir = environment())
250+
##
251+
peakXlist <- parLapply(clust, 1:LXDF, function(i) {
236252
px <- peakXmsp[i, 4:Lsamples]
237253
px[px != 0]
238-
}, mc.cores = number_processing_threads)
254+
})
255+
##
256+
stopCluster(clust)
239257
##
240258
names(peakXlist) <- as.character(IDX)
241259
##
@@ -245,33 +263,34 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
245263
##
246264
FSA_logRecorder("Initiated calculating Tanimoto coefficients!")
247265
##
248-
IDTC <- do.call(rbind, mclapply(1:LXDF, function(i) {
266+
clust <- makeCluster(number_processing_threads)
267+
clusterExport(clust, setdiff(ls(), c("clust", "LXDF")), envir = environment())
268+
##
269+
IDTC <- do.call(rbind, parLapply(clust, 1:LXDF, function(i) {
249270
call_IDTC(i)
250-
}, mc.cores = number_processing_threads))
271+
}))
272+
##
273+
stopCluster(clust)
251274
##
252275
} else {
253276
##
254277
IDTC <- NULL
255278
}
256-
##########################################################################
257279
##
258-
closeAllConnections()
259-
##
260-
} else if (osType == "Windows") {
280+
##########################################################################
261281
##
262-
clust <- makeCluster(number_processing_threads)
263-
registerDoParallel(clust)
282+
} else {
264283
##
265284
##########################################################################
266285
##
267-
peakXmsp <- foreach(i = 1:L_MSP, .combine = 'cbind', .verbose = FALSE) %dopar% {
286+
peakXmsp <- do.call(cbind, mclapply(seqMSP, function(i) {
268287
iCheck <- i %in% seqMSP
269288
if (iCheck) {
270289
call_peakXmsp(i)
271290
} else {
272291
rep0LpeakXcol
273292
}
274-
}
293+
}, mc.cores = number_processing_threads))
275294
##
276295
##########################################################################
277296
##
@@ -287,16 +306,17 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
287306
##
288307
########################################################################
289308
##
290-
numberCSAdetFreq <- foreach(i = 1:L_peakXcol, .combine = 'c', .verbose = FALSE) %dopar% {
309+
numberCSAdetFreq <- do.call(c, mclapply(1:L_peakXcol, function(i) {
291310
length(which(peakXmsp[i, ] > 0))
292-
}
311+
}, mc.cores = number_processing_threads))
293312
##
294313
xDetFreq <- which(numberCSAdetFreq/L_MSP >= minPercenetageDetection/100)
295314
##
296315
peakXmsp <- cbind(xDetFreq, peakXcol[xDetFreq, 2:3], peakXmsp[xDetFreq, ])
297316
peakXmsp <- peakXmsp[order(peakXmsp[, 1], decreasing = TRUE), ]
298317
peakXmsp <- peakXmsp[order(peakXmsp[, 2], decreasing = TRUE), ]
299318
##
319+
peakXcol <- NULL
300320
LXDF <- dim(peakXmsp)[1]
301321
##
302322
########################################################################
@@ -307,10 +327,10 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
307327
##
308328
########################################################################
309329
##
310-
peakXlist <- foreach(i = 1:LXDF, .verbose = FALSE) %dopar% {
330+
peakXlist <- mclapply(1:LXDF, function(i) {
311331
px <- peakXmsp[i, 4:Lsamples]
312332
px[px != 0]
313-
}
333+
}, mc.cores = number_processing_threads)
314334
##
315335
names(peakXlist) <- as.character(IDX)
316336
##
@@ -320,17 +340,18 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
320340
##
321341
FSA_logRecorder("Initiated calculating Tanimoto coefficients!")
322342
##
323-
IDTC <- foreach(i = 1:LXDF, .combine = 'rbind', .verbose = FALSE) %dopar% {
343+
IDTC <- do.call(rbind, mclapply(1:LXDF, function(i) {
324344
call_IDTC(i)
325-
}
345+
}, mc.cores = number_processing_threads))
326346
##
327347
} else {
328348
##
329349
IDTC <- NULL
330350
}
331351
##########################################################################
332352
##
333-
stopCluster(clust)
353+
closeAllConnections()
354+
##
334355
}
335356
}
336357
##############################################################################
@@ -391,23 +412,24 @@ CSA_alignedPeaksTanimotoCoefficientCalculator <- function(address_input_msp, pea
391412
##
392413
} else {
393414
##
394-
if (osType == "Linux") {
395-
listXIDTC <- mclapply(1:LidtIDTC, function(i) {
396-
call_listXIDTC(i)
397-
}, mc.cores = number_processing_threads)
398-
##
399-
closeAllConnections()
400-
##
401-
} else if (osType == "Windows") {
415+
if (osType == "Windows") {
402416
##
403417
clust <- makeCluster(number_processing_threads)
404-
registerDoParallel(clust)
418+
clusterExport(clust, c("call_listXIDTC", "idtIDTC", "IDTC"), envir = environment())
405419
##
406-
listXIDTC <- foreach(i = 1:LidtIDTC, .verbose = FALSE) %dopar% {
420+
listXIDTC <- parLapply(clust, 1:LidtIDTC, function(i) {
407421
call_listXIDTC(i)
408-
}
422+
})
409423
##
410424
stopCluster(clust)
425+
##
426+
} else {
427+
listXIDTC <- mclapply(1:LidtIDTC, function(i) {
428+
call_listXIDTC(i)
429+
}, mc.cores = number_processing_threads)
430+
##
431+
closeAllConnections()
432+
##
411433
}
412434
}
413435
##

0 commit comments

Comments
 (0)