diff --git a/NEWS b/NEWS
index a359655..06bd06d 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ pophelper 2.3.1
* Automatic CI testing added
* Fixed an issue where runs merged using mergeQ() produced a warning about missing attributes.
* In function clumppExport() and distructExport(), argument 'path' changed to 'exportpath' to be consistent with other functions.
+* Legend is now sorted numerically
* Fixed minor errors in documentation.
pophelper 2.3.0
diff --git a/NEWS.md b/NEWS.md
index 608bb56..01f65a5 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -10,6 +10,7 @@
* Automatic CI testing added
* Fixed an issue where runs merged using mergeQ() produced a warning about missing attributes.
* In function clumppExport() and distructExport(), argument 'path' changed to 'exportpath' to be consistent with other functions.
+* Legend is now sorted numerically
* Fixed minor errors in documentation.
# pophelper 2.3.0
diff --git a/R/plot.R b/R/plot.R
index 068129b..b1f44a4 100644
--- a/R/plot.R
+++ b/R/plot.R
@@ -1164,7 +1164,12 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
# legendlab
if(any(is.na(legendlab)))
{
- legendlab1 <- levels(factor(as.character(df2$variable)))
+ if(all(grepl("Cluster",df2$variable))){
+ legendlab1 <- paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",df2$variable)))))
+ }else{
+ legendlab1 <- levels(factor(as.character(df2$variable)))
+ }
+
}else{
legendlab1 <- legendlab
}
@@ -1194,7 +1199,12 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
width1 <- as.numeric(dimtemp[2])
grplabheight1 <- as.numeric(dimtemp[3])
units1 <- as.character(dimtemp[4])
-
+
+ # order legend numerically
+ if(all(grepl("Cluster",df2$variable))){
+ df2$variable <- factor(df2$variable,levels=paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",df2$variable))))))
+ }
+
## COMMON PLOT TOP PANEL ---------------------------------------------------
# create plot
gg_plot_panel <- ggplot(data=df2,aes(x=order_ind,y=value,fill=variable))+
@@ -1563,7 +1573,11 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
# legendlab
if(any(is.na(legendlab)))
{
- legendlab1 <- levels(factor(as.character(df3$variable)))
+ if(all(grepl("Cluster",df3$variable))){
+ legendlab1 <- paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",df3$variable)))))
+ }else{
+ legendlab1 <- levels(factor(as.character(df3$variable)))
+ }
}else{
legendlab1 <- legendlab
}
@@ -1583,6 +1597,11 @@ plotQ <- function(qlist=NULL,imgoutput="sep",clustercol=NA,sortind=NA,grplab=NA,
if(any(is.na(clustercol))) coll <- getColours(as.integer(max(kvec)))
if(length(coll) < max(kvec)) stop(paste0("plotQ: Number of colours (",length(coll),") is less than the number of clusters (",max(kvec),")."))
+ # order legend numerically
+ if(all(grepl("Cluster",df3$variable))){
+ df3$variable <- factor(df3$variable,levels=paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",df3$variable))))))
+ }
+
## COMMON PLOT TOP PANEL ----------------------------------------------------
# create plot
# when unsorted or sorting is by label, x-axis is by individual order
@@ -2312,6 +2331,7 @@ plotQMultiline <- function(qlist=NULL,spl=NA,lpp=NA,clustercol=NA,sortind=NA,grp
if(length(coll) < ncol(dff)) stop(paste0("plotQMultiline: Number of colours (",length(coll),") is less than the number of clusters (",ncol(dff),")."))
if(any(is.na(legendlab))) legendlab1 <- colnames(dff)
+ #if(any(is.na(legendlab))) legendlab1 <- paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",dff$variable)))))
dff$ind <- factor(rownames(dff),levels=rownames(dff))
#dff$ind <- as.character(rownames(dff))
@@ -2325,6 +2345,9 @@ plotQMultiline <- function(qlist=NULL,spl=NA,lpp=NA,clustercol=NA,sortind=NA,grp
dff[[selgrp]] <- factor(dff[[selgrp]],levels=rle(dff[[selgrp]])$values)
}
+ # order legend numerically
+ #dff$variable <- factor(dff$variable,levels=paste0("Cluster",sort(as.integer(unique(gsub("Cluster","",dff$variable))))))
+
# split and plot rows
dlist <- split(dff,dff$rows)
plist <- vector("list",length=nr2)
diff --git a/docs/404.html b/docs/404.html
index 1b7ba1f..02f4425 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -118,7 +118,7 @@
-
-
+
diff --git a/docs/articles/index.html b/docs/articles/index.html
index e8c5b1f..97ed2e8 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -103,7 +103,7 @@ Pophelper 2.3.1
-Roy Francis | 27-Dec-2020
+Roy Francis | 29-Dec-2020
Introduction
diff --git a/docs/articles/index_files/figure-html/unnamed-chunk-92-1.svg b/docs/articles/index_files/figure-html/unnamed-chunk-92-1.svg
index bb342ab..6d78af8 100644
--- a/docs/articles/index_files/figure-html/unnamed-chunk-92-1.svg
+++ b/docs/articles/index_files/figure-html/unnamed-chunk-92-1.svg
@@ -102,36 +102,33 @@
-
+
-
+
-
-
-
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -192,21 +189,18 @@
-
+
-
+
-
-
-
-
+
-
+
@@ -1773,12 +1767,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -1802,12 +1796,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
@@ -2233,17 +2227,17 @@
-
+
-
+
-
+
-
+
@@ -2253,27 +2247,27 @@
-
+
-
-
+
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
@@ -2282,8 +2276,8 @@
-
-
+
+
diff --git a/docs/authors.html b/docs/authors.html
index bd79ae4..5342b2f 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -118,7 +118,7 @@
-
-
+
diff --git a/docs/index.html b/docs/index.html
index 8ccc696..4b58311 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -76,7 +76,7 @@
-
-
+
@@ -97,7 +97,7 @@
pophelper
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 and across K and generate barplot figures.
-For a detailed demonstration and walkthrough, refer the online vignette. For information about changes in the latest version, visit this GitHub page.
+For a detailed demonstration and walkthrough, refer the online vignette. For information about changes in the latest version, check version history.
Latest changes
@@ -161,7 +161,7 @@
Disclaimer
-
The pophelper R package is offered free and without warranty of any kind, either expressed or implied. I will not be held liable to you for any damage arising out of the use, modification or inability to use this program. pophelper R package can be used, redistributed and/or modified freely for non-commercial purposes subject to the original source being properly cited. Licensed under GPL-3. Please make sure you verify all your results.
+
This R package is offered free and without warranty of any kind, either expressed or implied. I will not be held liable to you for any damage arising out of the use, modification or inability to use this program. This R package can be used, redistributed and/or modified freely for non-commercial purposes subject to the original source being properly cited. Licensed under GPL-3. Please make sure you verify all your results.
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
index 255d1fa..f66ea94 100644
--- a/docs/pkgdown.yml
+++ b/docs/pkgdown.yml
@@ -3,7 +3,7 @@ pkgdown: 1.6.1
pkgdown_sha: ~
articles:
index: index.html
-last_built: 2020-12-27T21:27Z
+last_built: 2020-12-29T00:10Z
urls:
reference: https://github.com/royfrancis/pophelper/reference
article: https://github.com/royfrancis/pophelper/articles
diff --git a/docs/reference/alignK.html b/docs/reference/alignK.html
index 9d3485a..116fe9e 100644
--- a/docs/reference/alignK.html
+++ b/docs/reference/alignK.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/analyseQ.html b/docs/reference/analyseQ.html
index be227f0..06cb61f 100644
--- a/docs/reference/analyseQ.html
+++ b/docs/reference/analyseQ.html
@@ -123,7 +123,7 @@
-
-
+
diff --git a/docs/reference/as.qlist.html b/docs/reference/as.qlist.html
index 097e339..005a8c8 100644
--- a/docs/reference/as.qlist.html
+++ b/docs/reference/as.qlist.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/clumppExport.html b/docs/reference/clumppExport.html
index 8f4ba4c..86f5ef6 100644
--- a/docs/reference/clumppExport.html
+++ b/docs/reference/clumppExport.html
@@ -122,7 +122,7 @@
-
-
+
diff --git a/docs/reference/collectClumppOutput.html b/docs/reference/collectClumppOutput.html
index cc9f018..5fb8407 100644
--- a/docs/reference/collectClumppOutput.html
+++ b/docs/reference/collectClumppOutput.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/collectRunsTess.html b/docs/reference/collectRunsTess.html
index f50bc56..2afb8cf 100644
--- a/docs/reference/collectRunsTess.html
+++ b/docs/reference/collectRunsTess.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/distructColours.html b/docs/reference/distructColours.html
index 0d10f95..cf2fbb6 100644
--- a/docs/reference/distructColours.html
+++ b/docs/reference/distructColours.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/distructExport.html b/docs/reference/distructExport.html
index 7677ab0..790c3e6 100644
--- a/docs/reference/distructExport.html
+++ b/docs/reference/distructExport.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/evannoMethodStructure.html b/docs/reference/evannoMethodStructure.html
index ba6a782..090a11a 100644
--- a/docs/reference/evannoMethodStructure.html
+++ b/docs/reference/evannoMethodStructure.html
@@ -122,7 +122,7 @@
-
-
+
diff --git a/docs/reference/index.html b/docs/reference/index.html
index ce45661..f9725b8 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -118,7 +118,7 @@
-
-
+
diff --git a/docs/reference/is.qlist.html b/docs/reference/is.qlist.html
index 431cd3e..a45c965 100644
--- a/docs/reference/is.qlist.html
+++ b/docs/reference/is.qlist.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/joinQ.html b/docs/reference/joinQ.html
index d5f7c75..d3991dc 100644
--- a/docs/reference/joinQ.html
+++ b/docs/reference/joinQ.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/mergeQ.html b/docs/reference/mergeQ.html
index b3403a0..2d46727 100644
--- a/docs/reference/mergeQ.html
+++ b/docs/reference/mergeQ.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/plotQ.html b/docs/reference/plotQ.html
index 73a674e..db2b574 100644
--- a/docs/reference/plotQ.html
+++ b/docs/reference/plotQ.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/plotQMultiline.html b/docs/reference/plotQMultiline.html
index b6c72f9..9713148 100644
--- a/docs/reference/plotQMultiline.html
+++ b/docs/reference/plotQMultiline.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/readQ.html b/docs/reference/readQ.html
index 31dcdaf..13a20bf 100644
--- a/docs/reference/readQ.html
+++ b/docs/reference/readQ.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQBaps.html b/docs/reference/readQBaps.html
index eff76e9..9523b0f 100644
--- a/docs/reference/readQBaps.html
+++ b/docs/reference/readQBaps.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQBasic.html b/docs/reference/readQBasic.html
index ad2f2f0..1d8eb6b 100644
--- a/docs/reference/readQBasic.html
+++ b/docs/reference/readQBasic.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQClumpp.html b/docs/reference/readQClumpp.html
index 117fcf3..98e0ae2 100644
--- a/docs/reference/readQClumpp.html
+++ b/docs/reference/readQClumpp.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQStructure.html b/docs/reference/readQStructure.html
index 80af5c0..50ebcf2 100644
--- a/docs/reference/readQStructure.html
+++ b/docs/reference/readQStructure.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQTess.html b/docs/reference/readQTess.html
index f6ba3aa..2c39d90 100644
--- a/docs/reference/readQTess.html
+++ b/docs/reference/readQTess.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/readQTess3.html b/docs/reference/readQTess3.html
index 02fbffe..e11981e 100644
--- a/docs/reference/readQTess3.html
+++ b/docs/reference/readQTess3.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/sortQ.html b/docs/reference/sortQ.html
index 929905d..2f1daa2 100644
--- a/docs/reference/sortQ.html
+++ b/docs/reference/sortQ.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/splitQ.html b/docs/reference/splitQ.html
index d1c43d5..cf46aae 100644
--- a/docs/reference/splitQ.html
+++ b/docs/reference/splitQ.html
@@ -119,7 +119,7 @@
-
-
+
diff --git a/docs/reference/summariseQ.html b/docs/reference/summariseQ.html
index 05289bf..5a664fc 100644
--- a/docs/reference/summariseQ.html
+++ b/docs/reference/summariseQ.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/tabulateQ.html b/docs/reference/tabulateQ.html
index 360b12d..f1e6105 100644
--- a/docs/reference/tabulateQ.html
+++ b/docs/reference/tabulateQ.html
@@ -120,7 +120,7 @@
-
-
+
diff --git a/docs/reference/verifyGrplab.html b/docs/reference/verifyGrplab.html
index 1506e2f..e2a9887 100644
--- a/docs/reference/verifyGrplab.html
+++ b/docs/reference/verifyGrplab.html
@@ -119,7 +119,7 @@