aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat/test_from_max_mean.R
blob: 3edf5969f09830f7c3507c1cafc4632ccb07c165 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Copyright (C) 2018,2019 Johannes Ranke
# Contact: jranke@uni-bremen.de

# This file is part of the R package mkin

# mkin is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.

# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.

# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>

context("Test fitting the decline of metabolites from their maximum")

test_that("Fitting from maximum mean value works", {

  expect_warning(
    expect_error(mkinfit(SFO_SFO, FOCUS_2006_D, from_max_mean = TRUE),
      "only implemented for models with a single observed variable"),
    "Observations with value of zero were removed")
  
  # We can either explicitly create a model for m1, or subset the data
  SFO_m1 <- mkinmod(m1 = mkinsub("SFO"))
  f.1 <- expect_warning(mkinfit(SFO_m1, FOCUS_2006_D, from_max_mean = TRUE, quiet = TRUE))
  expect_equivalent(endpoints(f.1)$distimes["m1", ], c(170.8, 567.5), 
                    scale = 1, tolerance = 0.1)

  f.2 <- expect_warning(mkinfit("SFO", subset(FOCUS_2006_D, name == "m1"), 
                                from_max_mean = TRUE, quiet = TRUE))
  expect_equivalent(endpoints(f.2)$distimes["m1", ], c(170.8, 567.5), 
                    scale = 1, tolerance = 0.1)
})

Contact - Imprint