Skip to content

Commit

Permalink
v0.3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
vertesy committed Jan 16, 2022
1 parent eca5762 commit 94f432f
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cff-version: 1.2.0
title: vertesy/ggExpress - the fastest way to create, annotate and and save plots in R.
version: v0.3.5
version: v0.3.6
message: >-
If you use this software, please cite it using these metadata.
type: software
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: ggExpress
Title: ggExpress is the fastest way to create, annotate and export plots
in R
Version: 0.3.5
Version: 0.3.6
Authors@R:
person("Abel", "Vertesy", , "[email protected]", role = c("aut", "cre"))
Author: Abel Vertesy <[email protected]> [aut, cre]
Expand Down Expand Up @@ -38,6 +38,6 @@ Imports:
stats,
tidyverse
Encoding: UTF-8
Packaged: 2021-12-14 20:42:20
Packaged: 2022-01-16 18:56:12
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
2 changes: 1 addition & 1 deletion Development/Create_the_ggExpress_Package.v0.1.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require('Stringendo')

# Setup ------------------------
PackageName = "ggExpress"
package.version = "0.3.5"
package.version = "0.3.6"
setwd("~/GitHub/Packages/")

RepositoryDir = kollapse("~/GitHub/Packages/", PackageName, "/")
Expand Down
47 changes: 26 additions & 21 deletions Development/Development.bac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ____________________________________________________________________
# ggExpress is the fastest way to create, annotate and export plots in R. ----
# ____________________________________________________________________
# try(source("~/GitHub/Packages/ggExpress/R/ggExpress.functions.R"), silent = T)
# try(source("https://raw.githubusercontent.com/vertesy/ggExpress/main/ggExpress.functions.R"), silent = T)
# try(source("~/GitHub/Packages/ggExpress/R/ggExpress.R"), silent = T)
# try(source("https://raw.githubusercontent.com/vertesy/ggExpress/main/ggExpress.R"), silent = T)

# ______________________________________________________________________________________________----
# Main plotting functions ----
Expand Down Expand Up @@ -36,7 +36,7 @@
#' @examples weight <- rnorm(1000); qhistogram(vec = weight); qhistogram(vec = weight, vline = 2, filtercol = -1)


qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdlink = FALSE
qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, suffix = NULL
, plotname = sppp(substitute(vec), suffix)
, logX = F, logY = F
Expand Down Expand Up @@ -102,7 +102,7 @@ qhistogram <- function(vec, ext = "pdf", xlab = F, plot = TRUE, save = TRUE, mdl
qdensity <- function(vec, ext = "pdf", xlab = F, plot = TRUE
, suffix = NULL
, plotname = sppp(substitute(vec), suffix)
, save = TRUE, mdlink = FALSE
, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, logX = F, logY = F
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, max.names = 50
Expand Down Expand Up @@ -161,7 +161,7 @@ qbarplot <- function(vec, ext = "pdf", plot = TRUE
, suffix = NULL
, plotname = sppp(substitute(vec), suffix)
# , title = F
, save = TRUE, mdlink = FALSE
, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, hline = F, filtercol = 1
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, col = as.character(1:3)[1]
Expand All @@ -175,17 +175,19 @@ qbarplot <- function(vec, ext = "pdf", plot = TRUE


if (isFALSE(xlab)) xlab = plotname
df <- qqqCovert.named.vec2tbl(namedVec = vec, thr = max.names)
df <- qqqCovert.named.vec2tbl(namedVec = vec, strip.too.many.names =F)
# nrCategories.DFcol1 <- length(unique(df[,1])); stopif( nrCategories.DFcol1 >100)

if (length(unique(df$"names")) == 1) df$"names" <- as.character(1:length(vec))
df[["colour"]] <- if (hline & filtercol != 0) {
if (filtercol == 1 ) (df$"value" > hline) else if (filtercol == -1 ) (df$"value" < hline)
} else if (length(col) == length(vec)) {
as.character(col)
} else {
as.character(rep(col, length(vec))[1:length(vec)])
}

df[["colour"]] <-
if (length(col) == length(vec)) {
as.character(col)
} else if (hline & filtercol != 0) {
if (filtercol == 1 ) (df$"value" > hline) else if (filtercol == -1 ) (df$"value" < hline)
} else {
as.character(rep(col, length(vec))[1:length(vec)])
}
print(df)

p <- ggpubr::ggbarplot(data = df, x = "names", y = "value"
Expand All @@ -195,6 +197,7 @@ qbarplot <- function(vec, ext = "pdf", plot = TRUE
, palette = palette_use, ...
) + ggpubr::grids(axis = 'y')

if (length(vec) > max.names) p <- p + ggplot2::guides(x = 'none')
if (hide.legend) { p <- p + ggplot2::theme(legend.position = "none"
, axis.text.x = ggplot2::element_text(angle = xlab.angle, hjust = 1) )
}
Expand Down Expand Up @@ -238,7 +241,7 @@ qbarplot <- function(vec, ext = "pdf", plot = TRUE
#' @examples xvec <- c("A"=12, "B"=29); qpie(vec = xvec)

qpie <- function(vec = Network.Size
, ext = "pdf", plot = TRUE, save = TRUE, mdlink = FALSE
, ext = "pdf", plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, suffix = NULL
, plotname = sppp(substitute(vec), suffix)
, LegendSide = TRUE
Expand All @@ -247,8 +250,9 @@ qpie <- function(vec = Network.Size
, custom.order = FALSE
, extended.canvas = TRUE
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, custom.margin = T
, max.categories = 100
, max.names = 5
, max.names = 10
, decr.order = TRUE
, both_pc_and_value = TRUE
, w = 5, h = w, ...) {
Expand All @@ -273,7 +277,7 @@ qpie <- function(vec = Network.Size

if (is.null(names(vec))) { names(vec) <- as.character(1:length(vec)) }

df <- qqqCovert.named.vec2tbl.v2(namedVec = vec, thr = max.names)
df <- qqqCovert.named.vec2tbl(namedVec = vec, thr = max.names)
if (l.orig > max.categories) df[['names']][length(df$'names')] <- name.of.last

pcX <- df$"value" / sum(df$"value")
Expand Down Expand Up @@ -363,7 +367,7 @@ qboxplot <- function(df_XYcol
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, ext = "png", also.pdf = T
, logY = F #, logX = F
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = FALSE
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, w = 7, h = w, ...) {
# plotname <- if (isFALSE(title)) Stringendo::kpp(make.names(as.character(substitute(df_XYcol))), suffix) else title
vars <- colnames(df_XYcol)
Expand Down Expand Up @@ -433,7 +437,7 @@ qviolin <- function(df_XYcol
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, ext = "png", also.pdf = T
, logY = F #, logX = F
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = FALSE
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, w = 7, h = w, ...) {
# plotname <- if (isFALSE(title)) Stringendo::kpp(make.names(as.character(substitute(df_XYcol))), suffix) else title
vars <- colnames(df_XYcol)
Expand Down Expand Up @@ -493,7 +497,7 @@ qscatter <- function(df_XYcol
, palette_use = c("RdBu", "Dark2", "Set2", "jco", "npg", "aaas", "lancet", "ucscgb", "uchicago")[4]
, ext = "png", also.pdf = T
, logX = F, logY = F
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = FALSE
, hline = F, vline = F, plot = TRUE, save = TRUE, mdlink = MarkdownHelpers::unless.specified('b.mdlink', def = F)
, w = 7, h = w, ...) {
# plotname <- if (isFALSE(title)) Stringendo::kpp(make.names(as.character(substitute(df_XYcol))), suffix) else title
vars <- colnames(df_XYcol)
Expand Down Expand Up @@ -608,13 +612,14 @@ qqqCovert.named.vec2tbl <- function(namedVec=1:14, verbose = F, strip.too.many.n

# Check naming issues
nr.uniq.names <- length(unique(names(namedVec)))
if (nr.uniq.names > thr & verbose) print("Vector has", thr, "+ names. Can mess up auto-color legends.")
if (nr.uniq.names > thr & verbose) iprint("Vector has", thr, "+ names. Can mess up auto-color legends.")
if (nr.uniq.names < 1 & verbose) print("Vector has no names")
an.issue.w.names <- (nr.uniq.names > thr | nr.uniq.names < 1 )

idx.elements.above.thr <- if (thr < length(namedVec)) thr:length(namedVec) else 1:length(namedVec)
if (strip.too.many.names & an.issue.w.names) names(namedVec)[idx.elements.above.thr] <- rep("", length(idx.elements.above.thr))
if (length(unique(names(namedVec))) > thr) print("Vector has", thr, "+ names. Can mess up auto-color legends.")

if (length(unique(names(namedVec))) > thr) iprint("Vector has", thr, "+ names. Can mess up auto-color legends.")

df <- tibble::as_tibble(cbind("value" = namedVec))
nm <- names(namedVec)
Expand Down
2 changes: 1 addition & 1 deletion man/qbarplot.Rd

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

2 changes: 1 addition & 1 deletion man/qboxplot.Rd

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

2 changes: 1 addition & 1 deletion man/qdensity.Rd

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

2 changes: 1 addition & 1 deletion man/qhistogram.Rd

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

5 changes: 3 additions & 2 deletions man/qpie.Rd

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

2 changes: 1 addition & 1 deletion man/qscatter.Rd

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

2 changes: 1 addition & 1 deletion man/qviolin.Rd

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

0 comments on commit 94f432f

Please sign in to comment.