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

Legend #7

Merged
merged 35 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
9d07901
Update legend functions
Oct 7, 2024
1048cf3
Update tests
Oct 7, 2024
db85c5e
Bump version
Oct 7, 2024
0418854
Update documentation
Oct 7, 2024
6de111e
Fix vertical scalling
Oct 7, 2024
6895d39
Update tests
Oct 7, 2024
1253efa
Remove params
Oct 7, 2024
53e176e
Fix graphical argument usage
Oct 7, 2024
1e51c55
Fix linting
Oct 7, 2024
182b87a
Add tips for plotly
LouisLeNezet Oct 7, 2024
4ae3824
Tooltips available through text
Oct 8, 2024
c10585a
Add tips to app
Oct 8, 2024
6752559
Fix tips usage
Oct 8, 2024
10c49dd
Supressa warning unknown aesthetics
Oct 8, 2024
b626181
Update documentation
Oct 8, 2024
8647ed9
Update documentation
Oct 8, 2024
8ac2700
Add spinner
Oct 8, 2024
bcb7a3b
Fix global
Oct 8, 2024
1fcd6c8
Fix doc
Oct 8, 2024
b040090
Update snapshot
Oct 8, 2024
1aef556
Fix plot download
Oct 8, 2024
54eac61
Remove unnecessary from namespace
Oct 8, 2024
533771b
Fix linting
Oct 8, 2024
c678c2e
Fix documentation
Oct 8, 2024
79f750d
Add interactive usage in vignette
Oct 8, 2024
102ea62
Fix vignette
LouisLeNezet Oct 9, 2024
f51992b
Add magick dependency
LouisLeNezet Oct 9, 2024
5894e2a
Fix bioccheck
LouisLeNezet Oct 9, 2024
ffa4408
Update snaps
LouisLeNezet Oct 9, 2024
62cf46d
Unevaluate plotly function
LouisLeNezet Oct 9, 2024
9883e53
Do not check for bioc version
LouisLeNezet Oct 9, 2024
3514c38
Update news
LouisLeNezet Oct 9, 2024
96d2cab
Improve news and release on website
LouisLeNezet Oct 9, 2024
755346a
Set news to first level header
LouisLeNezet Oct 9, 2024
0d40cfd
Set changes as h2
LouisLeNezet Oct 9, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/check-bioc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ jobs:
BiocCheck::BiocCheck(
dir('check', 'tar.gz$', full.names = TRUE),
`quit-with-status` = TRUE,
`no-check-version-num` = TRUE,
`no-check-R-ver` = TRUE,
`no-check-bioc-help` = TRUE
)
Expand Down
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: Pedixplorer
Version: 1.1.4
Version: 1.1.5
Date: 2024-10-01
Title: Pedigree Functions
Authors@R: c(
Expand Down Expand Up @@ -35,7 +35,8 @@ Imports:
plotly,
colourpicker,
shinytoastr,
scales
scales,
shinycssloaders
Description: Routines to handle family data with a Pedigree object. The initial
purpose was to create correlation structures that describe family
relationships such as kinship and identity-by-descent, which can be used to
Expand All @@ -62,7 +63,8 @@ Suggests:
covr,
devtools,
R.devices,
usethis
usethis,
magick
Config/testthat/edition: 3
biocViews: Software, DataRepresentation, Genetics, GraphAndNetwork, Visualization
BugReports: https://github.com/LouisLeNezet/Pedixplorer/issues
Expand Down
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export(Scales)
export(affected)
export(align)
export(ancestors)
export(anchor_to_factor)
export(auto_hint)
export(avail)
export(best_hint)
Expand Down Expand Up @@ -71,9 +70,7 @@ export(isinf)
export(kin)
export(kindepth)
export(kinship)
export(make_class_info)
export(make_famid)
export(make_rownames)
export(min_dist_inf)
export(momid)
export(na_to_length)
Expand Down Expand Up @@ -219,11 +216,13 @@ importFrom(dplyr,mutate_at)
importFrom(dplyr,mutate_if)
importFrom(dplyr,n)
importFrom(dplyr,one_of)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,rowwise)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(dplyr,sym)
importFrom(dplyr,ungroup)
importFrom(ggplot2,aes)
importFrom(ggplot2,annotate)
importFrom(ggplot2,element_blank)
Expand Down Expand Up @@ -319,6 +318,7 @@ importFrom(shiny,uiOutput)
importFrom(shinyWidgets,pickerInput)
importFrom(shinyWidgets,switchInput)
importFrom(shinyWidgets,updateSwitchInput)
importFrom(shinycssloaders,withSpinner)
importFrom(shinytoastr,toastr_error)
importFrom(shinytoastr,toastr_info)
importFrom(shinytoastr,toastr_success)
Expand Down
21 changes: 14 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# NEWS
## Changes in v1.1.5

