tests/tPlotLinear.R

library(RUnit)
library(Anaquin)

.test.data <- function()
{
    input <- c(15.1062,
               15.1062,
               966.797,
               241.699,
               30.2124,
               7734.38,
               483.398,
               30937.5,
               483.398,
               15.1062,
               483.398,
               241.699,
               60.4248,
               0.118017,
               7734.37,
               7734.38,
               120.85,
               1933.59,
               0.944138,
               120.85,
               7.5531,
               3.77655,
               3867.19,
               15468.8,
               1.88828,
               1933.59,
               120.85,
               3867.19,
               30.2124,
               0.472069,
               241.699,
               60.4248,
               0.944138,
               120.85,
               1.88828,
               60.4248,
               15468.8,
               60.4248,
               1933.59,
               1.88828,
               30.2124,
               0.944138,
               3867.19,
               15468.8,
               3867.19,
               30.2124,
               15.1062,
               1933.59,
               7.5531,
               0.472069,
               0.472069,
               0.236034,
               0.0590086,
               241.699,
               0.236034,
               0.472069,
               0.118017,
               120.85,
               0.118017,
               483.398,
               30937.5,
               7.5531,
               0.472069,
               483.398,
               7.5531,
               966.797,
               3.77655,
               30937.5,
               3.77655,
               3.77655,
               966.797,
               3.77655,
               0.236034,
               1.88828,
               0.0590086)
    
    o1 <- c(4.29354,
            6.41774,
            271.696,
            67.3212,
            3.1943,
            2628.81,
            245.034,
            14727.4,
            38.2906,
            8.41748,
            140.367,
            90.1342,
            5.03172,
            0.282232,
            2340.3,
            5418.16,
            124.648,
            157.443,
            0.437077,
            2.42797,
            3.88121,
            NA,
            2010.24,
            7762.18,
            2.05478,
            526.579,
            29.9481,
            1369.19,
            9.21093,
            0.305795,
            50.4639,
            11.4579,
            0.291139,
            76.4986,
            3.2669,
            21.1347,
            8064.47,
            37.4146,
            438.561,
            0.38055,
            11.2435,
            0.88877,
            1491.72,
            4786.46,
            867.185,
            7.30535,
            2.78194,
            559.819,
            3.69124,
            0.523401,
            0.474327,
            0.929315,
            0.722466,
            111.985,
            1.1903,
            1.47662,
            0.285894,
            35.2424,
            0.700978,
            419.301,
            25760.2,
            2.5859,
            1.31373,
            24.5161,
            4.35937,
            457.339,
            2.59279,
            15205,
            0.64947,
            1.1555,
            261.917,
            0.252222,
            0.443106,
            0.376111,
            1.0948)
    
    o2 <- c(3.09828,
            8.68183,
            272.248,
            80.5532,
            3.17143,
            2813.75,
            252.489,
            15776.6,
            55.5334,
            7.92421,
            134.694,
            92.8906,
            8.70729,
            0.88829,
            2313.62,
            5647.12,
            121.991,
            157.827,
            0.411342,
            2.28061,
            2.82815,
            2.02179,
            2007.42,
            8399.07,
            1.32179,
            479.284,
            30.1469,
            1354.44,
            7.04809,
            0.688492,
            45.6092,
            16.2209,
            0.655503,
            64.66,
            2.49032,
            23.6616,
            8801.15,
            37.5889,
            402.614,
            0.792792,
            13.1838,
            1.30589,
            1546.73,
            5024.49,
            870.876,
            6.57147,
            3.05968,
            568.894,
            3.72397,
            0.650601,
            NA,
            0.970407,
            0.902928,
            107.726,
            NA,
            1.74165,
            0.15758,
            42.8825,
            0.632109,
            436.377,
            27119.4,
            4.50098,
            0.297246,
            18.5351,
            2.64522,
            490.524,
            1.45904,
            15831,
            0.729047,
            0.449076,
            277.903,
            2.34995,
            0.385306,
            0.864491,
            0.944744)
    
    o3 <- c(5.78108,
            8.41477,
            261.53,
            71.0515,
            2.22543,
            2554.46,
            235.358,
            14074.1,
            52.9666,
            5.93463,
            130.117,
            89.6172,
            13.3467,
            2.71212,
            2186.4,
            5142.73,
            122.094,
            202.948,
            3.26205,
            3.628,
            2.82539,
            1.14586,
            1921.63,
            7459.34,
            0.987163,
            469.363,
            27.2883,
            1303.06,
            10.1981,
            1.0284,
            44.2452,
            14.9583,
            1.95817,
            62.0998,
            4.66003,
            24.9048,
            7705.65,
            39.1692,
            377.697,
            1.70661,
            12.2224,
            2.68944,
            1432.93,
            4672.95,
            821.054,
            6.00481,
            2.91698,
            549.193,
            6.69091,
            2.97898,
            1.91727,
            3.08212,
            2.09839,
            113.618,
            2.05095,
            4.40774,
            1.82189,
            36.1417,
            4.30722,
            410.602,
            23843.5,
            6.58454,
            1.3233,
            22.6614,
            6.2324,
            443.329,
            1.81664,
            14447.8,
            2.18542,
            0.148822,
            237.506,
            2.7184,
            2.3283,
            2.68241,
            3.31801)
    
    return (data.frame(Input=input, Observed1=o1, Observed2=o2, Observed3=o3))
}

