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

Clusters app v1.2 update #33

Merged
merged 103 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
dde6f22
added cluster labels to clustering tab, added different clustering op…
CooberHoo Jun 17, 2021
6c0cf36
Updated info/instructions for each tabs
CooberHoo Jun 17, 2021
0c75cab
added toggleable labels on dimension reduction plots, turned network …
CooberHoo Jun 18, 2021
c75f327
Adjust gene label alignment, disable scroll for bubble plots
bhavyaac Jun 21, 2021
cd65cc7
Remove TODO for closed issue
bhavyaac Jun 21, 2021
b504df3
added very basic hovering to network visualisation, added server side…
CooberHoo Jun 22, 2021
ae78b81
Implement bookmark button beside update button
bhavyaac Jun 22, 2021
352e0fc
Enable url-based bookmarking
bhavyaac Jun 22, 2021
94c7d51
Streamline loading spinner code using ui_functions file
bhavyaac Jun 22, 2021
aaf1580
added serverside bookmarking, custom formatting
CooberHoo Jun 22, 2021
d07c82e
removed shiny_bookmarks
CooberHoo Jun 22, 2021
0e020e4
Switch to server-side bookmarking - issue #28 (only tested locally)
bhavyaac Jun 22, 2021
b69f8e7
Match expression table column order to bubble plots - issue #16
bhavyaac Jun 22, 2021
6efbe7e
Add toggle for displaying mean expression to table tab, edit docs
bhavyaac Jun 22, 2021
3ba70d4
Show number of cells in timecourse tooltip - issue #19
bhavyaac Jun 22, 2021
af435f5
Add code documentation for new sections
bhavyaac Jun 22, 2021
66dcd10
Alter timecourse tooltip text and plotly controls
bhavyaac Jun 25, 2021
4b3b6c8
Create new tab to to rank clusters by expression - issue #20
bhavyaac Jun 25, 2021
c033cfd
modified labels, tool-tips, legends, comments
CooberHoo Jun 27, 2021
a429370
commented out code that doesn't work yet
CooberHoo Jun 27, 2021
f32749d
added cluster labels to clustering tab, added different clustering op…
CooberHoo Jun 17, 2021
32c2b1c
Updated info/instructions for each tabs
CooberHoo Jun 17, 2021
188fbb1
added toggleable labels on dimension reduction plots, turned network …
CooberHoo Jun 18, 2021
a87472f
added very basic hovering to network visualisation, added server side…
CooberHoo Jun 22, 2021
6506d55
added serverside bookmarking, custom formatting
CooberHoo Jun 22, 2021
cc1175b
removed shiny_bookmarks
CooberHoo Jun 22, 2021
083e940
modified labels, tool-tips, legends, comments
CooberHoo Jun 27, 2021
539afc4
commented out code that doesn't work yet
CooberHoo Jun 27, 2021
6dc1fd6
Merge branch 'dev_howard' of github.com:fungenomics/braindex into dev…
sjessa Jun 28, 2021
95e19fe
Display message in case of all-zero expression in single cell tabs
bhavyaac Jun 28, 2021
3cf1a50
Merge pull request #36 from fungenomics/dev_howard
sjessa Jun 28, 2021
db79bb4
Add informative error messages for missing gene input to all tabs
bhavyaac Jun 28, 2021
fa5d268
Remove relocate() function from expression table code - bug fix on di…
bhavyaac Jun 28, 2021
4508a59
Display the gene name in the ranked clusters plot + add docs for this…
bhavyaac Jun 28, 2021
502f2d8
Display message in case of all-zero expression in timecourse tab - is…
bhavyaac Jun 28, 2021
b3b5ae4
Remove row indices from expression table
bhavyaac Jun 28, 2021
291f0d4
Include shiny_bookmarks folder in .gitignore
bhavyaac Jun 29, 2021
550e7c3
Implement file upload (csv or tsv only) for gene lists
bhavyaac Jun 29, 2021
a3a071d
Allow user to use the textbox only, file upload optional - issue #17
bhavyaac Jun 29, 2021
bf5b27e
Toggle spike lines on by default for timeseries interactive plot
bhavyaac Jun 29, 2021
592bc79
Display mean expression toggle for <2 genes in textbox
bhavyaac Jun 29, 2021
e4cd5f4
Remove user toggle for spikelines in timecourse interactive plot
bhavyaac Jun 29, 2021
8f00338
Toggle between file upload and textbox input for gene selection - iss…
bhavyaac Jul 2, 2021
1d6be9e
Update text in file upload function + error message
bhavyaac Jul 2, 2021
868e6c3
Switch back to conditionally displaying mean expression toggle
bhavyaac Jul 2, 2021
34f499f
Alter docs and sidebar formatting to match GRN app
bhavyaac Jul 2, 2021
45a7f67
Switch back to URL bookmarking
bhavyaac Jul 6, 2021
d859e4a
Add mean expression toggle to ranked clusters tab, alter plot formatting
bhavyaac Jul 6, 2021
136895a
Clarify expression vs. proportion in ranked clusters tab
bhavyaac Jul 6, 2021
b213ce6
Implement expression table with reactable, alter text color in dark b…
bhavyaac Jul 6, 2021
fe266af
Load reactable package, comment out DT package
bhavyaac Jul 6, 2021
ba2fa58
Display error message for genes in uploaded files that aren't in data…
bhavyaac Jul 7, 2021
6918850
Remove case sensitivity for gene input error messages - issue #17
bhavyaac Jul 7, 2021
2c0992a
Revert "Remove case sensitivity for gene input error messages - issue…
bhavyaac Jul 7, 2021
96af6da
Extract part of input validation step to a function - issue #37
bhavyaac Jul 7, 2021
ead6ecf
Add dropdown menu to choose between inputs in timecourse tab - issue #38
bhavyaac Jul 9, 2021
281744f
Adjust app formatting during server test
bhavyaac Jul 12, 2021
12591b1
Adjust formatting and remove sticky column in table (server testing)
bhavyaac Jul 12, 2021
e55bcdf
Adjust formatting and alignment of dendrogram and table tabs (server …
bhavyaac Jul 12, 2021
102282b
Adjust formatting and alignment (server testing)
bhavyaac Jul 12, 2021
0db366c
Adjust gene label alignment, disable scroll for bubble plots
bhavyaac Jun 21, 2021
baec806
Remove TODO for closed issue
bhavyaac Jun 21, 2021
5aeafb1
Implement bookmark button beside update button
bhavyaac Jun 22, 2021
52efd5c
Enable url-based bookmarking
bhavyaac Jun 22, 2021
42c4137
Streamline loading spinner code using ui_functions file
bhavyaac Jun 22, 2021
589630f
Switch to server-side bookmarking - issue #28 (only tested locally)
bhavyaac Jun 22, 2021
e9090c4
Match expression table column order to bubble plots - issue #16
bhavyaac Jun 22, 2021
4422966
Add toggle for displaying mean expression to table tab, edit docs
bhavyaac Jun 22, 2021
c9ce9eb
Show number of cells in timecourse tooltip - issue #19
bhavyaac Jun 22, 2021
c83423d
Add code documentation for new sections
bhavyaac Jun 22, 2021
8fbe68c
Alter timecourse tooltip text and plotly controls
bhavyaac Jun 25, 2021
fd10037
Create new tab to to rank clusters by expression - issue #20
bhavyaac Jun 25, 2021
a7a24c1
Display message in case of all-zero expression in single cell tabs
bhavyaac Jun 28, 2021
6aed283
Add informative error messages for missing gene input to all tabs
bhavyaac Jun 28, 2021
6b4f9ae
Remove relocate() function from expression table code - bug fix on di…
bhavyaac Jun 28, 2021
2be635c
Display the gene name in the ranked clusters plot + add docs for this…
bhavyaac Jun 28, 2021
84655d4
Display message in case of all-zero expression in timecourse tab - is…
bhavyaac Jun 28, 2021
3ef9cf4
Remove row indices from expression table
bhavyaac Jun 28, 2021
a271f87
Include shiny_bookmarks folder in .gitignore
bhavyaac Jun 29, 2021
dab8c7e
Implement file upload (csv or tsv only) for gene lists
bhavyaac Jun 29, 2021
e2b0a9a
Allow user to use the textbox only, file upload optional - issue #17
bhavyaac Jun 29, 2021
d3c262a
Toggle spike lines on by default for timeseries interactive plot
bhavyaac Jun 29, 2021
78bbdcc
Display mean expression toggle for <2 genes in textbox
bhavyaac Jun 29, 2021
532d17d
Remove user toggle for spikelines in timecourse interactive plot
bhavyaac Jun 29, 2021
b676c02
Toggle between file upload and textbox input for gene selection - iss…
bhavyaac Jul 2, 2021
fd31c1c
Update text in file upload function + error message
bhavyaac Jul 2, 2021
2c0bf7b
Switch back to conditionally displaying mean expression toggle
bhavyaac Jul 2, 2021
74e30f9
Alter docs and sidebar formatting to match GRN app
bhavyaac Jul 2, 2021
d90cf68
Switch back to URL bookmarking
bhavyaac Jul 6, 2021
77db434
Add mean expression toggle to ranked clusters tab, alter plot formatting
bhavyaac Jul 6, 2021
f424262
Clarify expression vs. proportion in ranked clusters tab
bhavyaac Jul 6, 2021
7543aa1
Implement expression table with reactable, alter text color in dark b…
bhavyaac Jul 6, 2021
028f577
Load reactable package, comment out DT package
bhavyaac Jul 6, 2021
4091e50
Display error message for genes in uploaded files that aren't in data…
bhavyaac Jul 7, 2021
69aff40
Remove case sensitivity for gene input error messages - issue #17
bhavyaac Jul 7, 2021
23e9d9a
Revert "Remove case sensitivity for gene input error messages - issue…
bhavyaac Jul 7, 2021
ef4d939
Extract part of input validation step to a function - issue #37
bhavyaac Jul 7, 2021
6b4b3ad
Add dropdown menu to choose between inputs in timecourse tab - issue #38
bhavyaac Jul 9, 2021
a683453
Adjust app formatting during server test
bhavyaac Jul 12, 2021
17e9d78
Adjust formatting and remove sticky column in table (server testing)
bhavyaac Jul 12, 2021
f3446a8
Adjust formatting and alignment of dendrogram and table tabs (server …
bhavyaac Jul 12, 2021
d4912a4
Adjust formatting and alignment (server testing)
bhavyaac Jul 12, 2021
872fd66
Merge branch 'dev-bhavyaa' of https://github.com/fungenomics/braindex…
bhavyaac Jul 12, 2021
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
3 changes: 3 additions & 0 deletions GRN/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ explore
data/shared
data/joint_cortex
data/joint_pons
shiny_bookmarks
data/ct_e12
data/ct_e12_not_needed

28 changes: 28 additions & 0 deletions GRN/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,27 @@
"contents": "Several R objects: forebrain_data, TF_and_ext, TF_active, metadata, tf_df, cell_metadata_cortex,binary_activity data",
"script": "data_prep.R"

},
{
"file": "joint_cortex.regulon_activity_per_joint_cluster.feather",
"description": "feather file containing average TF activity per joint cluster instead of per sample cluster in the forebrain.",
"contents": "a data frame with a joint cluster column and columns corresponding to TFs and their activity in each cluster.",
"script": "data_prep.R"

},
{
"file": "Forebrain_join.2D.tsv",
"path": "selin.jessa/from_hydra/single_cell/scDev_data/data/joint_cortex/Forebrain_join.2D.tsv",
"description": "Cell-level information for forebrain data, including corresponding clusters and UMAP/tSNE/PCA coordinates, used to plot scatterplots",
"contents": "Data frame with columns, 'Cell' 'Sample' 'Sample_cluster', followed by columns for embedding coordinates."

},
{
"file": "Jessa2019_Table_2b_joint_cortex_metadata.tsv",
"path": "selin.jessa/from_hydra/single_cell/scDev_data/data/metadata/Jessa2019_Table_2b_joint_cortex_metadata.tsv",
"description": "Joint_cluster-level information for forebrain data, including color palatte for each cluster, used to color scatter plots",
"contents": "Data frame with columns, 'Cluster_number' 'Color' 'Cell_type' 'Sample' etc., followed by summary info for each cluster."

},
{

Expand Down Expand Up @@ -82,6 +96,20 @@
"script": "data_prep.R"

},
{
"file": "joint_pons.regulon_activity_per_joint_cluster.feather",
"description": "feather file containing average TF activity per joint cluster instead of per sample cluster in the pons.",
"contents": "a data frame with a joint cluster column and columns corresponding to TFs and their activity in each cluster.",
"script": "data_prep.R"

},
{
"file": "Jessa2019_Table_2c_joint_pons_metadata.tsv",
"path": "selin.jessa/from_hydra/single_cell/scDev_data/data/metadata/Jessa2019_Table_2c_joint_pons_metadata.tsv",
"description": "Joint_cluster-level information for forebrain data, including color palatte for each cluster, used to color scatter plots",
"contents": "Data frame with columns, 'Cluster_number' 'Color' 'Cell_type' 'Sample' etc., followed by summary info for each cluster."

},
{
"file": "Pons_join.2D.tsv",
"path": "selin.jessa/from_hydra/single_cell/scDev_data/data/joint_pons/Pons_join.2D.tsv",
Expand Down
399 changes: 318 additions & 81 deletions GRN/functions.R

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion GRN/global.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ library(ggplot2)
library(cowplot)
library(pheatmap)
library(DT)
library(rcytoscapejs2) # downloaded from https://github.com/uc-bd2k/rcytoscapejs2
#library(rcytoscapejs2) # downloaded from https://github.com/uc-bd2k/rcytoscapejs2
#could probably get rid of rcytoscape
library(glue)
library(GGally)
Expand All @@ -29,3 +29,6 @@ load("data/shared/common_prep.Rda") # metadata and colour_palettes

# Custom functions
source("functions.R")

#allows server side save states
enableBookmarking(store = "server")
121 changes: 67 additions & 54 deletions GRN/server.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
server <- function(input, output, session) {
# help message
observeEvent(input$help,
introjs(session, options = list("nextLabel"="Next",
"prevLabel"="Previous",
"skipLabel"="Exit Tutorial"),
events = list("oncomplete"=I('alert("All Done!")')))
)

# Dynamic UI, change the selectInput tf lists on display depending on the brain region that is selected
observeEvent(input$region,{
if(input$region == "cortex"){
updateSelectInput(session, inputId = "TF", choices = data_cortex$unique_active_TFs_bare,
selected = c("Arx","Lef1"))
updateSelectInput(session, inputId = "gene", choices = unique(data_cortex$TF_target_gene_info$gene),
selected = c("Dlx6","Sox6") )
updateSelectizeInput(session, inputId = "TF", choices = data_cortex$unique_active_TFs_bare,
selected = c("Arx","Lef1"), server = TRUE)
updateSelectizeInput(session, inputId = "gene", choices = unique(data_cortex$TF_target_gene_info$gene),
selected = c("Dlx6","Sox6"), server = TRUE )

}
else{
updateSelectInput(session, inputId = "TF", choices = data_pons$unique_active_TFs_bare,
selected = c("Lhx5","Pax7"))
updateSelectInput(session, inputId = "gene", choices = unique(data_pons$TF_target_gene_info$gene),
selected = c("Gad2"))
updateSelectizeInput(session, inputId = "TF", choices = data_pons$unique_active_TFs_bare,
selected = c("Lhx5","Pax7"), server = TRUE)
updateSelectizeInput(session, inputId = "gene", choices = unique(data_pons$TF_target_gene_info$gene),
selected = c("Gad2"), server = TRUE)

}
#updateRadioButtons(session, "show", selected = "stop") #resets the network visualization
})


#uses the input update button to update a list of the parameters of the app for the following functions
input_new <- eventReactive(input$update,{
Expand All @@ -48,6 +42,8 @@ server <- function(input, output, session) {
l$time_point <- temp
l$gene <- input$gene
l$label <- input$label
l$dim_red <- input$dim_red
l$cluster_label <- input$cluster_label
# l$gene_file_path <- input$file_gene$datapath
# print(l$gene_file_path)
# l has following elements with same names for both options above:
Expand All @@ -61,18 +57,18 @@ server <- function(input, output, session) {

# -----------------------------Tab1:table and network------------------------------------------
#def need to re-write this at the end
output$general_desc <- renderText({
"This app designs for displaying transcription factor and gene data from mice brain (cortex & pons part) in various fancy ways by three main tabs;

PROBLEM: There are some transcription factors from your input that may not have the corresponding data
in the following tabs. (Sometimes you may not see the information of that transcription factor or the plot
is not updated, etc. That is unfortunately because of the lack of data in the cell activity data in tab2,
or the binary cell activity data in tab3.
"

})
# output$general_desc <- renderText({
# "This app designs for displaying transcription factor and gene data from mice brain (cortex & pons part) in various fancy ways by three main tabs;
#
# PROBLEM: There are some transcription factors from your input that may not have the corresponding data
# in the following tabs. (Sometimes you may not see the information of that transcription factor or the plot
# is not updated, etc. That is unfortunately because of the lack of data in the cell activity data in tab2,
# or the binary cell activity data in tab3.
# "
#
# })
#filter the data, add a column for logos, then display
output$table <- renderDataTable({
output$table1 <- renderDataTable({
# process data, filter the lines with our interested TF
subset_data <- input_new()$TF_target_gene_info %>% dplyr::filter(TF %in% input_new()$tf) %>% select(TF, gene, Genie3Weight.weight, nMotifs, bestMotif)

Expand All @@ -82,7 +78,8 @@ server <- function(input, output, session) {
colnames = c('Gene' = 'gene', 'Number of Motifs' = 'nMotifs',
'Best Motif' = 'bestMotif',
'Strength of Association' = 'Genie3Weight.weight',
'Logo' = 'motif_logo'))
'Logo' = 'motif_logo'),
rownames = FALSE)
})
# observeEvent(input$reset, {
# reset("file_gene")
Expand Down Expand Up @@ -126,19 +123,35 @@ server <- function(input, output, session) {
)
})
#check if there is a user input gene_list file, if there is, use it, if not, use the selectInput genes

output$network <- renderPlot({
igraph_network <- reactive ({
if(is.null(gene_list$data)){
gene_into_graph <- input_new()$gene
gene_to_highlight <- input_new()$gene
}
else{
gene_into_graph <- gene_list$data
gene_to_highlight <- gene_list$data
}
make_igraph(input_new()$tf, input_new()$TF_target_gene_info,
gene_into_graph, input_new()$label)
#plot_ggnet(net, input_new()$gene)
make_network(input_new()$tf, input_new()$TF_target_gene_info,
gene_to_highlight) #returns an igraph network object
})
network_ggplot <- reactive({
plot_network(igraph_network(), input_new()$label, input_new()$tf)
})

output$network <- renderPlotly({
net_plotly <- network_ggplot() %>% ggplotly(height = 700, tooltip = "text") %>%
layout(xaxis = list(visible = FALSE), yaxis = list(visible = FALSE),
hovermode = "x", hoverdistance = 100)
net_plotly

})

output$download_network <- downloadHandler(filename = "network.pdf",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = network_ggplot(),
width = 8.5, height = 11)
})

#probably redo this entire part to visualize with ggNet
# output$desc <- renderText({
# text <- "\nOrange nodes are active transcription factors (tf genes that express their own tf);
Expand Down Expand Up @@ -208,23 +221,25 @@ server <- function(input, output, session) {
})

output$heatmap_joint <- renderPlot({
hm_joint_cluster_plot()
hm_joint <- hm_joint_cluster_plot()
hm_joint
})

output$download_hm_joint <- downloadHandler(filename = "heatmap_joint.png",
contentType = "image/png",
output$download_hm_joint <- downloadHandler(filename = "heatmap_joint.pdf",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = hm_joint_cluster_plot(),
width = 20, height = 25)
})

output$heatmap_cluster <- renderPlot({
hm_sample_cluster_plot()
hm_sample <- hm_sample_cluster_plot()
hm_sample

})

output$download_hm_cluster <- downloadHandler(filename = "heatmap_cluster.png",
contentType = "image/png",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = hm_sample_cluster_plot(),
width = 20, height = 25)
Expand All @@ -243,22 +258,22 @@ server <- function(input, output, session) {
# seems redundant, just needs one umap function here
Umap_plot_1 <- reactive({
req(length(input_new()$tf)>0)
plot_UMAP(tf_number = 1,input_new()$cell_metadata, activity_data_cluster())
plot_UMAP(tf_number = 1,input_new()$cell_metadata, activity_data_cluster(), input_new()$dim_red)
})
Umap_plot_2 <- reactive({
req(length(input_new()$tf)>1)
plot_UMAP(tf_number = 2,input_new()$cell_metadata, activity_data_cluster())
plot_UMAP(tf_number = 2,input_new()$cell_metadata, activity_data_cluster(), input_new()$dim_red)
})

output$color_by_cluster <- renderPlot({
color_by_cluster(input_new()$cell_metadata, input_new()$cluster_palette)
color_by_cluster(input_new()$cell_metadata, input_new()$cluster_palette, input_new()$dim_red, input_new()$cluster_label)
})

output$cluster1 <- renderPlot({
Umap_plot_1()
})
output$download_UMAP_1 <- downloadHandler(filename = "UMAP1.png",
contentType = "image/png",
output$download_UMAP_1 <- downloadHandler(filename = "UMAP1.pdf",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = Umap_plot_1(),
width = 20, height = 20)
Expand All @@ -269,8 +284,8 @@ server <- function(input, output, session) {
})


output$download_UMAP_2 <- downloadHandler(filename = "UMAP2.png",
contentType = "image/png",
output$download_UMAP_2 <- downloadHandler(filename = "UMAP2.pdf",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = Umap_plot_2(),
width = 20, height = 20)
Expand Down Expand Up @@ -322,18 +337,16 @@ server <- function(input, output, session) {
for(tf_n in input_new()$tfs_not_exist_timeseries){
tf_nexist_string <- paste(tf_nexist_string,tf_n,sep = " " )
}
text <- glue("We do not have these followning tfs in this tab: {tf_nexist_string}")
text <- glue("We do not have data for the following trancription: {tf_nexist_string}")


})


output$timeseries_desc <- renderText({
text <- "Click option: You may double click the color palatte of cell types at the right side to
display that cell type ONLY; you could also click on one cell type to eliminate that in the
plot at left.
Mouse over the white vertical line on the plot to see the cell types.
We only support four plots of your first four tfs input for now."
text <- "Click option: double clicking a cell type in the legend displays that cell type ONLY;
single click removes that cell type from the plot. Mouse over ribbons in the plot to see the cell types.
We only support four plots of your first four transcripton factor inputs."

})

Expand Down Expand Up @@ -367,7 +380,7 @@ server <- function(input, output, session) {
})

output$download_ribbon_1 <- downloadHandler(filename = "timeseries_ribbon.png",
contentType = "image/png",
contentType = "application/pdf",
content = function(file){
ggsave(filename = file, plot = ggplot_list_plot(),
width = 20, height = 15)
Expand Down
Loading