annotate moulinetteJF/retraitement_MSpurity_V4.R @ 0:67733206be53 draft

" master branch Updating"
author lain
date Thu, 14 Apr 2022 10:23:15 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
67733206be53 " master branch Updating"
lain
parents:
diff changeset
1 ## read and process mspurity W4M files
67733206be53 " master branch Updating"
lain
parents:
diff changeset
2 ## create a summary of fragment for each precursor and a graphics of peseudo spectra + correlation on which checking of fragment is based on
67733206be53 " master branch Updating"
lain
parents:
diff changeset
3 ## V3 try to identify and process multiple files for 1 precursor which may occur if different collision energy are used
67733206be53 " master branch Updating"
lain
parents:
diff changeset
4 ## V4 elimination of correlation = NA. Correlation is done with precursor, if precursor is not present correlation with most intense peak
67733206be53 " master branch Updating"
lain
parents:
diff changeset
5
67733206be53 " master branch Updating"
lain
parents:
diff changeset
6 ##require(msPurity)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
7
67733206be53 " master branch Updating"
lain
parents:
diff changeset
8 ###########################################################################################
67733206be53 " master branch Updating"
lain
parents:
diff changeset
9
67733206be53 " master branch Updating"
lain
parents:
diff changeset
10 plot_pseudoSpectra <- function(x, fid, sumInt, vmz, corAbsInt, refcol, cNAME) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
11 ## function to compute sum of intensities among scans for all m/z kept (cor > r_threshold & minimum number of scans)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
12 ## and plot pseudo spectra
67733206be53 " master branch Updating"
lain
parents:
diff changeset
13 ## x dataframe scan X fragments with scans number in the 1st column and ions in next with intensities
67733206be53 " master branch Updating"
lain
parents:
diff changeset
14 ## fid file id when several a precursor has been detected in several files
67733206be53 " master branch Updating"
lain
parents:
diff changeset
15 # du fait de la difference de nombre de colonne entre la dataframe qui inclue les scans en 1ere col, mzRef se decale de 1
67733206be53 " master branch Updating"
lain
parents:
diff changeset
16 refcol <- refcol-1
67733206be53 " master branch Updating"
lain
parents:
diff changeset
17 ## compute relative intensities max=100%
67733206be53 " master branch Updating"
lain
parents:
diff changeset
18 relInt <- sumInt[-1]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
19 relInt <- relInt/max(relInt)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
20
67733206be53 " master branch Updating"
lain
parents:
diff changeset
21 ## define max value on vertical axis (need to increase in order to plot the label of fragments)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
22 ymax <- max(relInt)+0.2*max(relInt)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
23
67733206be53 " master branch Updating"
lain
parents:
diff changeset
24 par(mfrow=c(2,1))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
25 plot(vmz, relInt, type="h", ylim=c(0,ymax), main = cNAME)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
26 ## low correl coef. will be display in grey
67733206be53 " master branch Updating"
lain
parents:
diff changeset
27 corLow <- which(round(corAbsInt,2) < r_threshold)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
28
67733206be53 " master branch Updating"
lain
parents:
diff changeset
29 lbmzcor <- paste(as.character(vmz),"(r=",round(corAbsInt,2),")", sep="")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
30
67733206be53 " master branch Updating"
lain
parents:
diff changeset
31 if (length(corLow) > 0) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
32 text(vmz[corLow], relInt[corLow], lbmzcor[corLow], cex=0.5, col = "grey", srt = 90 , adj=0)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
33 if (length(vmz) - length(corLow) > 1) text(vmz[-c(refcol,corLow)], relInt[-c(refcol,corLow)], lbmzcor[-c(refcol,corLow)], cex=0.6, col = 1, srt = 90 , adj=0)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
34 } else {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
35 if (length(vmz) > 1) text(vmz[-c(refcol)], relInt[-c(refcol)], lbmzcor[-c(refcol)], cex=0.6, col = 1, srt = 90 , adj=0)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
36 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
37
67733206be53 " master branch Updating"
lain
parents:
diff changeset
38 text(vmz[refcol], relInt[refcol], lbmzcor[refcol], cex=0.8, col = 2, srt = 90, adj=0 )
67733206be53 " master branch Updating"
lain
parents:
diff changeset
39
67733206be53 " master branch Updating"
lain
parents:
diff changeset
40 ## prepare result file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
41 corValid <- (round(corAbsInt,2) >= r_threshold)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
42 cpRes <- data.frame(rep(cNAME, length(vmz)),
67733206be53 " master branch Updating"
lain
parents:
diff changeset
43 rep(fid, length(vmz)),
67733206be53 " master branch Updating"
lain
parents:
diff changeset
44 vmz,corAbsInt,sumInt[-1],relInt,corValid)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
45
67733206be53 " master branch Updating"
lain
parents:
diff changeset
46 colnames(cpRes) <- c("compoundName","fileid","fragments_mz","CorWithPrecursor","AbsoluteIntensity","relativeIntensity","corValid")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
47 return(cpRes)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
48
67733206be53 " master branch Updating"
lain
parents:
diff changeset
49 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
50
67733206be53 " master branch Updating"
lain
parents:
diff changeset
51 ## function for extraction of fragments corresponding to precursors detected by MSPurity
67733206be53 " master branch Updating"
lain
parents:
diff changeset
52 Xtract_fragments <- function(mzref, rtref, cNAME, r_threshold = 0.85, seuil_ra = 0.1, tolmz = 0.01, tolrt = 60) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
53
67733206be53 " master branch Updating"
lain
parents:
diff changeset
54 ## filter precursor in the precursors file based on mz and rt in the compound list
67733206be53 " master branch Updating"
lain
parents:
diff changeset
55 cat("processing ",cNAME,"\n")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
56 selprec <- which((abs(prec$precurMtchMZ - mzref) <= tolmz) & (abs(prec$precurMtchRT - rtref) <= tolrt))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
57
67733206be53 " master branch Updating"
lain
parents:
diff changeset
58 ## check if there is the precursor in the file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
59 if (length(selprec) > 0) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
60
67733206be53 " master branch Updating"
lain
parents:
diff changeset
61 sprecini <- prec[selprec,]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
62
67733206be53 " master branch Updating"
lain
parents:
diff changeset
63 ## check if fragments corresponding to precursor are found in several files (collision energy)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
64 ## this lead to a processing for each fileid
67733206be53 " master branch Updating"
lain
parents:
diff changeset
65 mf <- levels(as.factor(sprecini$fileid))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
66 nbf <- length(mf)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
67 if (nbf > 1) cat(" several files detected for this compounds :\n")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
68
67733206be53 " master branch Updating"
lain
parents:
diff changeset
69 for (f in 1:nbf) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
70
67733206be53 " master branch Updating"
lain
parents:
diff changeset
71 sprec <- sprecini[sprecini$fileid == mf[f],]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
72
67733206be53 " master branch Updating"
lain
parents:
diff changeset
73 ## selection of fragment in the fragments file with the grpid common in both fragments and precursors
67733206be53 " master branch Updating"
lain
parents:
diff changeset
74 selfrgt <- levels(as.factor(sprec$grpid))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
75 sfrgt <- frgt[frgt$grpid %in% selfrgt & frgt$fileid == mf[f],]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
76
67733206be53 " master branch Updating"
lain
parents:
diff changeset
77 ## filter fragments on relative intensity seuil_ra = user defined parameter (MSpurity flags could be used here)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
78 sfrgtfil <- sfrgt[sfrgt$ra > seuil_ra,]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
79
67733206be53 " master branch Updating"
lain
parents:
diff changeset
80 mznominal <- round(x = sfrgtfil$mz, mzdecimal)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
81 sfrgtfil <- data.frame(sfrgtfil, mznominal)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
82
67733206be53 " master branch Updating"
lain
parents:
diff changeset
83 ## creation of cross table row=scan col=mz X=ra
67733206be53 " master branch Updating"
lain
parents:
diff changeset
84 vmz <- levels(as.factor(sfrgtfil$mznominal))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
85 #fscan <- levels(as.factor(sfrgtfil$acquisitionNum))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
86
67733206be53 " master branch Updating"
lain
parents:
diff changeset
87 cat(" fragments :",vmz)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
88 # dsIntra <- matrix(NA,nrow = length(vscan), ncol = length(vmz))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
89 # rownames(dsIntra) <- fscan
67733206be53 " master branch Updating"
lain
parents:
diff changeset
90 # dsIntra <- data.frame(fscan,dsIntra)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
91 # colnames(dsIntra) <- c("fscan",vmz)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
92
67733206be53 " master branch Updating"
lain
parents:
diff changeset
93 ## mz of precursor in data precursor to check correlation with
67733206be53 " master branch Updating"
lain
parents:
diff changeset
94 mzPrec <- paste("mz",round(mean(sprec$mz),mzdecimal),sep="")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
95
67733206be53 " master branch Updating"
lain
parents:
diff changeset
96 for (m in 1:length(vmz)) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
97
67733206be53 " master branch Updating"
lain
parents:
diff changeset
98 ## absolute intensity
67733206be53 " master branch Updating"
lain
parents:
diff changeset
99 cln <- c(which(colnames(sfrgtfil) == "acquisitionNum"), which(colnames(sfrgtfil) == "i"))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
100 int_mz <- sfrgtfil[sfrgtfil$mznominal == vmz[m], cln]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
101 colnames(int_mz)[2] <- paste("mz", vmz[m], sep="")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
102
67733206be53 " master branch Updating"
lain
parents:
diff changeset
103 ## average intensities of mass in duplicate scans
67733206be53 " master branch Updating"
lain
parents:
diff changeset
104 compScans <- aggregate(x = int_mz, by = list(int_mz[[1]]), FUN = mean)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
105 int_mz <- compScans[,-1]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
106
67733206be53 " master branch Updating"
lain
parents:
diff changeset
107 if (m == 1) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
108 dsAbsInt <- int_mz
67733206be53 " master branch Updating"
lain
parents:
diff changeset
109 #dsRelInt <- ra_mz
67733206be53 " master branch Updating"
lain
parents:
diff changeset
110 } else {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
111 dsAbsInt <- merge(x = dsAbsInt, y = int_mz, by.x = 1, by.y = 1, all.x=TRUE, all.y=TRUE)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
112 #dsRelInt <- merge(x = dsRelInt, y = ra_mz, by.x = 1, by.y = 1, all.x=TRUE, all.y=TRUE)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
113
67733206be53 " master branch Updating"
lain
parents:
diff changeset
114 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
115 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
116 ## for debug
67733206be53 " master branch Updating"
lain
parents:
diff changeset
117 ## write.table(x = dsAbsInt,file=paste(cNAME,"dsAbsInt.txt",sep=""), row.names = FALSE, sep="\t")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
118
67733206be53 " master branch Updating"
lain
parents:
diff changeset
119 ## elimination of mz with less than minNumberScan scans (user defined parameter)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
120 xmz <- rep(NA,ncol(dsAbsInt)-1)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
121 sumInt <- rep(NA,ncol(dsAbsInt))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
122 nbxmz <- 0
67733206be53 " master branch Updating"
lain
parents:
diff changeset
123 NbScanCheck <- min(nrow(dsAbsInt),minNumberScan)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
124
67733206be53 " master branch Updating"
lain
parents:
diff changeset
125 for (j in 2:ncol(dsAbsInt)) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
126 sumInt[j] <- sum(dsAbsInt[j],na.rm = TRUE)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
127 if (sum(!is.na(dsAbsInt[[j]])) < NbScanCheck) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
128 nbxmz <- nbxmz + 1
67733206be53 " master branch Updating"
lain
parents:
diff changeset
129 xmz[nbxmz] <- j
67733206be53 " master branch Updating"
lain
parents:
diff changeset
130 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
131 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
132
67733206be53 " master branch Updating"
lain
parents:
diff changeset
133 xmz <- xmz[-which(is.na(xmz))]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
134 if (length(xmz) > 0) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
135 dsAbsInt <- dsAbsInt[,-c(xmz)]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
136 sumInt <- sumInt[-c(xmz)]
67733206be53 " master branch Updating"
lain
parents:
diff changeset
137 ## liste des mz keeped decale de 1 avec dsAbsInt
67733206be53 " master branch Updating"
lain
parents:
diff changeset
138 vmz <- as.numeric(vmz[-c(xmz-1)])
67733206be53 " master branch Updating"
lain
parents:
diff changeset
139 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
140
67733206be53 " master branch Updating"
lain
parents:
diff changeset
141 ## reference ion for correlation computing = precursor OR maximum intensity ion in precursor is not present
67733206be53 " master branch Updating"
lain
parents:
diff changeset
142 refcol <- which(colnames(dsAbsInt) == mzPrec)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
143 if (length(refcol) == 0) refcol <- which(sumInt == max(sumInt, na.rm = TRUE))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
144
67733206be53 " master branch Updating"
lain
parents:
diff changeset
145 pdf(file=paste(cNAME,"_processing_file",mf[f],".pdf",sep=""), width = 8, height = 11 ); par(mfrow=c(3,2))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
146
67733206be53 " master branch Updating"
lain
parents:
diff changeset
147 ## pearson correlations between absolute intensities computing
67733206be53 " master branch Updating"
lain
parents:
diff changeset
148 corAbsInt <- rep(NA,length(vmz))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
149
67733206be53 " master branch Updating"
lain
parents:
diff changeset
150 if (length(refcol) > 0) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
151 for (i in 2:length(dsAbsInt)) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
152 corAbsInt[i-1] <- cor(x = dsAbsInt[[refcol]], y=dsAbsInt[[i]], use = "pairwise.complete.obs", method = "pearson")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
153 plot(dsAbsInt[[refcol]],dsAbsInt[[i]],
67733206be53 " master branch Updating"
lain
parents:
diff changeset
154 xlab = colnames(dsAbsInt)[refcol], ylab=colnames(dsAbsInt)[i],
67733206be53 " master branch Updating"
lain
parents:
diff changeset
155 main=paste(cNAME," corr coeff r=",round(corAbsInt[i-1],2),sep=""))
67733206be53 " master branch Updating"
lain
parents:
diff changeset
156 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
157 ## plot pseudo spectra
67733206be53 " master branch Updating"
lain
parents:
diff changeset
158 resCompByfile <- plot_pseudoSpectra(x= dsAbsInt, fid = mf[f], sumInt = sumInt, vmz = vmz, corAbsInt = corAbsInt, refcol = refcol, cNAME = cNAME )
67733206be53 " master branch Updating"
lain
parents:
diff changeset
159 if (f == 1) resComp <- resCompByfile
67733206be53 " master branch Updating"
lain
parents:
diff changeset
160 } else {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
161 resCompByfile <- NULL
67733206be53 " master branch Updating"
lain
parents:
diff changeset
162 cat(" non detected in fragments file \n")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
163 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
164 if (!is.null(resCompByfile)) resComp <- rbind(resComp,resCompByfile)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
165 cat("\n")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
166 dev.off()
67733206be53 " master branch Updating"
lain
parents:
diff changeset
167 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
168 } else {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
169 resComp <- NULL
67733206be53 " master branch Updating"
lain
parents:
diff changeset
170 cat(" non detected in precursor file \n")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
171 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
172
67733206be53 " master branch Updating"
lain
parents:
diff changeset
173 return(resComp)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
174 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
175
67733206be53 " master branch Updating"
lain
parents:
diff changeset
176
67733206be53 " master branch Updating"
lain
parents:
diff changeset
177 #################################### start #######################################################
67733206be53 " master branch Updating"
lain
parents:
diff changeset
178
67733206be53 " master branch Updating"
lain
parents:
diff changeset
179 ## FOLDER AND FILES
67733206be53 " master branch Updating"
lain
parents:
diff changeset
180 setwd(dir = "C:/Users/jfmartin/Documents/PROJETS/PROG/tools_R/MSPurity/positif2/V2")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
181
67733206be53 " master branch Updating"
lain
parents:
diff changeset
182 #load("Galaxy541-[msPurity.filterFragSpectra_on_data_540__RData].rdata")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
183
67733206be53 " master branch Updating"
lain
parents:
diff changeset
184 ## MSpurity precursors file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
185 prec <- read.table(file = "msPurity.filterFragSpectra_on_data_60__peaklist_precursors.tsv",
67733206be53 " master branch Updating"
lain
parents:
diff changeset
186 header = TRUE, sep="\t")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
187
67733206be53 " master branch Updating"
lain
parents:
diff changeset
188 ## MSpurity fragments file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
189 frgt <- read.table(file = "msPurity.filterFragSpectra_on_data_60__peaklist_fragments.tsv",
67733206be53 " master branch Updating"
lain
parents:
diff changeset
190 header = TRUE, sep="\t")
67733206be53 " master branch Updating"
lain
parents:
diff changeset
191
67733206be53 " master branch Updating"
lain
parents:
diff changeset
192 ## list of compounds : col1=Name of molecule, col2=m/z, col3=retention time
67733206be53 " master branch Updating"
lain
parents:
diff changeset
193 compounds <- read.table(file = "compounds_pos.txt", sep="\t", header = TRUE)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
194
67733206be53 " master branch Updating"
lain
parents:
diff changeset
195 ## PARAMETERS
67733206be53 " master branch Updating"
lain
parents:
diff changeset
196 ## tolerance for mz(dalton) rt(seconds) to match the standard in the compounds list with the precursor MSpurity file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
197 tolmz <- 0.01
67733206be53 " master branch Updating"
lain
parents:
diff changeset
198 tolrt <- 20
67733206be53 " master branch Updating"
lain
parents:
diff changeset
199
67733206be53 " master branch Updating"
lain
parents:
diff changeset
200 ## relative intensity threshold
67733206be53 " master branch Updating"
lain
parents:
diff changeset
201 seuil_ra = 0.05
67733206be53 " master branch Updating"
lain
parents:
diff changeset
202 ## nb decimal for mz
67733206be53 " master branch Updating"
lain
parents:
diff changeset
203 mzdecimal <- 0
67733206be53 " master branch Updating"
lain
parents:
diff changeset
204 ## r pearson correlation threshold between precursor and fragment absolute intensity
67733206be53 " master branch Updating"
lain
parents:
diff changeset
205 r_threshold <- 0.85
67733206be53 " master branch Updating"
lain
parents:
diff changeset
206 ## fragments are kept if there are found in a minimum number of scans
67733206be53 " master branch Updating"
lain
parents:
diff changeset
207 minNumberScan <- 8
67733206be53 " master branch Updating"
lain
parents:
diff changeset
208
67733206be53 " master branch Updating"
lain
parents:
diff changeset
209 for (i in 1:nrow(compounds)) {
67733206be53 " master branch Updating"
lain
parents:
diff changeset
210 ## loop execution for all compounds in the compounds file
67733206be53 " master branch Updating"
lain
parents:
diff changeset
211 resCor <- NULL
67733206be53 " master branch Updating"
lain
parents:
diff changeset
212 resCor <- Xtract_fragments(mzref = compounds[[2]][i],
67733206be53 " master branch Updating"
lain
parents:
diff changeset
213 rtref = compounds[[3]][i] * 60,
67733206be53 " master branch Updating"
lain
parents:
diff changeset
214 cNAME = compounds[[1]][i],
67733206be53 " master branch Updating"
lain
parents:
diff changeset
215 r_threshold, seuil_ra, tolmz, tolrt)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
216 if (i == 1 & !is.null(resCor)) resAll <- resCor else if (!is.null(resCor)) resAll <- rbind(resAll,resCor)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
217
67733206be53 " master branch Updating"
lain
parents:
diff changeset
218 }
67733206be53 " master branch Updating"
lain
parents:
diff changeset
219
67733206be53 " master branch Updating"
lain
parents:
diff changeset
220 write.table(x = resAll, file = "compound_fragments_result.txt", sep="\t", row.names = FALSE)
67733206be53 " master branch Updating"
lain
parents:
diff changeset
221
67733206be53 " master branch Updating"
lain
parents:
diff changeset
222 ######################################## end call ################################################
67733206be53 " master branch Updating"
lain
parents:
diff changeset
223