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

Develop board expression refactor #183

Merged
merged 32 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
daf5a25
updated height and width to match old codebase
mauromiguelm Jan 23, 2023
b34ba82
removed serverSideComputation to simplify code and reactivity
mauromiguelm Jan 23, 2023
b7a01e9
file names conform
mauromiguelm Jan 23, 2023
ef784f0
boxplot refactor [args and opts]
mauromiguelm Jan 23, 2023
ad3c98d
fix reactive inputs from topfoldchange
mauromiguelm Jan 23, 2023
a4c3ed3
fix tag input for plot_boxplot
mauromiguelm Jan 23, 2023
4c89372
fix reactivity for topgenes
mauromiguelm Jan 23, 2023
619a9b8
cleaned plot module template file
mauromiguelm Jan 27, 2023
b1cb01a
added basic layout files for remaining undone plots
mauromiguelm Jan 27, 2023
cbfcab1
volcanoAll plot refactored and working
mauromiguelm Jan 27, 2023
ea2acee
fix volcanoAll values being changes within fn
mauromiguelm Jan 27, 2023
58726fd
volcanoMethod refactored
mauromiguelm Jan 27, 2023
7cf6853
template for table refactoring
mauromiguelm Jan 28, 2023
2868f18
comment out code expression_table to avoid crashes
mauromiguelm Jan 28, 2023
4fb62ac
remove old plot code
mauromiguelm Jan 28, 2023
88ee2ad
update expression_table to expression board
mauromiguelm Jan 28, 2023
9494562
refactor genetable, add templates for tables
mauromiguelm Jan 28, 2023
a00a7fc
fix genetable missing ns and fn names
mauromiguelm Jan 29, 2023
ab5f1f5
gsettable refactoring
mauromiguelm Jan 29, 2023
401fd6c
fctable refactored
mauromiguelm Jan 29, 2023
f33d5b6
FDRtable refactored
mauromiguelm Jan 29, 2023
ef0f5c7
add missing reactives metaFC and metaQ to fctable
mauromiguelm Jan 29, 2023
dc2fe9e
added board header
mauromiguelm Jan 30, 2023
51b496b
remove template files
mauromiguelm Jan 30, 2023
28cc663
remove old table code
mauromiguelm Jan 30, 2023
924f583
cleaning code
mauromiguelm Jan 30, 2023
25c3e17
Small changes to make `Plot` panel and tables work
ESCRI11 Jan 30, 2023
fb66b52
add caption attributes to div
mauromiguelm Jan 31, 2023
70270d9
fix FDRtable
mauromiguelm Jan 31, 2023
5c8d24c
fixed zoom and standardized plot labels, fixed plotlibs
mauromiguelm Jan 31, 2023
3b89b06
fix: solved `plot_topgenes` bug
ESCRI11 Jan 31, 2023
b08b08f
styling changes
Feb 1, 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
102 changes: 0 additions & 102 deletions components/board.expression/R/expression_plot.R

This file was deleted.

