Skip to content

Commit

Permalink
v2.2.7
Browse files Browse the repository at this point in the history
With joined plots, group labels and sorting, div lines were incorrectly printed causing plots to be misaligned. This has been resolved.
  • Loading branch information
royfrancis committed May 22, 2018
1 parent f8220c6 commit c9e9189
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 2,446 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Package: pophelper
Type: Package
Title: Tabulate, analyse and visualise admixture proportions from STRUCTURE, TESS, BAPS, ADMIXTURE and tab-delimited q-matrices
files
Version: 2.2.6
Date: 2018-05-02
Version: 2.2.7
Date: 2018-05-23
Author: Roy Mathew Francis
Authors@R: person("Roy", "Francis", email = "[email protected]",role = c("aut", "cre"))
Maintainer: Roy Mathew Francis <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
pophelper 2.2.7
===========
* 23-May-2018
* With joined plots, group labels and sorting, div lines were incorrectly printed causing plots to be misaligned. This has been resolved.

pophelper 2.2.6
===========
* 02-May-2018
Expand Down
40 changes: 22 additions & 18 deletions R/pophelper.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Begin ------------------------------------------------------------------------

# pophelper v2.2.6
# pophelper v2.2.7
# Functions
# 02-May-2018
# 23-May-2018

# check packages
pkgs <- c("Cairo","grid","gridExtra","ggplot2","gtable","tidyr")
Expand Down Expand Up @@ -2088,7 +2088,7 @@ grpLabels <- function(dframe=NULL,grplab=NA,selgrp=NA,subsetgrp=NA,ordergrp=FALS
marker_position$divxpos <- marker_position$markerxpos+0.5
# add runid
marker_position$run <- runid

return(list(dframe=dfwork1,grplab=grplab1,label_position=label_position,
marker_position=marker_position))
}
Expand Down Expand Up @@ -2509,7 +2509,7 @@ sortInd <- function(dframe=NULL,grplab=NA,selgrp=NA,ordergrp=FALSE,sortind=NA,gr
#' plotQ(qlist=slist[c(1,3)],sortind="all")
#' plotQ(qlist=slist[c(1,3)],sortind="Cluster1")
#' plotQ(qlist=slist[c(1,3)],sortind="label")
#' plotQ(qlist=slist[c(1,3)],sortind="all",imgoutput="join")
#' plotQ(qlist=slist[c(1,3)],sortind="all",imgoutput="join",sharedindlab=F)
#'
#' # read group labels
#' md <- read.delim(system.file("files/metadata.txt", package="pophelper"), header=T,stringsAsFactors=F)
Expand All @@ -2519,8 +2519,8 @@ sortInd <- function(dframe=NULL,grplab=NA,selgrp=NA,ordergrp=FALSE,sortind=NA,gr
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join")
#'
#' # sort within groups
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join",sortind="all")
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join",sortind="Cluster1")
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join",sortind="all",sharedindlab=F)
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join",sortind="Cluster1",sharedindlab=F)
#' plotQ(qlist=slist[1:2],grplab=md[,2,drop=F],imgoutput="join",sortind="label")
#'
#' # reorder groups
Expand Down Expand Up @@ -3017,6 +3017,7 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
list_qlist <- vector("list",length=flen)
list_grplab <- vector("list",length=flen)
}
div_multiplier <- seq(from=0,to=(flen-1))
for (i in seq_along(qlist))
{
fname <- names(qlist)[i]
Expand Down Expand Up @@ -3072,9 +3073,17 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
df1$ind <- as.character(rownames(df1))
df1$run <- factor(rep(i,nrow(df1)))
df1$order_ind <- seq(from=1,to=Ind)
order_cumulative <- seq(from=strt,to=(i*Ind))
df1$order_cumulative <- order_cumulative
strt <- (i*Ind)+1

# cumulative numbering
if(i==1) {
start <- 1
end <- Ind
}else{
start <- end+1
end <- Ind*i
}

df1$order_cumulative <- seq(from=start,to=end)

# strip panel labelling
if(any(is.na(splab)))
Expand Down Expand Up @@ -3102,16 +3111,11 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
if(grplabcheck)
{
div_position <- marker_position[c(marker_position$count %in% divgrp),]
div_position <- div_position[seq(from=2,to=(nrow(div_position)-1)),,drop=F]
div_position <- div_position[seq(from=2,to=(nrow(div_position)-1)),c("count","divxpos"),drop=F]
div_position$run <- i
if(i>1 && sortindcheck!="label" && sortindcheck!="empty")
{
div_position$divxpos <- div_position$divxpos+Ind
div_position$markerxpos <- div_position$markerxpos+Ind
}
if(sortindcheck!="label" && sortindcheck!="empty") div_position$divxpos <- div_position$divxpos+(Ind*div_multiplier[i])
div_position_list[[i]] <- div_position
}

rm(df2)
}

Expand Down Expand Up @@ -3170,7 +3174,7 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
# when ind labels are not shared, x-axis is free
if(sharedindlab) gg_plot_panel <- gg_plot_panel+facet_wrap(~run,labeller=labeller(run=facetnames),strip.position=sppos,scales="fixed",nrow=flen,drop=TRUE)
if(!sharedindlab) gg_plot_panel <- gg_plot_panel+facet_wrap(~run,labeller=labeller(run=facetnames),strip.position=sppos,scales="free_x",nrow=flen,drop=TRUE)

gg_plot_panel <- gg_plot_panel+
labs(x=NULL,y=NULL)+
theme(legend.position="top",
Expand Down Expand Up @@ -4526,7 +4530,7 @@ summarizeQ <- summariseQ

#ON LOAD
.onLoad <- function(...) {
packageStartupMessage("pophelper v2.2.6 ready.")
packageStartupMessage("pophelper v2.2.7 ready.")
}

# End --------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pophelper 2.2.6
# pophelper 2.2.7

`pophelper` is an R package and web app to analyse and visualise population structure. `pophelper` curently supports output run files generated from population analysis programs such as STRUCTURE, TESS, TESS3, BAPS and numeric delimited formats such as ADMIXTURE or fastSTRUCTURE. The `pophelper` package can be used to read run files to R, tabulate runs, summarise runs, estimate *K* using the Evanno method, align clusters within K using CLUMPP, export files for DISTRUCT and generate barplot figures.

Expand Down Expand Up @@ -63,4 +63,4 @@ The `pophelper` R package is offered free and without warranty of any kind, eith

If you have an comments, suggestions, corrections or ideas on ways to improve or extend this package, feel free to contact me. Submit a report on the [Github issues page](https://github.com/royfrancis/pophelper/issues).

2018 Roy M Francis
2018 | Roy M Francis
2 changes: 1 addition & 1 deletion inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ bibentry(bibtype = "Article",
pages = "27-32",
doi = "10.1111/1755-0998.12509",
url = "https://github.com/royfrancis/pophelper",
note = "pophelper R package version 2.2.6",
note = "pophelper R package version 2.2.7",
textVersion=
paste("Francis, R. M. (2017).",
"pophelper: an R package and web app to analyse and visualize population structure.",
Expand Down
6 changes: 3 additions & 3 deletions man/plotQ.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions tests/testmanual/test-all.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Test Script
# v2.2.6
# 02-May-2018
# v2.2.7
# 23-May-2018

library(testthat)
library(pophelper)
Expand Down Expand Up @@ -597,9 +597,15 @@ for(i in seq_along(imgout))
#multiple labels
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs)

#multiple labels change selgrp
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,selgrp="mixed")

#multiple labels grpmean
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T)

#multiple labels grpmean change selgrp
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T,selgrp="mixed")

#multiple labels grpmean ordergrp
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T,ordergrp=T)

