Running 'test01-MO.R' [181s]
  Running 'test02-fitCox.R' [171s]
  Running 'test03-multiplePLS.R' [172s]
  Running 'test04-plasma.R' [12s]
  Running 'test05-interpret.R' [12s]
Running the tests in 'tests/test01-MO.R' failed.
Complete output:
  > library(plasma)
  > ## check data sets
  > fls <- try(loadESCAdata())
  > if (inherits(fls, "try-error")) {
  +   stop("Unable to load data from remote server.")
  + }
  > ls()
  [1] "fls"
  > ## make sure we can assemble MultiOmics objects
  > MO <- with(plasmaEnv, prepareMultiOmics(assemble, Outcome))
  > ## Test summary and plot methods
  > summary(MO)
  Datasets:
       ClinicalBin ClinicalCont MAF Meth450 miRSeq mRNASeq RPPA
  [1,]          53            6 566    1454    926    2520  192
  [2,]         185          185 185     185    185     185  185
  Outcomes:
     patient_id  vital_status days_to_death    days_to_last_followup
   a3i8   :  1   alive:108    Min.   :   9.0   Min.   :   4.0       
   a3ql   :  1   dead : 77    1st Qu.: 180.0   1st Qu.: 336.5       
   a3y9   :  1                Median : 351.0   Median : 402.5       
   a3ya   :  1                Mean   : 495.2   Mean   : 570.1       
   a3yb   :  1                3rd Qu.: 650.0   3rd Qu.: 696.8       
   a3yc   :  1                Max.   :2532.0   Max.   :3714.0       
   (Other):179                NA's   :108      NA's   :77           
        Days       
   Min.   :   4.0  
   1st Qu.: 232.0  
   Median : 400.0  
   Mean   : 538.9  
   3rd Qu.: 681.0  
   Max.   :3714.0  
                   
  > opar <- par(mai = c(1.02, 1.82, 0.82, 0.42))
  > plot(MO)
  > par(opar)
  > ## Make sure we can use the subset operator
  > train <- rep(c(TRUE, FALSE), times = c(112, 185-112))
  > MO2 <- MO[, train]
  > summary(MO2)
  Datasets:
       ClinicalBin ClinicalCont MAF Meth450 miRSeq mRNASeq RPPA
  [1,]          53            6 566    1454    926    2520  192
  [2,]         112          112 112     112    112     112  112
  Outcomes:
     patient_id  vital_status days_to_death  days_to_last_followup
   a3i8   :  1   alive:63     Min.   :   9   Min.   :  11.0       
   a3ql   :  1   dead :49     1st Qu.: 157   1st Qu.: 293.5       
   a3y9   :  1                Median : 390   Median : 441.0       
   a3ya   :  1                Mean   : 548   Mean   : 622.2       
   a3yb   :  1                3rd Qu.: 764   3rd Qu.: 721.5       
   a3yc   :  1                Max.   :2532   Max.   :3714.0       
   (Other):106                NA's   :63     NA's   :49           
        Days       
   Min.   :   9.0  
   1st Qu.: 223.2  
   Median : 409.0  
   Mean   : 589.7  
   3rd Qu.: 739.2  
   Max.   :3714.0  
                   
  > ## For future reference, show there are no survival differences
  > if (require("survival")) {
  +   plot(survfit(Surv(Days, vital_status == "dead") ~ train, data = MO@outcome),
  +                col=c("cyan4", "magenta"), lwd=3)
  + }
  Loading required package: survival
  > ## And check that the other argument also works
  > MO3 <- MO[c("ClinicalBin", "RPPA"),]
  > summary(MO3)
  Datasets:
       ClinicalBin RPPA
  [1,]          53  192
  [2,]         185  185
  Outcomes:
     patient_id  vital_status days_to_death    days_to_last_followup
   a3i8   :  1   alive:108    Min.   :   9.0   Min.   :   4.0       
   a3ql   :  1   dead : 77    1st Qu.: 180.0   1st Qu.: 336.5       
   a3y9   :  1                Median : 351.0   Median : 402.5       
   a3ya   :  1                Mean   : 495.2   Mean   : 570.1       
   a3yb   :  1                3rd Qu.: 650.0   3rd Qu.: 696.8       
   a3yc   :  1                Max.   :2532.0   Max.   :3714.0       
   (Other):179                NA's   :108      NA's   :77           
        Days       
   Min.   :   4.0  
   1st Qu.: 232.0  
   Median : 400.0  
   Mean   : 538.9  
   3rd Qu.: 681.0  
   Max.   :3714.0  
                   
  > 
  > ## Things expected to fail
  > ## disorient one of the component datasets.
  > badinput <- with(plasmaEnv, assemble)
  > badinput$mRNASeq <- t(badinput$mRNASeq)
  > pmo <- try( with(plasmaEnv, prepareMultiOmics(badinput, Outcome) ))
  Error in FUN(X[[i]], ...) : 
    No matching sample names in dataset 'mRNASeq'.
  
  > 
  > proc.time()
     user  system elapsed 
     6.76    1.21    9.34 
