Skip to content

Commit

Permalink
update to 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkychen committed Mar 13, 2024
1 parent b05e9c9 commit 050909b
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
^.*\.Rproj$
^\.Rproj\.user$
.travis.yml
LICENSE.md
LICENSE.md
README.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.Rhistory
.RData
.Ruserdata
.Rbuildignore
.travis.yml
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -27,6 +27,7 @@ Imports:
reshape2,
stringr,
tree,
rlang,
Suggests:
gtable,
iterators,
Expand All @@ -36,5 +37,5 @@ Suggests:
rmarkdown,
testthat
License: GPL (>= 2)
RoxygenNote: 7.1.1
RoxygenNote: 7.3.1
Encoding: UTF-8
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/accuracy.MC.R
Original file line number Diff line number Diff line change
@@ -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/").
Expand Down
12 changes: 8 additions & 4 deletions R/accuracy.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand 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
Expand Down Expand Up @@ -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))+
Expand All @@ -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()+
Expand Down Expand Up @@ -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")+
Expand All @@ -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()+
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.

<details>
<summary>History</summary>

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.

Expand Down
2 changes: 1 addition & 1 deletion assignPOP.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/testthat/test_accuracy.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_membership.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

0 comments on commit 050909b

Please sign in to comment.