Expand Down Expand Up @@ -634,7 +640,7 @@ for(i in seq_along(imgout))
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,ordergrp=TRUE,sortind="label",showindlab=TRUE)

#multiple labels grpmean
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T)
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T,showindlab=TRUE)

#multiple labels grpmean showindlab
plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,grpmean=T,showindlab=TRUE,width=15)
Expand Down Expand Up @@ -696,25 +702,25 @@ for(i in seq_along(imgout))
if(imgo=="join")
{
#sharedindlab off
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=F)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=F,outputfilename="joined")
#sharedindlab on
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,outputfilename="joined")
#sharedindlab on with sort label
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,sort="label")
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,sort="label",outputfilename="joined")
#sharedindlab with sort all
expect_error(plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sortind="all"))
#sharedindlab with sort cluster
expect_error(plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sortind="Cluster1"))
#sharedindlab off with grplab
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=F,grplab=grplabs)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=F,grplab=grplabs,outputfilename="joined")
#sharedindlab on with grplab
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,width=16)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,width=16,outputfilename="joined")
#shared indlab with repeated grplab
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grpsrep)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grpsrep,outputfilename="joined")
#sharedindlab with grplab subset
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,subsetgrp="a",width=16)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,subsetgrp="a",width=16,outputfilename="joined")
#sharedindlab with reorder
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,subsetgrp=c("b","a"),width=16)
plotQ(slist[1:2],imgoutput=imgo,showindlab=T,sharedindlab=T,grplab=grplabs,subsetgrp=c("b","a"),width=16,outputfilename="joined")
#error sharedindlab error
expect_error(plotQ(slist[1:2],imgoutput=imgo,grplab=grplabs,showindlab=T,sortind="Cluster1"))
#error ordergrp error
Expand Down
2,409 changes: 0 additions & 2,409 deletions vignettes/vignette.html

This file was deleted.

0 comments on commit c9e9189

Please sign in to comment.