Running the tests in 'tests/test02-fitCox.R' failed.
Complete output:
  > library(plasma)
  > # Repeat basic stuff from first test
  > fls <- try(loadESCAdata())
  > if (inherits(fls, "try-error")) {
  +   stop("Unable to load data from remote server.")
  + }
  > ls()
  [1] "fls"
  > MO <- with(plasmaEnv, prepareMultiOmics(assemble, Outcome))
  > train <- rep(c(TRUE, FALSE), times = c(112, 185-112))
  > MO2 <- MO[, train]
  > ## Fit a survival model on a single data set on the MultiOmics object
  > fitted <- fitSingleModel(MO2, "ClinicalBin", "Days", "vital_status", "dead")
  ____************************************************____
  ____There are some NAs in X but not in Y____
  ____Component____ 1 ____
  ____Component____ 2 ____
  ____Component____ 3 ____
  ____Predicting X with NA in X and not in Y____
  ****________________________________________________****
  
  There were 15 warnings (use warnings() to see them)
  > summary(fitted)
  Risk Model:
  Call:
  coxph(formula = formula(paste("Surv(", timevar, ",", eventvar, 
      "== \"", eventvalue, "\") ~ Risk", sep = "")), data = Xout)
  
    n= 112, number of events= 49 
  
         coef exp(coef) se(coef)     z Pr(>|z|)    
  Risk 1.0000    2.7183   0.1322 7.565 3.88e-14 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
       exp(coef) exp(-coef) lower .95 upper .95
  Risk     2.718     0.3679     2.098     3.522
  
  Concordance= 0.823  (se = 0.032 )
  Likelihood ratio test= 69.52  on 1 df,   p=<2e-16
  Wald test            = 57.23  on 1 df,   p=4e-14
  Score (logrank) test = 10.48  on 1 df,   p=0.001
  
  SplitModel:
  Call:
  coxph(formula = formula(paste("Surv(", timevar, ",", eventvar, 
      "==\"", eventvalue, "\") ~ Split", sep = "")), data = Xout)
  
    n= 112, number of events= 49 
  
           coef exp(coef) se(coef)     z Pr(>|z|)    
  Split  2.4910   12.0737   0.4603 5.412 6.24e-08 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
        exp(coef) exp(-coef) lower .95 upper .95
  Split     12.07    0.08282     4.898     29.76
  
  Concordance= 0.721  (se = 0.03 )
  Likelihood ratio test= 44.78  on 1 df,   p=2e-11
  Wald test            = 29.29  on 1 df,   p=6e-08
  Score (logrank) test = 42.93  on 1 df,   p=6e-11
  
  PLS Model:
    n= 112, number of events= 49 
  
          coef exp(coef) se(coef)     z Pr(>|z|)    
  tt.1  3.5044   33.2618   0.5318 6.589 4.42e-11 ***
  tt.2  1.1128    3.0429   0.1906 5.838 5.28e-09 ***
  tt.3  0.7267    2.0682   0.3071 2.366    0.018 *  
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  
       exp(coef) exp(-coef) lower .95 upper .95
  tt.1    33.262    0.03006    11.729    94.328
  tt.2     3.043    0.32864     2.094     4.421
  tt.3     2.068    0.48352     1.133     3.776
  
  Concordance= 0.823  (se = 0.032 )
  Likelihood ratio test= 69.52  on 3 df,   p=5e-15
  Wald test            = 57.23  on 3 df,   p=2e-12
  Score (logrank) test = 20.57  on 3 df,   p=1e-04
  
  > p <- predict(fitted)
  > summary(p)
      Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
  -32.2297  -0.1138   1.0077   0.0000   1.9803   5.4533 
  > plot(fitted, xlab = "Time (Days)", legloc = "topright", main = "Training Data")
  > ## Make sure we can predict on new data
  > testobj <- MO[, !train]
  > summary(testobj)
  Datasets:
       ClinicalBin ClinicalCont MAF Meth450 miRSeq mRNASeq RPPA
  [1,]          53            6 566    1454    926    2520  192
  [2,]          73           73  73      73     73      73   73
  Outcomes:
     patient_id vital_status days_to_death    days_to_last_followup
   a4a1   : 1   alive:45     Min.   :  47.0   Min.   :   4.0       
   a4a2   : 1   dead :28     1st Qu.: 208.0   1st Qu.: 365.0       
   a4a3   : 1                Median : 317.0   Median : 388.0       
   a4a4   : 1                Mean   : 402.8   Mean   : 497.2       
   a4a5   : 1                3rd Qu.: 554.0   3rd Qu.: 549.0       
   a4a6   : 1                Max.   :1405.0   Max.   :1641.0       
   (Other):67                NA's   :45       NA's   :28           
        Days     
   Min.   :   4  
   1st Qu.: 247  
   Median : 383  
   Mean   : 461  
   3rd Qu.: 553  
   Max.   :1641  
                 
  > ## How do we get rid of the "Missing value" information?
  > pre <- predict(fitted, newdata = testobj)
  > prer <- predict(fitted, newdata = testobj, type = "risk")
  > pres <- predict(fitted, newdata = testobj, type = "split")
  > pairs(cbind(pre, prer, pres))
  > 
  > ## Things that should fail:
  > p <- try( predict(fitted, "risk") )
  Error in newdata@data : 
    no applicable method for `@` applied to an object of class "character"
  > p <- try( predict(fitted, type = "riak") )
  Error in match.arg(type) : 
    'arg' should be one of "components", "risk", "split", "survfit"
  > 
  > proc.time()
     user  system elapsed 
     6.62    1.20    9.36 