test.PlotLinear_1 <- function()
{
    x <- .test.data()
    r <- plotLinear(row.names(x), log2(x$Input), log2(x$Observed1), shouldLog=F)
    checkEqualsNumeric(r$model$breaks, 0.9170727)
}

test.PlotLinear_2 <- function()
{
    x <- .test.data()
    r <- plotLinear(row.names(x), log2(x$Input), log2(x[,c(2:4)]), shouldLog=F)
    checkTrue(is.null(r))
}

test.PlotLinear_3 <- function()
{
    x <- "15.1062,
          15.1062,
          241.699,
          0.472069,
          120.85,
          483.398,
          0.0590086,
          483.398,
          15.1062,
          241.699,
          60.4248,
          120.85,
          120.85,
          0.472069,
          0.118017,
          0.0590086,
          0.944138,
          0.118017,
          7.5531,
          3.77655,
          0.236034,
          60.4248,
         1.88828,
          241.699,
          0.118017,
          0.236034,
          0.472069,
          30.2124,
          241.699,
          60.4248,
          0.944138,
          0.944138,
          0.118017,
          1.88828,
          60.4248,
          60.4248,
          0.944138,
          1.88828,
          0.472069,
          0.944138,
          15.1062,
          7.5531,
          15.1062,
          0.472069,
          15.1062,
          60.4248,
          7.5531,
          30.2124,
          30.2124,
          0.0590086,
          0.236034,
          0.0590086,
          241.699,
          0.236034,
          30.2124,
          120.85,
          0.118017,
          120.85,
          1.88828,
          7.5531,
          30.2124,
          483.398,
          7.5531,
          966.797,
          3.77655,
          241.699,
          3.77655,
          3.77655,
          3.77655,
          0.236034,
          1.88828,
          0.0590086"
    
    y <- "2292.02,
          1728.11,
          33095.9,
          51.557,
          13616.2,
          54615.3,
          5.75489,
          60652.2,
          1205.27,
          30255,
          7645.25,
          11118.4,
          16529.2,
          48.5283,
          12.6669,
          8.29854,
          96.6785,
          14.3095,
          1151.03,
          481.086,
          22.5602,
          9128.84,
          203.783,
          24093.9,
          15.2307,
          22.7496,
          50.3159,
          4104.9,
          19207.5,
          6752.21,
          123.603,
          187.043,
          14.0419,
          263.462,
          3310.3,
          8270.03,
          119.862,
          280.256,
          1e-05,
          115.157,
          2042.86,
          1084.78,
          1773.62,
          54.5923,
          1733.97,
          6365.94,
          901.141,
          4224.51,
          3612.83,
          14.9924,
          29.9387,
          5.04516,
          30960.8,
          35.6649,
          3664.05,
          17094.3,
          13.5061,
          13986.2,
          248.781,
          918.314,
          3502.82,
          64966.4,
          860.103,
          3426.51,
          515.013,
          32569.1,
          609.002,
          427.186,
          677.121,
          25.5264,
          199.22,
          8.10828"    
    
    z <- "R1_101,
          R1_102,
          R1_11,
          R1_12,
          R1_13,
          R1_14,
          R1_21,
          R1_22,
          R1_23,
          R1_31,
          R1_32,
          R1_33,
          R1_41,
          R1_42,
          R1_43,
          R1_51,
          R1_52,
          R1_53,
          R1_61,
          R1_62,
          R1_63,
          R1_71,
          R1_72,
          R1_73,
          R1_81,
          R1_82,
          R1_83,
          R1_91,
          R1_92,
          R1_93,
          R2_1,
          R2_105,
          R2_115,
          R2_116,
          R2_117,
          R2_140,
          R2_143,
          R2_151,
          R2_152,
          R2_153,
          R2_154,
          R2_18,
          R2_19,
          R2_20,
          R2_24,
          R2_26,
          R2_27,
          R2_28,
          R2_32,
          R2_33,
          R2_37,
          R2_38,
          R2_41,
          R2_42,
          R2_45,
          R2_46,
          R2_47,
          R2_53,
          R2_55,
          R2_57,
          R2_59,
          R2_6,
          R2_60,
          R2_63,
          R2_65,
          R2_66,
          R2_67,
          R2_68,
          R2_71,
          R2_72,
          R2_73,
          R2_76"

    r <- plotLinear(unlist(strsplit(z, split=',')),
                    log2(as.numeric(unlist(strsplit(x, split=',')))),
                    log2(as.numeric(unlist(strsplit(y, split=',')))),
                    shouldLog=F)
    
    checkEquals(NULL, r$LOQ)
}

test.PlotLinear_1()
test.PlotLinear_2()
test.PlotLinear_3()
sequinstandards/RAnaquin documentation built on Aug. 9, 2019, 2:46 p.m.