R Under development (unstable) (2024-01-23 r85822 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # Tests on residuals and corresponding postfit filter > library(DRomics) Loading required package: limma Loading required package: DESeq2 Loading required package: S4Vectors Loading required package: stats4 Loading required package: BiocGenerics Attaching package: 'BiocGenerics' The following object is masked from 'package:limma': plotMA The following objects are masked from 'package:stats': IQR, mad, sd, var, xtabs The following objects are masked from 'package:base': Filter, Find, Map, Position, Reduce, anyDuplicated, aperm, append, as.data.frame, basename, cbind, colnames, dirname, do.call, duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted, lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank, rbind, rownames, sapply, setdiff, table, tapply, union, unique, unsplit, which.max, which.min Attaching package: 'S4Vectors' The following object is masked from 'package:utils': findMatches The following objects are masked from 'package:base': I, expand.grid, unname Loading required package: IRanges Attaching package: 'IRanges' The following object is masked from 'package:grDevices': windows Loading required package: GenomicRanges Loading required package: GenomeInfoDb Loading required package: SummarizedExperiment Loading required package: MatrixGenerics Loading required package: matrixStats Attaching package: 'MatrixGenerics' The following objects are masked from 'package:matrixStats': colAlls, colAnyNAs, colAnys, colAvgsPerRowSet, colCollapse, colCounts, colCummaxs, colCummins, colCumprods, colCumsums, colDiffs, colIQRDiffs, colIQRs, colLogSumExps, colMadDiffs, colMads, colMaxs, colMeans2, colMedians, colMins, colOrderStats, colProds, colQuantiles, colRanges, colRanks, colSdDiffs, colSds, colSums2, colTabulates, colVarDiffs, colVars, colWeightedMads, colWeightedMeans, colWeightedMedians, colWeightedSds, colWeightedVars, rowAlls, rowAnyNAs, rowAnys, rowAvgsPerColSet, rowCollapse, rowCounts, rowCummaxs, rowCummins, rowCumprods, rowCumsums, rowDiffs, rowIQRDiffs, rowIQRs, rowLogSumExps, rowMadDiffs, rowMads, rowMaxs, rowMeans2, rowMedians, rowMins, rowOrderStats, rowProds, rowQuantiles, rowRanges, rowRanks, rowSdDiffs, rowSds, rowSums2, rowTabulates, rowVarDiffs, rowVars, rowWeightedMads, rowWeightedMeans, rowWeightedMedians, rowWeightedSds, rowWeightedVars Loading required package: Biobase Welcome to Bioconductor Vignettes contain introductory material; view with 'browseVignettes()'. To cite Bioconductor, see 'citation("Biobase")', and for packages 'citation("pkgname")'. Attaching package: 'Biobase' The following object is masked from 'package:MatrixGenerics': rowMedians The following objects are masked from 'package:matrixStats': anyMissing, rowMedians DRomics has been loaded. !!!! IMPORTANT CHANGES IN DEFAULT PLOT ARGUMENTS !!!! Now all the plot functions use by default a log10 scale for dose and BMD values, except curvesplot(), for which the use of a dose log scale requires the specification by the user of a non null minimal value (xmin). We also put the default value of the argument scaling at TRUE in curvesplot() and bmdplotwithgradient(), to focus on shapes of dose-responses rather than on their amplitude. > visualize <- FALSE # put to TRUE for a manual check of plots > > if (visualize) + { + IC <- "AICc" + ### test on microarray data ###################### + datafilename <- system.file("extdata", "transcripto_sample.txt", package="DRomics") + datafilename <- system.file("extdata", "transcripto_very_small_sample.txt", package="DRomics") + + (o <- microarraydata(datafilename, check = TRUE, norm.method = "cyclicloess")) + (s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)) + (f <- drcfit(s_quad, progressbar = TRUE, information.criterion = IC)) + plot(f, plot.type = "fitted_residuals") + nrow(f$fitres) + nrow(f$unfitres) + length(which(f$residualtests$resivartrendP < 0.05)) + length(which(f$residualtests$resivartrendP < 0.05)) / length(f$residualtests$resivartrendP) + + # Look at the table of results for successful fits + head(f$fitres) + + # Look at the table of results for unsuccessful fits + head(f$unfitres) + + # count the number of unsuccessful fits for each cause + table(f$unfitres$cause) + + # Plot of the data corresponding to unsuccessful fits + targetplot(f$unfitres$id[f$unfitres$cause == "constant.model"], f) + targetplot(f$unfitres$id[f$unfitres$cause == "trend.in.residuals"], f) + + # Fit without postfit filtering + (f2 <- drcfit(s_quad, postfitfilter = FALSE, progressbar = TRUE)) + nrow(f2$fitres) + nrow(f2$unfitres) + + # count the number of unsuccessful fits for each cause + table(f2$unfitres$cause) + + # Plot of the data corresponding to unsuccessful fits in f + (itemseliminatedinf <- f$unfitres$id[f$unfitres$cause == "trend.in.residuals"]) + + targetplot(itemseliminatedinf, f2) + + f2$residualtests + (itemswithmeantrendinf2 <- + f2$fitres$id[f2$residualtests$resimeantrendP < 0.05]) + targetplot(itemswithmeantrendinf2[1:20], f2) + + (itemswithvartrendinf2 <- + f2$fitres$id[f2$residualtests$resivartrendP < 0.05]) + targetplot(itemswithvartrendinf2[1:20], f2) + + (itemsbothPB <- f2$fitres$id[f2$residualtests$resimeantrendP < 0.05 + & f2$residualtests$resivartrendP < 0.05]) + ### test on RNAseq data ################# + data(Zhou_kidney_pce) + d <- Zhou_kidney_pce + (o <- RNAseqdata(d)) + (s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)) + (f <- drcfit(s_quad, progressbar = TRUE, information.criterion = IC)) + # (f <- drcfit(s_quad, progressbar = FALSE, parallel = "snow", ncpus = 4)) + plot(f, dose_log_transfo = TRUE) + scale_x_log10(limits = c(0.1, 10)) + + # count the number of unsuccessful fits for each cause + table(f$unfitres$cause) + + # Plot of the data corresponding to unsuccessful fits + targetplot(f$unfitres$id[f$unfitres$cause == "constant.model"], f) + targetplot(f$unfitres$id[f$unfitres$cause == "trend.in.residuals"], f) + nrow(f$fitres) + nrow(f$unfitres) + length(which(f$residualtests$resivartrendP < 0.05)) + length(which(f$residualtests$resivartrendP < 0.05)) / length(f$residualtests$resivartrendP) + + ### test on RNAseqdata incorrectly entered as metabolomic data + ### and with a high FDR + data(Zhou_kidney_pce) + d <- Zhou_kidney_pce + (o <- continuousomicdata(d)) + (s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.20)) + (f <- drcfit(s_quad, progressbar = TRUE, information.criterion = IC)) + plot(f, items = 49) + nrow(f$fitres) + nrow(f$unfitres) + length(which(f$residualtests$resivartrendP < 0.05)) + length(which(f$residualtests$resivartrendP < 0.05)) / length(f$residualtests$resivartrendP) + # count the number of unsuccessful fits for each cause + table(f$unfitres$cause) + + + ### test on metabolomic data ################# + data(Scenedesmus_metab) + (o <- continuousomicdata(Scenedesmus_metab)) + plot(o) + (s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)) + (f <- drcfit(s_quad, progressbar = TRUE, information.criterion = IC)) + plot(f, plot.type = "fitted_residuals") + nrow(f$fitres) + nrow(f$unfitres) + length(which(f$residualtests$resivartrendP < 0.05)) + length(which(f$residualtests$resivartrendP < 0.05)) / length(f$residualtests$resivartrendP) + # count the number of unsuccessful fits for each cause + table(f$unfitres$cause) + + which(f$residualtests$resivartrendP < 0.05) + (itemswithvartrendinf <- + f$fitres$id[f$residualtests$resivartrendP < 0.05]) + targetplot(itemswithvartrendinf, f) + + ### test on metabolomic data not in log scale ################# + data(Scenedesmus_metab) + metabnotinlog <- Scenedesmus_metab + metabnotinlog[-1, -1] <- 10^metabnotinlog[-1, -1] + + (o <- continuousomicdata(metabnotinlog)) + plot(o) + (s_quad <- itemselect(o, select.method = "quadratic", FDR = 0.05)) + (f <- drcfit(s_quad, progressbar = TRUE, information.criterion = IC)) + plot(f, plot.type = "fitted_residuals") + nrow(f$fitres) + nrow(f$unfitres) + length(which(f$residualtests$resivartrendP < 0.05)) + length(which(f$residualtests$resivartrendP < 0.05)) / length(f$residualtests$resivartrendP) + + which(f$residualtests$resivartrendP < 0.05) + (itemswithvartrendinf <- + f$fitres$id[f$residualtests$resivartrendP < 0.05]) + targetplot(itemswithvartrendinf, f) + + } > > proc.time() user system elapsed 9.39 0.81 10.20