Skip to content

Commit 49064be

Browse files
committed
re-styled code & roxygen2 docs, replaced jsonlite by yyjsonr, fixed removeNAs
1 parent 74c95ec commit 49064be

48 files changed

Lines changed: 695 additions & 667 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/R-CMD-check.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
33
on:
44
push:
5-
branches: [main]
5+
branches: [dev]
66

77
name: R-CMD-check.yaml
88

.github/workflows/pkgdown.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

DESCRIPTION

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: OmicFlow
22
Title: Fast and Efficient (Automated) Analysis of Sparse Omics Data
3-
Version: 1.6.0
3+
Version: 1.6.0.9001
44
Date: 2026-05-19
55
Authors@R: c(
66
person(
@@ -28,28 +28,23 @@ Config/testthat/edition: 3
2828
Encoding: UTF-8
2929
Roxygen: list(markdown = TRUE)
3030
Depends:
31-
R (>= 4.3.0),
31+
R (>= 4.3.0)
32+
Imports:
3233
R6,
3334
data.table,
34-
Matrix
35-
Imports:
35+
Matrix,
3636
ape,
3737
ggpubr,
3838
ggrepel,
3939
ggplot2,
40-
jsonlite,
4140
jsonvalidate,
42-
magrittr,
4341
methods,
4442
patchwork,
4543
RColorBrewer,
4644
rhdf5,
4745
rstatix,
4846
Rcpp (>= 0.12.6),
4947
RcppParallel (>= 4.3.20),
50-
stats,
51-
tools,
52-
utils,
5348
vegan,
5449
yyjsonr,
5550
cli

NAMESPACE

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -23,58 +23,20 @@ export(plot_pairwise_stats)
2323
export(proteomics)
2424
export(unifrac)
2525
export(volcano_plot)
26-
import(Matrix)
2726
import(R6)
27+
import(data.table)
28+
import(ggplot2)
2829
import(rhdf5)
2930
importFrom(Matrix,sparseMatrix)
30-
importFrom(RColorBrewer,brewer.pal)
31-
importFrom(RColorBrewer,brewer.pal.info)
3231
importFrom(Rcpp,sourceCpp)
33-
importFrom(RcppParallel,setThreadOptions)
34-
importFrom(ape,keep.tip)
3532
importFrom(ape,read.tree)
3633
importFrom(data.table,":=")
3734
importFrom(data.table,.SD)
38-
importFrom(ggplot2,.data)
39-
importFrom(ggplot2,aes)
40-
importFrom(ggplot2,coord_flip)
41-
importFrom(ggplot2,element_rect)
42-
importFrom(ggplot2,element_text)
43-
importFrom(ggplot2,facet_wrap)
44-
importFrom(ggplot2,geom_bar)
45-
importFrom(ggplot2,geom_boxplot)
46-
importFrom(ggplot2,geom_hline)
47-
importFrom(ggplot2,geom_label)
48-
importFrom(ggplot2,geom_point)
49-
importFrom(ggplot2,geom_segment)
50-
importFrom(ggplot2,geom_vline)
51-
importFrom(ggplot2,ggplot)
52-
importFrom(ggplot2,ggtitle)
53-
importFrom(ggplot2,labs)
54-
importFrom(ggplot2,position_jitter)
55-
importFrom(ggplot2,scale_color_gradient2)
56-
importFrom(ggplot2,scale_colour_manual)
57-
importFrom(ggplot2,scale_fill_manual)
58-
importFrom(ggplot2,scale_size_continuous)
59-
importFrom(ggplot2,scale_x_continuous)
60-
importFrom(ggplot2,scale_x_discrete)
61-
importFrom(ggplot2,stat_ellipse)
62-
importFrom(ggplot2,theme)
63-
importFrom(ggplot2,theme_bw)
64-
importFrom(jsonlite,read_json)
65-
importFrom(jsonlite,toJSON)
6635
importFrom(jsonvalidate,json_validate)
67-
importFrom(magrittr,"%>%")
68-
importFrom(methods,as)
6936
importFrom(patchwork,plot_layout)
7037
importFrom(patchwork,wrap_plots)
71-
importFrom(stats,as.dist)
72-
importFrom(stats,median)
73-
importFrom(stats,na.omit)
74-
importFrom(stats,p.adjust)
75-
importFrom(stats,p.adjust.methods)
76-
importFrom(stats,quantile)
77-
importFrom(tools,file_ext)
7838
importFrom(utils,globalVariables)
39+
importFrom(yyjsonr,read_json_file)
7940
importFrom(yyjsonr,validate_json_file)
41+
importFrom(yyjsonr,write_json_file)
8042
useDynLib(OmicFlow, .registration = TRUE)

NEWS.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# OmicFlow 1.6.0.9001
2+
3+
## Changed
4+
- Re-factoring `roxygen2` code & documentation style [IN PROGRESS].
5+
- TODO: Add `tryCatch` where neccessary
6+
- Replaced `jsonlite` by `yyjsonr` functionality, much faster and cleaner code.
7+
- Replaced `tests/testthat/input/metagenomics/biom_with_taxonomy_json.biom` with one from BIOM v2 example.
8+
9+
## Fixed
10+
- `omics$feature_merge` is optional in `omics$foldchange`
11+
- `omics$removeNAs` uses `stats::complete.cases` instead of `na.omit`
12+
113
# OmicFlow 1.6.0 (2026-05-19)
214

315
## Added

R/OmicFlow-package.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
"_PACKAGE"
33

44
## usethis namespace: start
5-
#' @importFrom magrittr %>%
65
#' @importFrom data.table := .SD
7-
#' @importFrom stats na.omit p.adjust
8-
#' @useDynLib OmicFlow, .registration = TRUE
96
#' @importFrom Rcpp sourceCpp
7+
#' @useDynLib OmicFlow, .registration = TRUE
108
#' @importFrom utils globalVariables
119
## usethis namespace: end
1210

R/bray.R

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
#' When weighted is set to FALSE, counts are replaced by presence/absence data.
1313
#'
1414
#' @param x A \link[base]{matrix}, \link[Matrix]{sparseMatrix} or \link[Matrix]{Matrix}.
15-
#' @param weighted A boolean value, to use abundances (\code{weighted = TRUE}) or absence/presence (\code{weighted=FALSE}) (default: TRUE).
16-
#' @param threads A wholenumber, the number of threads to use in \link[RcppParallel]{setThreadOptions} (default: 1).
15+
#' @param weighted A boolean value, to use abundances (\code{weighted = TRUE}) or absence/presence (\code{weighted=FALSE}) (default: \code{TRUE}).
16+
#' @param threads A wholenumber, the number of threads to use in \link[RcppParallel]{setThreadOptions} (default: \code{1}).
1717
#' @return A column x column \link[stats]{dist} object.
1818
#' @references
1919
#' Bray, J.R. & Curtis, J.T. (1957) An Ordination of the Upland Forest Communities of Southern Wisconsin. Ecological Monographs, 27(4), 325–349.
@@ -36,17 +36,15 @@
3636
#' taxa$scale(method = "tss")
3737
#'
3838
#' bray(taxa$countData)
39-
#' @importFrom RcppParallel setThreadOptions
4039
#' @importFrom Matrix sparseMatrix
41-
#' @importFrom stats as.dist
4240
#' @export
4341

4442
bray <- function(x, weighted = TRUE, threads = 1) {
4543

4644
## Error handling
4745
#--------------------------------------------------------------------#
4846
if (inherits(x, "denseMatrix") || inherits(x, "matrix") || inherits(x, "sparseMatrix")) {
49-
x <- as(x, "CsparseMatrix")
47+
x <- methods::as(x, "CsparseMatrix")
5048
} else cli::cli_abort("Input isn't a {.cls matrix}, {.cls denseMatrix} or {.cls sparseMatrix}.")
5149

5250
if (!is.numeric(x@x))
@@ -67,5 +65,5 @@ bray <- function(x, weighted = TRUE, threads = 1) {
6765
if (!is.null(col_names))
6866
dimnames(out) <- list(col_names, col_names)
6967

70-
return(as.dist(out))
68+
return(stats::as.dist(out))
7169
}

R/canberra.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
#' where \eqn{A_i} and \eqn{B_i} are the abundances of the \eqn{i}-th feature in sample \eqn{A} and \eqn{B}, respectively. NZ are the number of non-zero entries.
1212
#' When weighted is set to FALSE, counts are replaced by presence/absence data.
1313
#'
14-
#' @param x A \link[base]{matrix}, \link[Matrix]{sparseMatrix} or \link[Matrix]{Matrix}.
15-
#' @param weighted A boolean value, to use abundances (\code{weighted = TRUE}) or absence/presence (\code{weighted=FALSE}) (default: TRUE).
16-
#' @param threads A wholenumber, the number of threads to use in \link[RcppParallel]{setThreadOptions} (default: 1).
14+
#' @inheritParams bray
1715
#' @return A column x column \link[stats]{dist} object.
1816
#' @references
1917
#' Lance, G.N. & Williams, W.T. (1967) Mixed-data classificatory programs. I. Agglomerative systems. Australian Computer Journal, 1(1), 15-20.
@@ -36,9 +34,7 @@
3634
#' taxa$scale(method = "tss")
3735
#'
3836
#' canberra(taxa$countData)
39-
#' @importFrom RcppParallel setThreadOptions
4037
#' @importFrom Matrix sparseMatrix
41-
#' @importFrom stats as.dist
4238
#' @export
4339

4440
canberra <- function(x, weighted = TRUE, threads = 1) {
@@ -49,7 +45,7 @@ canberra <- function(x, weighted = TRUE, threads = 1) {
4945
cli::cli_abort("Input must a matrix of class matrix or Matrix, not a vector.")
5046

5147
if (inherits(x, "denseMatrix") || inherits(x, "matrix") || inherits(x, "sparseMatrix")) {
52-
x <- as(x, "CsparseMatrix")
48+
x <- methods::as(x, "CsparseMatrix")
5349
} else cli::cli_abort("Input isn't a {.cls matrix}, {.cls denseMatrix} or {.cls sparseMatrix}.")
5450

5551
if (!is.numeric(x@x))
@@ -70,5 +66,5 @@ canberra <- function(x, weighted = TRUE, threads = 1) {
7066
if (!is.null(col_names))
7167
dimnames(out) <- list(col_names, col_names)
7268

73-
return(as.dist(out))
69+
return(stats::as.dist(out))
7470
}

R/colormap.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#'
1919
#' colors <- colormap(data = dt,
2020
#' col_name = "treatment")
21-
#' @importFrom RColorBrewer brewer.pal.info brewer.pal
2221
#' @export
2322

2423
colormap <- function(data,

R/composition_plot.R

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
#' @param title_name A character to set the \code{ggtitle} of the \link[ggplot2]{ggplot}, (Default: NULL).
1010
#' @param group_by A character variable to aggregate the stacked bars by group (Default: NULL).
1111
#' @return A \link[ggplot2]{ggplot2} object to be further modified
12-
#'
13-
#' @importFrom ggplot2 ggplot aes .data geom_bar coord_flip theme_bw theme element_text scale_x_discrete scale_fill_manual labs ggtitle
1412
#'
1513
#' @examples
16-
#' library("ggplot2")
17-
#'
1814
#' # Create mock_data as data.frame (data.table is also supported)
1915
#' mock_data <- data.frame(
2016
#' SAMPLE_ID = rep(paste0("Sample", 1:10), each = 5),
@@ -67,6 +63,7 @@
6763
#' title_name = "Mock Genus Composition by Group",
6864
#' group_by = "Group"
6965
#' )
66+
#' @import ggplot2
7067
#' @export
7168

7269
composition_plot <- function(data,
@@ -108,51 +105,60 @@ composition_plot <- function(data,
108105

109106
# Generates a stacked barplot as base with custome palette
110107
if (!is.null(group_by)) {
111-
plt <- data %>%
112-
ggplot(mapping = aes(y = .data[["value"]],
113-
x = as.factor(.data[[ group_by ]]),
114-
fill = .data[[ feature_rank ]]))
108+
plt <- ggplot2::ggplot(
109+
data = data,
110+
mapping = ggplot2::aes(
111+
y = .data[["value"]],
112+
x = as.factor(.data[[ group_by ]]),
113+
fill = .data[[ feature_rank ]]
114+
)
115+
)
115116
} else {
116-
plt <- data %>%
117-
ggplot(mapping = aes(y = .data[["value"]],
118-
x = .data[["SAMPLE_ID"]],
119-
fill = base::get(feature_rank, data)))
117+
plt <- ggplot2::ggplot(
118+
data = data,
119+
mapping = ggplot2::aes(
120+
y = .data[["value"]],
121+
x = .data[["SAMPLE_ID"]],
122+
fill = base::get(feature_rank, data)
123+
)
124+
)
120125
}
121126
# Required for stacked barplot
122127
plt <- plt +
123-
geom_bar(
128+
ggplot2::geom_bar(
124129
position = "fill",
125130
stat = "identity"
126131
)
127132

128133
if (is.null(group_by)) {
129134
plt <- plt +
130-
coord_flip()
135+
ggplot2::coord_flip()
131136
}
132137
plt <- plt +
133-
theme_bw() +
134-
theme(
135-
plot.title = element_text(size = 14, face = "bold"),
136-
plot.subtitle = element_text(size = 13),
137-
axis.text.x = element_text(angle = 90, size = 12,
138-
vjust = 0.5, hjust=1,
139-
colour = "black"),
140-
axis.title.y = element_text(size = 12),
141-
axis.title.x = element_text(size = 12, vjust=0.5),
142-
legend.title = element_text(size = 14, face = "bold"),
143-
legend.text = element_text(size = 12, colour = "black"),
144-
axis.text.y = element_text(colour = "black", size = 12)
138+
ggplot2::theme_bw() +
139+
ggplot2::theme(
140+
plot.title = ggplot2::element_text(size = 14, face = "bold"),
141+
plot.subtitle = ggplot2::element_text(size = 13),
142+
axis.text.x = ggplot2::element_text(
143+
angle = 90, size = 12,
144+
vjust = 0.5, hjust=1,
145+
colour = "black"
146+
),
147+
axis.title.y = ggplot2::element_text(size = 12),
148+
axis.title.x = ggplot2::element_text(size = 12, vjust=0.5),
149+
legend.title = ggplot2::element_text(size = 14, face = "bold"),
150+
legend.text = ggplot2::element_text(size = 12, colour = "black"),
151+
axis.text.y = ggplot2::element_text(colour = "black", size = 12)
145152
)
146153

147154
if (is.null(group_by)) {
148155
plt <- plt +
149-
scale_x_discrete(limits = rev(levels(as.factor(data[["SAMPLE_ID"]]))))
156+
ggplot2::scale_x_discrete(limits = rev(levels(as.factor(data[["SAMPLE_ID"]]))))
150157
}
151158
plt <- plt +
152-
scale_fill_manual(values = palette, name = feature_rank) +
153-
labs(y = "Rel. Abun.",
154-
x = NULL) +
155-
ggtitle(title_name)
159+
ggplot2::scale_fill_manual(values = palette, name = feature_rank) +
160+
ggplot2::labs(y = "Rel. Abun.", x = NULL) +
161+
ggplot2::ggtitle(title_name)
156162

157163
return(plt)
158164
}

0 commit comments

Comments
 (0)