diff --git a/.Rbuildignore b/.Rbuildignore index 437a3bf..88784d0 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,4 +1,5 @@ ^.*\.Rproj$ ^\.Rproj\.user$ .travis.yml -LICENSE.md \ No newline at end of file +LICENSE.md +README.md \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5b6a065..db5decf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .Rhistory .RData .Ruserdata +.Rbuildignore +.travis.yml diff --git a/DESCRIPTION b/DESCRIPTION index 870eba2..b3a7679 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: assignPOP Type: Package Title: Population Assignment using Genetic, Non-Genetic or Integrated Data in a Machine Learning Framework -Version: 1.2.4 +Version: 1.3.0 Author: Kuan-Yu (Alex) Chen [aut, cre], Elizabeth A. Marschall [aut], Michael G. Sovic [aut], Anthony C. Fries [aut], H. Lisle Gibbs [aut], Stuart A. Ludsin [aut] @@ -27,6 +27,7 @@ Imports: reshape2, stringr, tree, + rlang, Suggests: gtable, iterators, @@ -36,5 +37,5 @@ Suggests: rmarkdown, testthat License: GPL (>= 2) -RoxygenNote: 7.1.1 +RoxygenNote: 7.3.1 Encoding: UTF-8 diff --git a/NAMESPACE b/NAMESPACE index ab04626..e7fee07 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,6 +27,7 @@ importFrom(parallel,stopCluster) importFrom(randomForest,importance) importFrom(randomForest,randomForest) importFrom(reshape2,melt) +importFrom(rlang,.data) importFrom(stats,model.matrix) importFrom(stats,prcomp) importFrom(stats,predict) diff --git a/R/accuracy.MC.R b/R/accuracy.MC.R index 2074481..1f4e9db 100644 --- a/R/accuracy.MC.R +++ b/R/accuracy.MC.R @@ -1,4 +1,4 @@ -#' Estimate assignment accuracies of Monte-Carlo cross-validation results +#' Estimate assignment accuracy of Monte-Carlo cross-validation results #' #' This function allows you to estimate assignment accuracies of Monte-Carlo cross-validation results. The output results can be used to make assignment accuracy plots (use function accuracy.plot). #' @param dir A character string to specify the folder that has your Monte-Carlo cross-validation results. A slash should be included at the end (e.g., dir="YourFolderName/"). diff --git a/R/accuracy.plot.R b/R/accuracy.plot.R index dcaa987..b48c146 100644 --- a/R/accuracy.plot.R +++ b/R/accuracy.plot.R @@ -6,6 +6,7 @@ #' @return This function returns a boxplot plot using the ggplot2 library. Users can modified the plot (e.g., change color, text, etc.) using functions provided by ggplot2 library. #' @import ggplot2 #' @importFrom reshape2 melt +#' @importFrom rlang .data #' @examples #' Your_df <- read.table(system.file("extdata/Rate.txt", package="assignPOP"), header=TRUE) #' accuracy.plot(Your_df, pop="all") @@ -14,6 +15,8 @@ accuracy.plot <- function(df, pop="all"){ #claim variables train.inds <- NULL; train.loci <- NULL; value <- NULL; KF <- NULL + #claim variables for aes use + train_inds <- "train.inds"; train_loci <- "train.loci"; KF_ <- "KF" #validate specified pop names df_popName <- substring(colnames(df)[4:ncol(df)], 13, 1000L) if(!all(pop %in% df_popName)){ #if specified pop name not in df @@ -43,7 +46,8 @@ accuracy.plot <- function(df, pop="all"){ col <- paste0("assign.rate.",pop) #see if multiple levels of train loci used.(e.g.,10%, 20%...of loci) if(length(unique(df$train.loci)) > 1 ){ - boxplot <- ggplot(df, aes_string(y=col, x="train.inds", fill="train.loci"))+ + ## boxplot <- ggplot(df, aes_string(y=col, x="train.inds", fill="train.loci"))+ # aes_string is deprecated in ggplot2 3.0 + boxplot <- ggplot(df, aes(y=.data[[col]], x=.data[[train_inds]], fill=.data[[train_loci]]))+ geom_boxplot()+ xlab(x_label) + ylab("Assignment accuracy")+ scale_fill_discrete(name="Prop. of\ntrain loci",guide=guide_legend(reverse=TRUE))+ @@ -58,7 +62,7 @@ accuracy.plot <- function(df, pop="all"){ return(boxplot) #see if only one level of train loci used (e.g.,used all loci) }else if(length(unique(df$train.loci))==1){ - boxplot <- ggplot(df, aes_string(y=col, x="train.inds"))+ + boxplot <- ggplot(df, aes(y=.data[[col]], x=.data[[train_inds]]))+ geom_boxplot()+ xlab(x_label) + ylab("Assignment accuracy")+ theme_bw()+ @@ -133,7 +137,7 @@ accuracy.plot <- function(df, pop="all"){ col <- paste0("assign.rate.",pop) # if(length(unique(df$train.loci)) > 1 ){ #see if multiple levels of train loci used.(e.g.,10%, 20%...of loci) - boxplot <- ggplot(df, aes_string(y=col, x="KF" ,fill="train.loci"))+ + boxplot <- ggplot(df, aes(y=.data[[col]], x=.data[[KF_]] ,fill=.data[[train_loci]]))+ geom_boxplot()+ #geom_point(size=5, position=dodge)+ xlab("K") + ylab("Assignment accuracy")+ @@ -149,7 +153,7 @@ accuracy.plot <- function(df, pop="all"){ return(boxplot) }else if(length(unique(df$train.loci))==1){ #see if only one level of train loci used (e.g.,used all loci) - boxplot <- ggplot(df, aes_string(y=col, x="KF"))+ + boxplot <- ggplot(df, aes(y=.data[[col]], x=.data[[KF_]]))+ geom_boxplot()+ xlab("K") + ylab("Assignment accuracy")+ theme_bw()+ diff --git a/README.md b/README.md index 11a74e4..49e99fd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -[![Travis-CI Build Status](https://travis-ci.org/alexkychen/assignPOP.svg?branch=master)](https://travis-ci.org/alexkychen/assignPOP) [![CRAN status](http://www.r-pkg.org/badges/version/assignPOP)](https://cran.r-project.org/package=assignPOP) [![GitHub release](https://img.shields.io/github/release/alexkychen/assignPOP.svg)](https://github.com/alexkychen/assignPOP/releases) [![license](https://img.shields.io/github/license/alexkychen/assignPOP.svg)](https://github.com/alexkychen/assignPOP/blob/master/LICENSE.md) @@ -36,12 +35,16 @@ Please visit our tutorial website for more infomration * [http://alexkychen.github.io/assignPOP/](http://alexkychen.github.io/assignPOP/) ## What's new -Changes in ver. 1.2.4 (2021.10.27) -- Update membership.plot - add argument 'plot.k' and 'plot.loci' to skip related question prompt. +Changes in ver. 1.3.0 (2024.3.13) +- Update accuracy.plot - adjust ggplot's aes_string() due to its deprecation. +- Update testthat test_accuracy and test_membership to pass CRAN evaluations.
History +Changes in ver. 1.2.4 (2021.10.27) +- Update membership.plot - add argument 'plot.k' and 'plot.loci' to skip related question prompt. + Changes in ver. 1.2.3 (2021.8.17) - Update assign.X - (1)Add argument 'common' to specify whether stopping the analysis when inconsistent features between data sets were found. (2)Add argument 'skipQ' to skip data type checking on non-genetic data. (3)Modify argument 'mplot' to handle membership probability plot output. diff --git a/assignPOP.Rproj b/assignPOP.Rproj index a48fc92..a32c6e1 100644 --- a/assignPOP.Rproj +++ b/assignPOP.Rproj @@ -15,5 +15,5 @@ LaTeX: pdfLaTeX BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageCheckArgs: --as-cran +PackageCheckArgs: --as-cran --no-manual PackageRoxygenize: rd,collate,namespace,vignette diff --git a/tests/testthat/test_accuracy.R b/tests/testthat/test_accuracy.R index 53673a7..ba6a3a2 100644 --- a/tests/testthat/test_accuracy.R +++ b/tests/testthat/test_accuracy.R @@ -5,7 +5,7 @@ test_that("Calculate assignment accuracy for Monte-Carlo results",{ expect_output(str(AccuMC),"data.frame") expect_true(file.exists("ResMCtest/Rate_of_3_tests_3_pops.txt")) plot <- accuracy.plot(AccuMC) - expect_output(str(plot), "List of 9") + expect_type(plot, "list") }) unlink("ResMCtest/Rate_of_3_tests_3_pops.txt") @@ -15,7 +15,7 @@ test_that("Calculate assignment accuracy for K-fold results",{ expect_output(str(AccuKF),"data.frame") expect_true(file.exists("ResKFtest/Rate_of_3_tests_3_pops.txt")) plot <- accuracy.plot(AccuKF) - expect_output(str(plot), "List of 9") + expect_type(plot, "list") }) unlink("ResKFtest/Rate_of_3_tests_3_pops.txt") diff --git a/tests/testthat/test_membership.R b/tests/testthat/test_membership.R index fa886f4..db1eb89 100644 --- a/tests/testthat/test_membership.R +++ b/tests/testthat/test_membership.R @@ -2,5 +2,5 @@ context("Test membership.prob.plot") test_that("Plot membership probability",{ plot <- membership.plot(dir="ResKFtest/", style=1, non.genetic=T) - expect_output(str(plot), "List of 10") + expect_type(plot, "list") }) \ No newline at end of file