NEWS file for the Pedixplorer package
- Change code of ped_to_legdf
- When plotting with the main plot, the legend gets its own
space separate from the plot. This allow better control over
the size and localisation of the legend.
- The graphical parameters are reset after each use of plot_fromdf
- Add tooltips control in Pedigree plots and add it to the app
- Add example of interactivness in vignette
- Fix plot area function and legend creation for better alignment

## Changes in version 1.1.4
## Changes in v1.1.4

- Update website and logo
- Improve `ped_shiny()` esthetics
Expand All @@ -16,17 +23,17 @@ functions for users
- Standardize the vignettes and add more documentation
- Fix label adjusting position in plot functions

## Changes in version 1.1.3
## Changes in v1.1.3

- Fix github workflows
- Disable `ped_shiny()` execution in markdown
- Publish with `pkgdown`

## Changes in version 1.1.2
## Changes in v1.1.2

- Use R version 4.4 and update workflows

## Changes in version 1.1.1
## Changes in v1.1.1

- A [shiny application](https://shiny.posit.co/) is now available through
the `ped_shiny()` function.
Expand All @@ -46,7 +53,7 @@ to reduce noise between platform.
computed by `ped_to_plotdf()`.
- `useful_inds()` function has been improved.

## Changes in version 0.99.0
## Changes in v0.99.0

- Kinship2 is renamed to Pedixplorer and hosted on Bioconductor.
- Pedigree is now a S4 object, all functions are updated to work with
Expand Down
6 changes: 3 additions & 3 deletions R/app_plot_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ plot_download_server <- function(
paste(myfilename(), input$ext, sep = ".")
}, content = function(file) {
if (input$ext == "html") {
if ("ggplot" %in% class(my_plot())) {
if ("htmlwidget" %in% class(my_plot())) {
htmlwidgets::saveWidget(file = file, my_plot())
} else if ("ggplot" %in% class(my_plot())) {
plot_html <- plotly::ggplotly(my_plot())
htmlwidgets::saveWidget(file = file, plot_html)
} else if ("htmlwidget" %in% class(my_plot())) {
htmlwidgets::saveWidget(file = file, my_plot())
} else {
shinytoastr::toastr_error(
title = "Error in plot type selected",
Expand Down
16 changes: 9 additions & 7 deletions R/app_plot_legend.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#### UI function of the module #### ----------
#' @rdname plot_legend
#' @rdname plot_legend_app
#' @export
#' @importFrom shiny NS column plotOutput
plot_legend_ui <- function(id, height = "200px") {
plot_legend_ui <- function(id, height = "400px") {
ns <- shiny::NS(id)
shiny::column(12,
shiny::plotOutput(ns("plotlegend"), height = height)
Expand All @@ -25,13 +25,13 @@ plot_legend_ui <- function(id, height = "200px") {
#' if (interactive()) {
#' plot_legend_demo()
#' }
#' @rdname plot_legend
#' @rdname plot_legend_app
#' @keywords internal
#' @export
#' @importFrom shiny moduleServer is.reactive renderPlot req
plot_legend_server <- function(
id, pedi, leg_loc = c(0.2, 1, 0, 1),
lwd = par("lwd"), boxw = 1, boxh = 1,
id, pedi, leg_loc = c(0, 1, 0, 1),
lwd = par("lwd"), boxw = 0.1, boxh = 0.1,
adjx = 0, adjy = 0
) {
stopifnot(shiny::is.reactive(pedi))
Expand All @@ -51,11 +51,13 @@ plot_legend_server <- function(
}

#### Demo function of the module #### ----------
#' @rdname plot_legend
#' @rdname plot_legend_app
#' @export
#' @importFrom utils data
#' @importFrom shiny shinyApp fluidPage reactive
plot_legend_demo <- function(height = "200px", leg_loc = c(0.2, 1, 0, 1)) {
plot_legend_demo <- function(
height = "400px", leg_loc = c(0.2, 0.8, 0.2, 0.6)
) {
data_env <- new.env(parent = emptyenv())
utils::data("sampleped", envir = data_env, package = "Pedixplorer")
pedi <- shiny::reactive({
Expand Down
33 changes: 24 additions & 9 deletions R/app_plot_ped.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ plot_ped_ui <- function(id) {
#' @param precision An integer to set the precision of the plot.
#' @param max_ind An integer to set the maximum number of individuals to plot.
#' @inheritParams plot_fromdf
#' @inheritParams ped_to_plotdf
#' @returns A reactive ggplot or the pedigree object.
#' @examples
#' if (interactive()) {
Expand All @@ -46,15 +47,24 @@ plot_ped_ui <- function(id) {
#' @importFrom shiny tagList checkboxInput plotOutput
#' @importFrom ggplot2 scale_y_reverse theme element_blank
#' @importFrom plotly ggplotly renderPlotly plotlyOutput
#' @importFrom shinycssloaders withSpinner
plot_ped_server <- function(
id, pedi, title, precision = 2,
max_ind = 500, lwd = par("lwd")
max_ind = 500, lwd = par("lwd"),
tips = NULL
) {
stopifnot(shiny::is.reactive(pedi))
shiny::moduleServer(id, function(input, output, session) {

ns <- shiny::NS(id)

mytips <- shiny::reactive({
if (shiny::is.reactive(tips)) {
tips <- tips()
}
tips
})

mytitle <- shiny::reactive({
if (shiny::is.reactive(title)) {
title <- title()
Expand Down Expand Up @@ -95,8 +105,9 @@ plot_ped_server <- function(
pedi_val(),
aff_mark = TRUE, label = NULL, ggplot_gen = input$interactive,
cex = 1, symbolsize = 1, force = TRUE,
mar = c(0.5, 0.5, 1.5, 0.5), title = mytitle(),
precision = precision, lwd = lwd
ped_par = list(mar = c(0.5, 0.5, 1.5, 0.5)),
title = mytitle(), tips = mytips(),
precision = precision, lwd = lwd / 3
)

ggp <- ped_plot_lst$ggplot + ggplot2::scale_y_reverse() +
Expand All @@ -115,7 +126,8 @@ plot_ped_server <- function(
ggp +
ggplot2::theme(legend.position = "none"),
tooltip = "text"
)
) %>%
plotly::layout(hoverlabel = list(bgcolor = "darkgrey"))
})
output$plotpedi <- shiny::renderUI({
if (is.null(input$interactive)) {
Expand All @@ -125,19 +137,22 @@ plot_ped_server <- function(
output$ped_plotly <- plotly::renderPlotly({
plotly_ped()
})
plotly::plotlyOutput(ns("ped_plotly"), height = "700px")
plotly::plotlyOutput(ns("ped_plotly"), height = "700px") %>%
shinycssloaders::withSpinner(color = "#8aca25")
} else {
output$ped_plot <- shiny::renderPlot({
shiny::req(pedi_val())
plot(
pedi_val(),
aff_mark = TRUE, label = NULL,
cex = 1, symbolsize = 1, force = TRUE,
mar = c(0.5, 0.5, 1.5, 0.5), title = mytitle(),
ped_par = list(mar = c(0.5, 0.5, 1.5, 0.5)),
title = mytitle(),
precision = precision, lwd = lwd
)
})
shiny::plotOutput(ns("ped_plot"), height = "700px")
shiny::plotOutput(ns("ped_plot"), height = "700px") %>%
shinycssloaders::withSpinner(color = "#8aca25")
}
})

Expand All @@ -156,7 +171,7 @@ plot_ped_server <- function(
#' @rdname plot_ped
#' @export
#' @importFrom shiny shinyApp fluidPage
plot_ped_demo <- function(pedi, precision = 2, max_ind = 500) {
plot_ped_demo <- function(pedi, precision = 2, max_ind = 500, tips = NULL) {
ui <- shiny::fluidPage(
plot_ped_ui("plot_ped"),
plot_download_ui("saveped")
Expand All @@ -165,7 +180,7 @@ plot_ped_demo <- function(pedi, precision = 2, max_ind = 500) {
ped_plot <- plot_ped_server(
"plot_ped", pedi,
"My Pedigree", max_ind = max_ind,
precision = precision
precision = precision, tips = tips
)
plot_download_server("saveped", ped_plot)
}
Expand Down
26 changes: 22 additions & 4 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ ped_server <- function(
)

## Plotting pedigree --------------------------------------------------

cust_title <- function(short) {
shiny::reactive({
shiny::req(lst_fam())
Expand All @@ -315,16 +314,35 @@ ped_server <- function(
})
}

### Tips column selection --------------------------------------------
output$col_sel_tips <- renderUI({
shiny::req(ped_subfam())
all_cols <- colnames(Pedixplorer::as.data.frame(ped(ped_subfam())))
select <- c("affection", "affected", "avail", "status")
select <- select[select %in% all_cols]
shiny::selectInput(
"tips_col",
label = "Select columns for tips",
choices = all_cols, selected = select,
multiple = TRUE
)
})

my_tips <- shiny::reactive({
input$tips_col
})

plot_ped <- plot_ped_server(
"ped", ped_subfam,
cust_title(short = FALSE),
precision = precision, lwd = 2
precision = precision, lwd = 2,
tips = my_tips
)

plot_legend_server(
"legend", ped_subfam,
boxw = 0.03, boxh = 0.07, adjx = 0.3, adjy = -0.015,
leg_loc = c(0.2, 1.2, 0.2, 0.95), lwd = 2
boxw = 0.02, boxh = 0.08, adjx = 0, adjy = 0,
leg_loc = c(0.1, 0.7, 0.01, 0.95), lwd = 1.5
)

## Download data and plot ---------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ ped_ui <- function() {
shiny::fluidRow(
shiny::column(5,
plot_download_ui("saveped"),
data_download_ui("plot_data_dwnl")
data_download_ui("plot_data_dwnl"),
shiny::uiOutput("col_sel_tips")
),
shiny::column(7,
plot_legend_ui("legend", "350px")
Expand Down
Loading
Loading