Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
shinyscreen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
11
Issues
11
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Environmental Cheminformatics
shinyscreen
Commits
3c08df96
Commit
3c08df96
authored
Aug 21, 2019
by
Adelene Lai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add MS2 intTresh, other WIP
parent
c16af080
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
20 deletions
+43
-20
R/.mix.R.swp
R/.mix.R.swp
+0
-0
R/.run.R.swp
R/.run.R.swp
+0
-0
R/mix.R
R/mix.R
+43
-20
No files found.
R/.mix.R.swp
0 → 100644
View file @
3c08df96
File added
R/.run.R.swp
deleted
100644 → 0
View file @
c16af080
File deleted
R/mix.R
View file @
3c08df96
...
@@ -322,18 +322,20 @@ RMB_EIC_prescreen_df <- function (wd, RMB_mode, FileList, cmpd_list,
...
@@ -322,18 +322,20 @@ RMB_EIC_prescreen_df <- function (wd, RMB_mode, FileList, cmpd_list,
row.names
=
F
)
row.names
=
F
)
}
}
preProc
<-
function
(
fnFileTab
,
fnDest
=
paste
(
stripext
(
fnFileTab
),
"_candidate.csv"
,
sep
=
''
),
noiseFac
=
3
,
rtDelta
=
0.5
,
intTresh
=
1e5
)
{
preProc
<-
function
(
fnFileTab
,
fnDest
=
paste
(
stripext
(
fnFileTab
),
"_candidate.csv"
,
sep
=
''
),
noiseFac
=
3
,
rtDelta
=
0.5
,
ms1_intTresh
=
1e5
,
ms2_intTresh
=
1e4
,
MS1peakWi
=
0.3
)
{
## read in .csv file as file
## read in .csv file as file
ftable
<-
read.csv
(
file
=
fnFileTab
,
header
=
T
,
sep
=
","
,
stringsAsFactors
=
F
)
ftable
<-
read.csv
(
file
=
fnFileTab
,
header
=
T
,
sep
=
","
,
stringsAsFactors
=
F
)
getWidth
<-
function
(
maxid
)
{
log10
(
maxid
)
+1
}
getWidth
<-
function
(
maxid
)
{
log10
(
maxid
)
+1
}
ids
<-
as.numeric
(
levels
(
factor
(
ftable
$
ID
)))
ids
<-
as.numeric
(
levels
(
factor
(
ftable
$
ID
))
##is MS1 intensity high enough?)
id_field_width
<-
getWidth
(
max
(
ids
))
id_field_width
<-
getWidth
(
max
(
ids
))
fn_out
<-
function
(
id
,
suff
)
{
paste
(
formatC
(
id
,
width
=
id_field_width
,
flag
=
0
),
suff
,
".csv"
,
sep
=
''
)}
fn_out
<-
function
(
id
,
suff
)
{
paste
(
formatC
(
id
,
width
=
id_field_width
,
flag
=
0
),
suff
,
".csv"
,
sep
=
''
)}
## for loop through dataframe called file to set tresholds
## for loop through dataframe called file to set tresholds
ftable
[
c
(
"MS1"
,
"MS2"
,
"Alignment"
,
"
Intensity"
,
"AboveNoise
"
)]
<-
T
ftable
[
c
(
"MS1"
,
"MS2"
,
"Alignment"
,
"
MS1Intensity"
,
"AboveNoise"
,
"MS2Intensity"
,
"MS1peakWidth
"
)]
<-
T
ftable
$
Comments
<-
""
ftable
$
Comments
<-
""
for
(
ind
in
1
:
nrow
(
ftable
))
{
for
(
ind
in
1
:
nrow
(
ftable
))
{
wd
<-
ftable
$
wd
[
ind
]
wd
<-
ftable
$
wd
[
ind
]
...
@@ -342,36 +344,57 @@ preProc <- function (fnFileTab,fnDest=paste(stripext(fnFileTab),"_candidate.csv"
...
@@ -342,36 +344,57 @@ preProc <- function (fnFileTab,fnDest=paste(stripext(fnFileTab),"_candidate.csv"
fn_eic
<-
file.path
(
wd
,
fn_out
(
id
,
".eic"
))
fn_eic
<-
file.path
(
wd
,
fn_out
(
id
,
".eic"
))
eic
<-
NULL
eic
<-
NULL
maxInt
<-
NULL
maxInt
<-
NULL
eicExists
<-
F
eicExists
<-
T
if
(
!
file.exists
(
fn_eic
))
{
##does MS1 exist?
if
(
!
file.exists
(
fn_eic
))
{
ftable
[
ind
,
"MS1"
]
=
FALSE
ftable
[
ind
,
"MS1"
]
=
FALSE
eicExists
<-
T
eicExists
<-
F
}
}
else
{
else
{
eic
<-
read.csv
(
fn_eic
,
sep
=
","
,
stringsAsFactors
=
F
)
eic
<-
read.csv
(
fn_eic
,
sep
=
","
,
stringsAsFactors
=
F
)
maxInt
<-
max
(
eic
$
intensity
)
maxInt
<-
max
(
eic
$
intensity
)
if
(
maxInt
<
intTresh
)
{
ftable
[
ind
,
"Intensity"
]
=
FALSE
##is MS1 intensity high enough?
if
(
maxInt
<
ms1_intTresh
)
{
ftable
[
ind
,
"MS1Intensity"
]
=
FALSE
}
}
##
Detect noisy signal. This is a naive implementation, so careful.
##Detect noisy signal. This is a naive implementation, so careful.
mInt
<-
mean
(
eic
$
intensity
)
mInt
<-
mean
(
eic
$
intensity
)
if
(
maxInt
<
noiseFac
*
mInt
)
ftable
[
ind
,
"AboveNoise"
]
<-
F
if
(
maxInt
<
noiseFac
*
mInt
)
ftable
[
ind
,
"AboveNoise"
]
<-
F
##Is MS1 peak a proper peak, or just a spike? Check peakwidth.
MS1peakWi
}
}
#####MS2 checks
fn_kids
<-
file.path
(
wd
,
fn_out
(
id
,
".kids"
))
fn_kids
<-
file.path
(
wd
,
fn_out
(
id
,
".kids"
))
##does MS2 exist? Regardless of quality/alignment.
if
(
!
file.exists
(
fn_kids
))
{
if
(
!
file.exists
(
fn_kids
))
{
ftable
[
ind
,
"MS2"
]
=
FALSE
ftable
[
ind
,
"MS2"
]
=
FALSE
ftable
[
ind
,
"MS2Intensity"
]
=
NA
#moot
ftable
[
ind
,
"Alignment"
]
=
NA
#moot
}
else
{
}
else
{
## Detect RT shifts. Naive implementation, so careful.
## Detect RT shifts. Naive implementation, so careful.
if
(
eicExists
)
{
if
(
eicExists
)
{
################WHY THIS IF CONDITIONAL?? If MS2 exists, then eic MUST exist, no? Seems redundant.
rtInd
<-
match
(
maxInt
,
eic
$
intensity
)
##Is MS2 intensity high enough?
rtMax
<-
eic
$
rt
[
rtInd
]
ms2maxInt
<-
max
(
msms
@
intensity
)
msms
<-
read.csv
(
fn_kids
,
sep
=
","
,
stringsAsFactors
=
F
)
if
(
ms2maxInt
>
ms2_intTresh
){
whc
<-
msms
$
rt
>
rtMax
-
rtDelta
rtInd
<-
match
(
maxInt
,
eic
$
intensity
)
#returns position of first match in eic$intensity
whc
<-
whc
<
rtMax
+
rtDelta
rtMax
<-
eic
$
rt
[
rtInd
]
#fetch the rtmax value (RT with highest int;seconds) using above index
ints
<-
msms
$
intensity
[
whc
]
msms
<-
read.csv
(
fn_kids
,
sep
=
","
,
stringsAsFactors
=
F
)
if
(
!
any
(
ints
>
0
))
ftable
[
ind
,
"Alignment"
]
=
FALSE
whc
<-
msms
$
rt
>
rtMax
-
rtDelta
#T/F vector: are RT vals of ms2 above rtMax within Delta? Good peaks=TRUE;rt must be retentionTime!!!
}
whc
<-
whc
<
rtMax
+
rtDelta
#T/F vector: are RT vals of ms2 above rtMax within Delta?
#Overwrites whc! In any case, cannot use this as both must be T to give final whc of T (i.e. fall within the window).
ints
<-
msms
$
intensity
[
whc
]
#builds ints vector with intensities which fall in window
if
(
!
any
(
ints
>
0
))
ftable
[
ind
,
"Alignment"
]
=
FALSE
#if none of ints larger than 0, Alignment <-F
}
else
{
ftable
[
ind
,
"MS2Intensity"
]
=
FALSE
ftable
[
ind
,
"Alignment"
]
=
NA
#neither T or F, the MS2 was not of decent intensity in first place, alignment moot.
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment