Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major POMA Update 2023 #12

Merged
merged 58 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
754bae9
new POMA palettes
pcastellanoescuder Feb 9, 2023
e989f41
theme
pcastellanoescuder Feb 10, 2023
ddb511d
boxplot and density plot
pcastellanoescuder Feb 10, 2023
abb25d3
volcano
pcastellanoescuder Feb 10, 2023
9c25215
minor change in boxplot theme default params
pcastellanoescuder Feb 13, 2023
2f4adc0
quantile normalization
pcastellanoescuder Mar 29, 2023
ed3114d
sum normalization
pcastellanoescuder Mar 29, 2023
db1aca6
palette and bug fixes
pcastellanoescuder Mar 30, 2023
e32061e
minor bug fix
pcastellanoescuder Mar 30, 2023
c83dfbb
minor bug fix 2
pcastellanoescuder Mar 30, 2023
095a014
new PomaImpute
pcastellanoescuder Jun 21, 2023
f7c7a8e
update PomaNorm
pcastellanoescuder Jun 22, 2023
3e4c203
update PomaUnivariate
pcastellanoescuder Jun 22, 2023
6d862c2
update PomaUnivariate done
pcastellanoescuder Jun 22, 2023
c8716e5
fix SummarizedExperiment fun
pcastellanoescuder Jun 24, 2023
9d7c337
boxplots and densityplots
pcastellanoescuder Jun 26, 2023
b2e7b10
heatmap
pcastellanoescuder Jun 26, 2023
4973301
norm for df with 1 cols
pcastellanoescuder Jun 27, 2023
b4f7019
PomaUni docs
pcastellanoescuder Jun 27, 2023
6d10fb1
lm, pca, DEseq, and minor changes
pcastellanoescuder Jun 28, 2023
9961573
lm, pca, DEseq, and minor changes 2
pcastellanoescuder Jun 28, 2023
c806a29
PomaPLS almost done
pcastellanoescuder Jun 28, 2023
a87b7a4
working on PomaLMM
pcastellanoescuder Jun 28, 2023
5ec0004
PomaLMM
pcastellanoescuder Jun 29, 2023
452b1ed
minor documentation changes in LM and LMM
pcastellanoescuder Jul 5, 2023
bf4ed40
plot for PomaLM
pcastellanoescuder Jul 24, 2023
87cd151
Upper case for POMA features
pcastellanoescuder Jul 27, 2023
bc985cf
Upper case for POMA features 2
pcastellanoescuder Jul 27, 2023
b4f4243
metadata without caps
pcastellanoescuder Jul 28, 2023
f53d4c2
random forest
pcastellanoescuder Aug 3, 2023
497650a
volcano plot
pcastellanoescuder Aug 3, 2023
305218b
update LM plot
pcastellanoescuder Aug 11, 2023
511a13f
ad hoc tests in PomaUnivariate
pcastellanoescuder Aug 29, 2023
955c8cd
review PomaDESeq
pcastellanoescuder Aug 29, 2023
0aa6ef0
bug in univariate
pcastellanoescuder Aug 29, 2023
2c306b0
bump version
pcastellanoescuder Aug 29, 2023
220471a
bump version 2
pcastellanoescuder Aug 29, 2023
ca08da1
fix volcano
pcastellanoescuder Sep 5, 2023
d35120c
limma
pcastellanoescuder Sep 13, 2023
7ecd179
PomaCor
pcastellanoescuder Sep 13, 2023
2920e90
rank prod done
pcastellanoescuder Sep 14, 2023
20371c2
poma outliers
pcastellanoescuder Sep 15, 2023
7e0be79
test
pcastellanoescuder Sep 16, 2023
a07ba46
lasso
pcastellanoescuder Sep 17, 2023
55ccbcd
fix bug in quantile normalization
pcastellanoescuder Nov 8, 2023
1012ded
enable PomaOutliers without colData groups
pcastellanoescuder Nov 8, 2023
3b55cd3
enable PomaOutliers without colData groups 2
pcastellanoescuder Nov 8, 2023
7de539f
PomaClust done
pcastellanoescuder Nov 9, 2023
3f9c7aa
all functions complete
pcastellanoescuder Nov 13, 2023
54db24b
UMAP sample names
pcastellanoescuder Nov 14, 2023
b262216
fix volcano
pcastellanoescuder Nov 16, 2023
1eae9df
optional post-hoc test in PomaUnivariate
pcastellanoescuder Nov 16, 2023
0696727
fix PomaClust
pcastellanoescuder Nov 16, 2023
39e5a69
fix PomaClust
pcastellanoescuder Nov 20, 2023
652b2a7
fix PomaOutliers
pcastellanoescuder Nov 20, 2023
f5eb24d
working on tests 1
pcastellanoescuder Dec 6, 2023
1b23d90
ready to PR devel
pcastellanoescuder Dec 6, 2023
6298ca6
Update R-CMD-check.yml
pcastellanoescuder Dec 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions .github/workflows/R-CMD-check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

name: R-CMD-check

Expand All @@ -20,7 +20,7 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
#- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down
12 changes: 9 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: POMA
Title: Tools for Omics Data Analysis
Version: 1.7.19
Version: 1.8.47
Authors@R:
c(person(given = "Pol",
family = "Castellano-Escuder",
Expand All @@ -13,7 +13,7 @@ Description:
and statistical analysis of omics datasets. The main aim of POMA is to enable a flexible data cleaning and
statistical analysis processes in one comprehensible and user-friendly R package. This package has a Shiny app
version called POMAShiny that implements all POMA functions. See https://github.com/pcastellanoescuder/POMAShiny.
See Castellano-Escuder P, González-Domínguez R, Carmona-Pontaque F, et al. (2021) <doi:10.1371/journal.pcbi.1009148>
See Castellano-Escuder et al. (2021) <doi:10.1371/journal.pcbi.1009148>
for more details.
License: GPL-3
Encoding: UTF-8
Expand All @@ -40,16 +40,22 @@ Imports:
dbscan,
dplyr,
DESeq2,
FSA,
ggplot2,
ggrepel,
glasso (>= 1.11),
glmnet,
impute,
janitor,
limma,
lme4,
magrittr,
MASS,
Matrix,
mixOmics,
randomForest,
RankProd (>= 3.14),
rlang,
rmarkdown,
SummarizedExperiment,
tibble,
Expand All @@ -66,7 +72,7 @@ Suggests:
tidyverse,
testthat (>= 2.3.2)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Depends: R (>= 4.0)
VignetteBuilder: knitr
URL: https://github.com/pcastellanoescuder/POMA
Expand Down
15 changes: 12 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,32 @@ export("%>%")
export(PomaBoxplots)
export(PomaClust)
export(PomaCorr)
export(PomaCreateObject)
export(PomaDESeq)
export(PomaDensity)
export(PomaEDA)
export(PomaHeatmap)
export(PomaImpute)
export(PomaLM)
export(PomaLMM)
export(PomaLasso)
export(PomaLimma)
export(PomaMultivariate)
export(PomaNorm)
export(PomaOddsRatio)
export(PomaOutliers)
export(PomaPCA)
export(PomaPCR)
export(PomaPLS)
export(PomaRandForest)
export(PomaRankProd)
export(PomaSummarizedExperiment)
export(PomaUMAP)
export(PomaUnivariate)
export(PomaVolcano)
export(poma_pal_c)
export(poma_pal_d)
export(scale_color_poma_c)
export(scale_color_poma_d)
export(scale_fill_poma_c)
export(scale_fill_poma_d)
export(theme_poma)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
17 changes: 16 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# POMA 1.8.47

* New POMA theme and colorblind-friendly palette
* Available sample normalization (sum and quantile)
* New feature normalization methods
* Extensive review and improvement of all `POMA` functions
* Major documentation updates
* Rename `PomaSummarizedExperiment` to `PomaCreateObject`
* Auto-recognition of variable types and automatic variable re-labeling in `PomaCreateObject`
* Available violin plots with `PomaBoxplots`
* New functions `PomaPCA` and `PomaPLS` as stand-alone functions from the old `PomaMultivariate` (deprecated)
* Other new functions: `PomaLM`, `PomaLMM`
* Post-hoc pairwise comparisons in `PomaUnivariate`
* Update tests and vignettes

# POMA 1.7.19

* New `biocViews` and `Description`
Expand All @@ -13,7 +28,7 @@

* `MSnbase::MSnSet` class has been replaced by the `SummarizedExperiment` class
* Color scale for all plots set to `viridis` (without yellow)
* All output tables provided as `tibble` istead of `matrix` or `data.frame`
* All output tables provided as `tibble` instead of `matrix` or `data.frame`
* Allow users to select specific covariates and their position (importance) in the model for `PomaLimma`, `PomaUnivariate(method = "anova")`, and `PomaOddsRatio`
* Add SD to `PomaUnivariate` output tables
* Reduce dependencies
Expand Down
165 changes: 98 additions & 67 deletions R/PomaBoxplots.R
Original file line number Diff line number Diff line change
@@ -1,107 +1,138 @@

#' Classical Boxplots
#' Boxplots and Violin Plots
#'
#' @description PomaBoxplots() generates a boxplot for subjects or features. This boxplot can help in the comparison between pre and post normalized data and in the "validation" of the normalization process.
#' @description `PomaBoxplots` generates boxplots and violin plots for samples and features. This function can be used for data exploration (e.g., comparison between pre and post normalized datasets).
#'
#' @param data A SummarizedExperiment object.
#' @param group Groupping factor for the plot. Options are "samples" and "features". Option "samples" (default) will create a boxplot for each sample and option "features" will create a boxplot of each variable.
#' @param jitter Logical. If it's TRUE (default), the boxplot will show all points.
#' @param feature_name A vector with the name/s of feature/s to plot. If it's NULL (default) a boxplot of all features will be created.
#' @param label_size Numeric indicating the size of x-axis labels.
#' @param legend_position Character indicating the legend position. Options are "none", "top", "bottom", "left", and "right".
#' @param data A `SummarizedExperiment` object.
#' @param x Character. Options are "samples" (to visualize sample boxplots) and "features" (to visualize feature boxplots). Default is "samples".
#' @param violin Logical. Indicates if violin plots should be displayed instead of boxplots. Default is FALSE.
#' @param feature_name Character vector. Indicates the feature/s to display. Default is NULL (all features will be displayed).
#' @param theme_params List. Indicates `theme_poma` parameters.
#'
#' @export
#'
#' @return A ggplot2 object.
#' @return A `ggplot` object.
#' @author Pol Castellano-Escuder
#'
#' @importFrom magrittr %>%
#'
#' @examples
#' data("st000284")
#'
#' # samples
#' PomaBoxplots(st000284)
#' # Sample boxplots
#' st000284 %>%
#' PomaNorm() %>%
#' PomaBoxplots(theme_params = list(axistext = "y"))
#'
#' # features
#' PomaBoxplots(st000284, group = "features")
#' # Sample violin plots
#' st000284 %>%
#' PomaNorm() %>%
#' PomaBoxplots(violin = TRUE, theme_params = list(axistext = "y"))
#'
#' # All feature boxplots
#' st000284 %>%
#' PomaNorm() %>%
#' PomaBoxplots(x = "features", theme_params = list(axis_x_rotate = TRUE))
#'
#' # Specific feature boxplots
#' st000284 %>%
#' PomaNorm() %>%
#' PomaBoxplots(x = "features",
#' feature_name = c("ornithine", "orotate"))
#'
#' # concrete features
#' PomaBoxplots(st000284, group = "features",
#' # Specific feature violin plots
#' st000284 %>%
#' PomaNorm() %>%
#' PomaBoxplots(x = "features",
#' violin = TRUE,
#' feature_name = c("ornithine", "orotate"))
PomaBoxplots <- function(data,
group = "samples",
jitter = FALSE,
x = "samples",
violin = FALSE,
feature_name = NULL,
label_size = 10,
legend_position = "bottom"){

if (missing(data)) {
stop("data argument is empty!")
}
theme_params = list(legend_title = FALSE, axis_x_rotate = TRUE),
...) {

if(!is(data, "SummarizedExperiment")){
stop("data is not a SummarizedExperiment object. \nSee POMA::PomaSummarizedExperiment or SummarizedExperiment::SummarizedExperiment")
stop("data is not a SummarizedExperiment object. \nSee POMA::PomaCreateObject or SummarizedExperiment::SummarizedExperiment")
}
if (!(group %in% c("samples", "features"))) {
stop("Incorrect value for group argument!")
if (!(x %in% c("samples", "features"))) {
stop("Incorrect value for x argument")
}
if (!is.null(feature_name)) {
if(!any(feature_name %in% rownames(SummarizedExperiment::assay(data)))) {
stop("None of the specified features found")
stop("Features not found")
}
if(!all(feature_name %in% rownames(SummarizedExperiment::assay(data)))){
warning(paste0("Feature/s ",
paste0(feature_name[!feature_name %in% rownames(SummarizedExperiment::assay(data))], collapse = ", "),
if(!all(feature_name %in% rownames(SummarizedExperiment::assay(data)))) {
message(paste0(paste0(feature_name[!feature_name %in% rownames(SummarizedExperiment::assay(data))], collapse = ", "),
" not found"))
}
}
if(!(legend_position %in% c("none", "top", "bottom", "left", "right"))) {
stop("Incorrect value for legend_position argument!")
}

e <- t(SummarizedExperiment::assay(data))
target <- SummarizedExperiment::colData(data) %>%
as.data.frame() %>%
tibble::rownames_to_column("ID") %>%
dplyr::rename(Group = 2) %>%
dplyr::select(ID, Group)
plot_data <- t(SummarizedExperiment::assay(data))

grouping_factor <- ifelse(ncol(SummarizedExperiment::colData(data)) > 0,
is.factor(SummarizedExperiment::colData(data)[,1]), FALSE)

data <- cbind(target, e)
if (grouping_factor) {
plot_data <- data.frame(sample_id = rownames(SummarizedExperiment::colData(data)),
group_factor = SummarizedExperiment::colData(data)[,1],
plot_data)
} else {
if (ncol(SummarizedExperiment::colData(data)) > 0) {
sample_names <- rownames(SummarizedExperiment::colData(data))
} else {
sample_names <- colnames(SummarizedExperiment::assay(data))
}

if (is.null(sample_names)) {
sample_names <- paste0("sample_", 1:ncol(SummarizedExperiment::assay(data)))
}

plot_data <- data.frame(sample_id = sample_names,
group_factor = "no_groups",
plot_data)
}

if(group == "samples"){
plot_data <- data %>%
tidyr::pivot_longer(cols = -c(ID, Group)) %>%
ggplot2::ggplot(ggplot2::aes(ID, value, color = Group))
if (x == "samples") {
plot_data <- plot_data %>%
tidyr::pivot_longer(cols = -c(sample_id, group_factor)) %>%
dplyr::group_by(sample_id) %>%
dplyr::mutate(median_rank = median(value, na.rm = TRUE)) %>%
dplyr::ungroup() %>%
ggplot2::ggplot(ggplot2::aes(reorder(sample_id, median_rank), value))
}

else {
if(is.null(feature_name)){
plot_data <- data %>%
dplyr::select(-ID) %>%
tidyr::pivot_longer(cols = -Group) %>%
ggplot2::ggplot(ggplot2::aes(name, value, color = Group))

} else {
plot_data <- data %>%
dplyr::select(-ID) %>%
tidyr::pivot_longer(cols = -Group) %>%
dplyr::filter(name %in% feature_name) %>%
ggplot2::ggplot(ggplot2::aes(name, value, color = Group))
else if (x == "features") {
plot_data <- plot_data %>%
dplyr::select(-sample_id) %>%
tidyr::pivot_longer(cols = -group_factor)

if (!is.null(feature_name)){
plot_data <- plot_data %>%
dplyr::filter(name %in% feature_name)
}

plot_data <- plot_data %>%
ggplot2::ggplot(ggplot2::aes(name, value))
}

plot_complete <- plot_data +
ggplot2::geom_boxplot() +
{if(jitter)ggplot2::geom_jitter(alpha = 0.5, position = ggplot2::position_jitterdodge())} +
ggplot2::theme_bw() +
ggplot2::labs(x = "",
y = "Value") +
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust = 1, size = label_size),
legend.title = ggplot2::element_blank(),
legend.position = legend_position) +
ggplot2::scale_colour_viridis_d(begin = 0, end = 0.8)
# boxplots
{if(grouping_factor & !violin)ggplot2::geom_boxplot(ggplot2::aes(color = group_factor, fill = group_factor), alpha = 0.5)} +
{if(!grouping_factor & !violin)ggplot2::geom_boxplot(alpha = 0.5)} +
# violin plots
{if(grouping_factor & violin)ggplot2::geom_violin(ggplot2::aes(color = group_factor, fill = group_factor), alpha = 0.5)} +
{if(!grouping_factor & violin)ggplot2::geom_violin(alpha = 0.5)} +
# aesthetics
ggplot2::labs(x = NULL,
y = "Value",
fill = NULL,
color = NULL) +
do.call(theme_poma, theme_params) +
scale_fill_poma_d() +
scale_color_poma_d()

return(plot_complete)

}

Loading