Skip to content

Commit

Permalink
Merge pull request #91 from wverastegui/77_refactor_R_aplcms
Browse files Browse the repository at this point in the history
Refactor find.turn.point.R and find.tol.time.R and recover.weaker.R
  • Loading branch information
hechth authored Aug 17, 2022
2 parents 3444911 + 668a6bf commit e55a447
Show file tree
Hide file tree
Showing 23 changed files with 1,398 additions and 866 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- refactored `feature.align.R` [#63](https://github.com/RECETOX/recetox-aplcms/pull/63)[#88](https://github.com/RECETOX/recetox-aplcms/pull/88)
- refactored `adjust.time.R` [#64](https://github.com/RECETOX/recetox-aplcms/pull/64)
- refactored `find.tol.time.R` [#91](https://github.com/RECETOX/recetox-aplcms/pull/91)
- refactored `find.turn.point.R` [#91](https://github.com/RECETOX/recetox-aplcms/pull/91)
### Removed

## [0.9.4] - 2022-05-10
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Authors@R: c(
Description: This is a customized fork of the original work from Tianwei Yu.
It takes the adaptive processing of LC/MS metabolomics data further
with focus on high resolution MS for both LC and GC applications.
Depends: R (>= 3.50), MASS, mzR, splines, doParallel, foreach, snow, dplyr,
tidyr, stringr, tibble, tools, arrow
Depends: R (>= 3.50), MASS, mzR, splines, doParallel, foreach,
snow, dplyr, tidyr, stringr, tibble, tools, arrow
biocViews: Technology, MassSpectrometry
License: GPL-2
LazyLoad: yes
NeedsCompilation: no
Suggests:
arrow, dataCompareR, testthat (>= 3.0.0)
dataCompareR, testthat (>= 3.0.0)
Config/testthat/edition: 3
RoxygenNote: 7.2.0
RoxygenNote: 7.2.1
13 changes: 8 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ export(bigauss.esti)
export(bigauss.esti.EM)
export(bigauss.mix)
export(combine.seq.3)
export(compute_all_times)
export(compute_base_curve)
export(compute_boundaries)
export(compute_bounds)
export(compute_breaks)
export(compute_breaks_2)
export(compute_delta_rt)
export(compute_densities)
export(compute_mass_density)
export(compute_mass_values)
export(compute_target_time)
export(compute_target_times)
export(cont.index)
export(duplicate.row.remove)
export(extract_features)
export(extract_pattern_colnames)
export(feature.align)
export(find.tol)
export(find.turn.point)
export(find_local_maxima)
export(get_custom_chr_tol)
export(get_mzrange_bound_indices)
export(get_raw_features_in_mzrange)
export(get_rt_region_indices)
export(get_times_to_use)
export(hybrid)
export(increment_counter)
Expand All @@ -35,9 +35,12 @@ export(load.lcms)
export(load_data)
export(load_file)
export(make.known.table)
export(mass.match)
export(msExtrema)
export(normix)
export(normix.bic)
export(plot_raw_profile_histogram)
export(predict_mz_break_indices)
export(prep.uv)
export(proc.cdf)
export(prof.to.features)
Expand Down
16 changes: 2 additions & 14 deletions R/adaptive.bin.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ compute_breaks <- function(tol, masses, intensi, weighted) {
return(breaks)
}

#' @export
compute_boundaries <- function(mass.vlys, mass.pks, j){
mass.lower <- max(mass.vlys[mass.vlys < mass.pks[j]])
mass.upper <- min(mass.vlys[mass.vlys > mass.pks[j]])

return(list(lower = mass.lower, upper = mass.upper))
}

#' @export
increment_counter <- function(pointers, that.n){
Expand Down Expand Up @@ -134,7 +127,7 @@ adaptive.bin <- function(x,
for (j in 1:length(mass.pks))
{
# compute boundaries
boundaries <- compute_boundaries(mass.vlys, mass.pks, j)
boundaries <- compute_boundaries(mass.vlys, mass.pks[j])

if (length(mass.pks) == 1){
boundaries$lower <- boundaries$lower - 1
Expand All @@ -144,12 +137,7 @@ adaptive.bin <- function(x,
that <- this_table |> dplyr::filter(mz > boundaries$lower & mz <= boundaries$upper)

if (nrow(that) > 0) {
that <- combine.seq.3(that)

if (nrow(that) != 1) {
that <- that[order(that[, 1]), ]
}

that <- combine.seq.3(that) |> dplyr::arrange_at("mz")
that.range <- diff(range(that$labels))

if (that.range > 0.5 * time_range & length(that$labels) > that.range * min.pres & length(that$labels) / (that.range / aver.time.range) > min.pres) {
Expand Down
Loading

0 comments on commit e55a447

Please sign in to comment.