76 changes: 34 additions & 42 deletions components/board.expression/R/expression_plot_boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,16 @@ expression_plot_boxplot_ui <- function(id,
height,
width) {
ns <- shiny::NS(id)
options <- tagList(
actionButton(ns("button1"), "some action")

plots_boxplot_opts <- shiny::tagList(
withTooltip(shiny::checkboxInput(ns("boxplot_grouped"), "grouped", TRUE),
"Group expression values by conditions.",
placement = "right", options = list(container = "body")
),
withTooltip(shiny::checkboxInput(ns("boxplot_logscale"), "log scale", TRUE),
"Show logarithmic (log2CPM) expression values.",
placement = "right", options = list(container = "body")
)
)

info_text <- "The top N = {12} differentially (both positively and negatively) expressed gene barplot for the selected comparison under the <code>Contrast</code> settings."
Expand All @@ -29,7 +37,7 @@ expression_plot_boxplot_ui <- function(id,
label = label,
plotlib = "base",
info.text = info_text,
options = NULL,
options = plots_boxplot_opts,
download.fmt = c("png", "pdf", "csv"),
width = width,
height = height
Expand All @@ -41,7 +49,8 @@ expression_plot_boxplot_ui <- function(id,
#' @description A shiny Module for plotting (server code).
#'
#' @param id
#' @param inputData
#' @param comp
#' @param ngs
#' @param sel
#' @param res
#' @param watermark
Expand All @@ -50,58 +59,53 @@ expression_plot_boxplot_ui <- function(id,
#'
#' @export
expression_plot_boxplot_server <- function(id,
inputData,
comp,
ngs,
sel,
res,
watermark = FALSE) {
moduleServer(id, function(input, output, session) {
# #calculate required inputs for plotting ---------------------------------

plot_data <- shiny::reactive({
ngs <- inputData()
shiny::req(ngs)

## get table
## sel=1
comp <- comp() # input$gx_contrast
grouped <- input$boxplot_grouped
logscale <- input$boxplot_logscale
ngs <- ngs()
sel <- sel()
if (is.null(sel) || length(sel) == 0) {
frame()
text(0.5, 0.5, "No gene selected", col = "black")
return(NULL)
}

res <- res()
if (is.null(res) || is.null(sel)) {
return(NULL)
}

psel <- rownames(res)[sel]
gene <- ngs$genes[1, "gene_name"]
comp <- 1
grouped <- TRUE
logscale <- TRUE
srt <- 45

gene <- ngs$genes[psel, "gene_name"]
comp <- input$gx_contrast
shiny::req(comp)
grouped <- input$boxplot_grouped
logscale <- input$boxplot_logscale
srt <- ifelse(grouped, 0, 35)

return(
return(list(
ngs = ngs,
gene = gene,
comp = comp,
sel = sel,
grouped = grouped,
logscale = logscale,
srt = srt
)
))
})

plotly.RENDER <- function() {
pd <- plot_data()
shiny::req(pd)

if (is.null(pd[["sel"]]) || length(pd[["sel"]]) == 0) {
frame()
text(0.5, 0.5, "No gene selected", col = "black")
return(NULL)
}

if (is.null(res) || is.null(sel)) {
return(NULL)
}

par(mfrow = c(1, 1), mar = c(4, 3, 1.5, 1.5), mgp = c(2, 0.8, 0), oma = c(1, 0.5, 0, 0.5))
pgx.plotExpression(pd[["ngs"]],
pd[["gene"]],
Expand All @@ -114,23 +118,11 @@ expression_plot_boxplot_server <- function(id,
)
}

modal_plotly.RENDER <- function() {
fig <- plotly.RENDER() %>%
plotly::layout(
font = list(size = 18),
legend = list(
font = list(size = 18)
)
)
fig <- plotly::style(fig, marker.size = 20)
fig
}

PlotModuleServer(
"pltmod",
plotlib = "base",
func = plotly.RENDER,
func2 = modal_plotly.RENDER,
# func2 = modal_plotly.RENDER,
csvFunc = plot_data, ## *** downloadable data as CSV
res = c(80, 95), ## resolution of plots
pdf.width = 6, pdf.height = 6,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,11 @@ expression_plot_maplot_server <- function(id,
return(NULL)
}
fc.genes <- as.character(res[, grep("^gene$|gene_name", colnames(res))])
## pval = res$P.Value
## pval = res[,grep("P.Value|meta.p|pval|p.val",colnames(res))[1]]

## filter genes by gene family or gene set
fam.genes <- unique(unlist(ngs$families[10]))
## fam.genes = unique(unlist(ngs$families[input$gx_features]))
fam.genes <- res$gene_name
if (gx_features() != "<all>") {
## gset <- GSETS[input$gx_features]
gset <- getGSETS(gx_features())
fam.genes <- unique(unlist(gset))
}
Expand All @@ -121,10 +117,8 @@ expression_plot_maplot_server <- function(id,
sel.genes <- intersect(sig.genes, sel.genes)

## are there any genes/genesets selected?
# sel1 = genetable$rows_selected()
sel1 <- sel1()
df1 <- df1()
# sel2 = gsettable$rows_selected()
sel2 <- sel2()
df2 <- df2()
lab.cex <- 1
Expand Down Expand Up @@ -168,9 +162,6 @@ expression_plot_maplot_server <- function(id,
head(sel.genes[order(-impt(sel.genes))], 10)
)




return(list(
x = x,
y = y,
Expand Down Expand Up @@ -200,8 +191,6 @@ expression_plot_maplot_server <- function(id,
highlight = pd[["sel.genes"]],
label = pd[["lab.genes"]], label.cex = pd[["lab.cex"]],
group.names = c("group1", "group0"),
## xlim=xlim, ylim=ylim, ## hi.col="#222222",
## use.fdr=TRUE,
psig = pd[["fdr"]], lfc = pd[["lfc"]],
xlab = "average expression (log2.CPM)",
ylab = "effect size (log2.FC)",
Expand Down
Loading