Running the tests in 'tests/test03-multiplePLS.R' failed.
Complete output:
  > library(plasma)
  > fls <- try(loadESCAdata())
  > if (inherits(fls, "try-error")) {
  +   stop("Unable to load data from remote server.")
  + }
  > ls()
  [1] "fls"
  > ## prepare MultiOmics
  > MO <- with(plasmaEnv, prepareMultiOmics(assemble, Outcome))
  > MO <- MO[c("ClinicalBin", "ClinicalCont", "RPPA"),]
  > summary(MO)
  Datasets:
       ClinicalBin ClinicalCont RPPA
  [1,]          53            6  192
  [2,]         185          185  185
  Outcomes:
     patient_id  vital_status days_to_death    days_to_last_followup
   a3i8   :  1   alive:108    Min.   :   9.0   Min.   :   4.0       
   a3ql   :  1   dead : 77    1st Qu.: 180.0   1st Qu.: 336.5       
   a3y9   :  1                Median : 351.0   Median : 402.5       
   a3ya   :  1                Mean   : 495.2   Mean   : 570.1       
   a3yb   :  1                3rd Qu.: 650.0   3rd Qu.: 696.8       
   a3yc   :  1                Max.   :2532.0   Max.   :3714.0       
   (Other):179                NA's   :108      NA's   :77           
        Days       
   Min.   :   4.0  
   1st Qu.: 232.0  
   Median : 400.0  
   Mean   : 538.9  
   3rd Qu.: 681.0  
   Max.   :3714.0  
                   
  > ## test complete cox models
  > set.seed(12345)
  > train <- rep(FALSE, 185)
  > train[sample(185, 113)] <- TRUE
  > MO2 <- MO[, train]
  > summary(MO2)
  Datasets:
       ClinicalBin ClinicalCont RPPA
  [1,]          53            6  192
  [2,]         113          113  113
  Outcomes:
     patient_id  vital_status days_to_death    days_to_last_followup
   a3ql   :  1   alive:64     Min.   :   9.0   Min.   :  11.0       
   a3y9   :  1   dead :49     1st Qu.: 157.0   1st Qu.: 318.8       
   a3ya   :  1                Median : 351.0   Median : 404.5       
   a3yc   :  1                Mean   : 494.6   Mean   : 572.7       
   a43c   :  1                3rd Qu.: 600.0   3rd Qu.: 652.8       
   a43h   :  1                Max.   :2532.0   Max.   :3714.0       
   (Other):107                NA's   :64       NA's   :49           
        Days       
   Min.   :   9.0  
   1st Qu.: 238.0  
   Median : 400.0  
   Mean   : 538.8  
   3rd Qu.: 632.0  
   Max.   :3714.0  
                   
  > bigfit <- fitCoxModels(MO2, timevar = "Days",
  +                        eventvar = "vital_status",
  +                        eventvalue = "dead")
  Fitting model with  ClinicalBin 
  ____************************************************____
  ____There are some NAs in X but not in Y____
  ____Component____ 1 ____
  ____Component____ 2 ____
  ____Component____ 3 ____
  ____Predicting X with NA in X and not in Y____
  ****________________________________________________****
  
  Fitting model with  ClinicalCont 
  ____************************************************____
  ____There are some NAs in X but not in Y____
  ____Component____ 1 ____
  ____Component____ 2 ____
  ____Predicting X with NA in X and not in Y____
  ****________________________________________________****
  
  Fitting model with  RPPA 
  ____************************************************____
  ____Component____ 1 ____
  ____Component____ 2 ____
  ____Component____ 3 ____
  ____Predicting X without NA neither in X nor in Y____
  ****________________________________________________****
  
  There were 15 warnings (use warnings() to see them)
  > ## test core methods
  > class(bigfit)
  [1] "MultiplePLSCoxModels"
  attr(,"package")
  [1] "plasma"
  > summary(bigfit)
  An object containing MultiplePLSCoxModels based on:
  [1] "ClinicalBin"  "ClinicalCont" "RPPA"        
  > getSizes(bigfit)
               NT cNT      p.value
  ClinicalBin   3   3 1.095726e-03
  ClinicalCont  2   2 5.056035e-01
  RPPA          3   3 6.993030e-11
  > plot(bigfit)
  > preds <- predict(bigfit)
  > ## make sure we can predict on new data
  > testobj <- MO[, !train]
  > 
  > predsB <- predict(bigfit, newdata = testobj)
  > predsR <- predict(bigfit, newdata = testobj, type = "risk")
  > predsS <- predict(bigfit, newdata = testobj, type = "split")
  > 
  > proc.time()
     user  system elapsed 
     9.56    1.03   12.03