Commit a6654723 authored by NAVRATIL VINCENT's avatar NAVRATIL VINCENT
Browse files

added dataset_focus panel

parent 439e0156
......@@ -9,6 +9,7 @@ library(DT)
library(ggplot2)
library(ggtree)
library(ggmsa)
library(tidyverse)
library(readr)
print(getwd())
\ No newline at end of file
......@@ -10,16 +10,39 @@ shinyServer(
# DGINN reactive
#
dginn_df_reactive <- reactive({
dginn_df_focus_reactive <- reactive({
dginn_file <- "../data/covid_comp_DGINNscreen.csv"
dginn_file <- "../data/dataset_focus/DGINN_dataset_focus.csv"
if (is.null(dginn_file)){
return(NULL)
}
else{
colnames <- c("File","Name","Gene","Description","GeneSize","NbSpecies","omegaM0Bpp","omegaM0codeml","BUSTED","BUSTED_p-value","MEME_NbSites","MEME_PSS","BppM1M2","BppM1M2_p-value","BppM1M2_NbSites","BppM1M2_PSS","BppM7M8","BppM7M8_p-value","BppM7M8_NbSites","BppM7M8_PSS","codemlM1M2","codemlM1M2_p-value","codemlM1M2_NbSites","codemlM1M2_PSS","codemlM7M8","codemlM7M8_p-value","codemlM7M8_NbSites","codemlM7M8_PSS")
colnames <- c("File","Name","Gene","Description","GeneSize","NbSpecies","BUSTED","BUSTED_p-value","MEME_NbSites","MEME_PSS","BppM1M2","BppM1M2_p-value","BppM1M2_NbSites","BppM1M2_PSS","BppM7M8","BppM7M8_p-value","BppM7M8_NbSites","BppM7M8_PSS","codemlM1M2","codemlM1M2_p-value","codemlM1M2_NbSites","codemlM1M2_PSS","codemlM7M8","codemlM7M8_p-value","codemlM7M8_NbSites","codemlM7M8_PSS")
df <- read.csv2(dginn_file,sep=",",strip.white = TRUE)
df <- df[,c(-1)]
names(df) <- colnames
df$BppM7M8_NbSites <- as.numeric(df$BppM7M8_NbSites)
sel <- df$BppM1M2_NbSites+df$BppM7M8_NbSites+df$codemlM1M2_NbSites+df$codemlM7M8_NbSites
sel <- sel == 0 | is.na(sel)
return(df[!sel,])
}
})
dginn_df_full_reactive <- reactive({
dginn_file <- "../data/dataset_full/DGINN_dataset_full.csv"
if (is.null(dginn_file)){
return(NULL)
}
else{
colnames <- c("File","Name","Gene","Description","GeneSize","NbSpecies","omegaM0Bpp","omegaM0codeml","BUSTED","BUSTED_p-value","MEME_NbSites","MEME_PSS","BppM1M2","BppM1M2_p-value","BppM1M2_NbSites","BppM1M2_PSS","BppM7M8","BppM7M8_p-value","BppM7M8_NbSites","BppM7M8_PSS","codemlM1M2","codemlM1M2_p-value","codemlM1M2_NbSites","codemlM1M2_PSS","codemlM7M8","codemlM7M8_p-value","codemlM7M8_NbSites","codemlM7M8_PSS")
df <- read.csv2(dginn_file,sep=",")
#split primates and bat data
......@@ -35,20 +58,51 @@ shinyServer(
sel <- sel == 0 | is.na(sel)
return(df[!sel,])
}
}
})
dginn_site_df_reactive <- reactive({
dginn_site_df_focus_reactive <- reactive({
selected <- input$dginn_data_rows_selected
selected <- input$dginn_data_focus_rows_selected
if (is.null(selected)){
return(NULL)
}
else{
raw_selected <- dginn_df_focus_reactive()[selected,]
models <- c("BppM1M2","BppM7M8","codemlM1M2","codemlM7M8")
df <- data.frame()
for(i in 1:length(models)){
if(dginn_df_focus_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
dginn_position <- as.integer(strsplit(as.character(dginn_df_focus_reactive()[selected,paste(models[i],"PSS",sep="_")]),",")[[1]])
dginn_pvalue <- as.integer(strsplit(as.character(dginn_df_focus_reactive()[selected,paste(models[i],"p-value",sep="_")]),",")[[1]])
dginn_position_df <- data.frame("models" = models[i],"site" = dginn_position,"p-value" = dginn_pvalue )
df <- rbind(df,dginn_position_df)
}
}
return(df)
}
})
dginn_site_df_full_reactive <- reactive({
selected <- input$dginn_data_full_rows_selected
if (is.null(selected)){
return(NULL)
}
else{
raw_selected <- dginn_df_reactive()[selected,]
raw_selected <- dginn_df_full_reactive()[selected,]
models <- c("BppM1M2","BppM7M8","codemlM1M2","codemlM7M8")
......@@ -56,10 +110,10 @@ shinyServer(
for(i in 1:length(models)){
if(dginn_df_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
if(dginn_df_full_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
dginn_position <- as.integer(strsplit(as.character(dginn_df_reactive()[selected,paste(models[i],"PSS",sep="_")]),",")[[1]])
dginn_pvalue <- as.integer(strsplit(as.character(dginn_df_reactive()[selected,paste(models[i],"p-value",sep="_")]),",")[[1]])
dginn_position <- as.integer(strsplit(as.character(dginn_df_full_reactive()[selected,paste(models[i],"PSS",sep="_")]),",")[[1]])
dginn_pvalue <- as.integer(strsplit(as.character(dginn_df_full_reactive()[selected,paste(models[i],"p-value",sep="_")]),",")[[1]])
dginn_position_df <- data.frame("models" = models[i],"site" = dginn_position,"p-value" = dginn_pvalue )
df <- rbind(df,dginn_position_df)
......@@ -74,15 +128,29 @@ shinyServer(
#
# Tree data reactive
#
#
tree_data_focus_reactive <- reactive({
selected <- input$dginn_data_focus_rows_selected
file=dginn_df_focus_reactive()[selected,"File"]
species=dginn_df_focus_reactive()[selected,"Name"]
path="../data/dataset_focus/"
gene=dginn_df_focus_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
read_file(paste(file_url,".phylip_phyml_tree.txt",sep=""))
})
tree_data_reactive <- reactive({
tree_data_full_reactive <- reactive({
selected <- input$dginn_data_rows_selected
selected <- input$dginn_data_full_rows_selected
file=dginn_df_reactive()[selected,"File"]
species=dginn_df_reactive()[selected,"Name"]
path="../data/"
gene=dginn_df_reactive()[selected,"Gene"]
file=dginn_df_full_reactive()[selected,"File"]
species=dginn_df_full_reactive()[selected,"Name"]
path="../data/dataset_full/"
gene=dginn_df_full_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
read_file(paste(file_url,".phylip_phyml_tree.txt",sep=""))
......@@ -91,16 +159,30 @@ shinyServer(
#
# MSA data reactive
#
#
msa_data_reactive <- reactive({
selected <- input$dginn_data_rows_selected
msa_data_focus_reactive <- reactive({
selected <- input$dginn_data_focus_rows_selected
file=dginn_df_reactive()[selected,"File"]
species=dginn_df_reactive()[selected,"Name"]
path="../data/"
gene=dginn_df_reactive()[selected,"Gene"]
file=dginn_df_focus_reactive()[selected,"File"]
species=dginn_df_focus_reactive()[selected,"Name"]
path="../data/dataset_focus/"
gene=dginn_df_focus_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
read_file(paste(file_url,".phylip",sep=""))
})
msa_data_full_reactive <- reactive({
selected <- input$dginn_data_full_rows_selected
file=dginn_df_full_reactive()[selected,"File"]
species=dginn_df_full_reactive()[selected,"Name"]
path="../data/dataset_full/"
gene=dginn_df_full_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
read_file(paste(file_url,".best.fas",sep=""))
......@@ -110,9 +192,20 @@ shinyServer(
# rendering functions
# renderDataTable -- DGINN data table
output$dginn_data <- DT::renderDataTable({
output$dginn_data_focus <- DT::renderDataTable({
df <- dginn_df_focus_reactive()
},
selection = 'single',
rownames= FALSE,
options = list(pageLength = 5, columnDefs = list( list(targets = 0, visible = FALSE)))
)
output$dginn_data_full <- DT::renderDataTable({
df <- dginn_df_reactive()
df <- dginn_df_full_reactive()
},
selection = 'single',
......@@ -120,16 +213,99 @@ shinyServer(
options = list(pageLength = 5, columnDefs = list( list(targets = 0, visible = FALSE)))
)
#renderPlotOutput -- ggTree + msa + summary
output$ggtree_plot <- renderPlot({
#renderPlotOutput -- ggTree + msa + summary
output$ggtree_plot_focus <- renderPlot({
selected <- input$dginn_data_focus_rows_selected
if (! is.null(selected)){
species=dginn_df_focus_reactive()[selected,"Name"]
file=dginn_df_focus_reactive()[selected,"File"]
path="../data/dataset_focus/"
gene=dginn_df_focus_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
tree=read.tree(paste(file_url,".phylip_phyml_tree.txt",sep=""))
model=input$model_parameter_rb
#
# get dginn_data_model_summary
#
models <- c("MEME","BppM1M2","BppM7M8","codemlM1M2","codemlM7M8")
dginn_data_model_summary <- list()
dginn_data_model_summary[1] <- c()
for(i in 1:length(models)){
if(dginn_df_focus_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
dginn_position <- as.character(dginn_df_focus_reactive()[selected,paste(models[i],"PSS",sep="_")])
dginn_data_model_summary[1] = c(dginn_data_model_summary[1],as.integer(strsplit(dginn_position,",")[[1]]))
dginn_data_model_summary[[i+1]]= as.integer(strsplit(dginn_position,",")[[1]])
}
else{
dginn_data_model_summary[[i+1]] <- NA
}
}
names(dginn_data_model_summary) <- c("summary",models)
dginn_data_model_summary$summary <- table(dginn_data_model_summary$summary)
phylopic_id=""
if(species=="primates"){
phylopic_id="2d078b25-e6a0-4beb-a5d3-5d6f16be8ebf"
}
if(species=="bats"){
phylopic_id="18bfd2fc-f184-4c3a-b511-796aafcc70f6"
}
p <- ggtree(tree,size=1) + geom_tiplab(size=5)
p_msa_window <- dginn_msaplot(p, paste(file_url,".phylip",sep=""), offset=1, width=5, window=c(120, 200))
p_msa <- dginn_msaplot(p, paste(file_url,".phylip",sep=""),dginn_position=as.numeric(names(dginn_data_model_summary$summary)), offset=1, width=5)
p_msa_summary <- dginn_msaplot_summary(p, paste(file_url,".phylip",sep=""),dginn_summary=dginn_data_model_summary, offset=1, width=5)
grid.arrange(cowplot::get_legend(p_msa_summary),p_msa_summary+ theme(legend.position = "none") ,p_msa+ theme(legend.position = "none"),nrow=3,ncol=1,heights=c(10,5,2*dginn_df_focus_reactive()[selected,"NbSpecies"]))
removeUI(
selector="#tree"
)
insertUI(
selector = "#ggtree_plot",
where = "afterEnd",
ui = downloadLink("tree",".tree")
)
removeUI(
selector="#msa"
)
insertUI(
selector = "#ggtree_plot",
where = "afterEnd",
ui = downloadLink("msa",".fasta")
)
}
}
)
output$ggtree_plot_full <- renderPlot({
selected <- input$dginn_data_rows_selected
selected <- input$dginn_data_full_rows_selected
if (! is.null(selected)){
species=dginn_df_reactive()[selected,"Name"]
file=dginn_df_reactive()[selected,"File"]
path="../data/"
gene=dginn_df_reactive()[selected,"Gene"]
species=dginn_df_full_reactive()[selected,"Name"]
file=dginn_df_full_reactive()[selected,"File"]
path="../data/dataset_full/"
gene=dginn_df_full_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
tree=read.tree(paste(file_url,".phylip_phyml_tree.txt",sep=""))
......@@ -145,9 +321,9 @@ shinyServer(
for(i in 1:length(models)){
if(dginn_df_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
if(dginn_df_full_reactive()[selected,paste(models[i],"NbSites",sep="_")] >0){
dginn_position <- as.character(dginn_df_reactive()[selected,paste(models[i],"PSS",sep="_")])
dginn_position <- as.character(dginn_df_full_reactive()[selected,paste(models[i],"PSS",sep="_")])
dginn_data_model_summary[1] = c(dginn_data_model_summary[1],as.integer(strsplit(dginn_position,",")[[1]]))
dginn_data_model_summary[[i+1]]= as.integer(strsplit(dginn_position,",")[[1]])
}
......@@ -176,7 +352,7 @@ shinyServer(
p_msa <- dginn_msaplot(p, paste(file_url,".best.fas",sep=""),dginn_position=as.numeric(names(dginn_data_model_summary$summary)), offset=1, width=5)
p_msa_summary <- dginn_msaplot_summary(p, paste(file_url,".best.fas",sep=""),dginn_summary=dginn_data_model_summary, offset=1, width=5)
grid.arrange(cowplot::get_legend(p_msa_summary),p_msa_summary+ theme(legend.position = "none") ,p_msa+ theme(legend.position = "none"),nrow=3,ncol=1,heights=c(10,5,2*dginn_df_reactive()[selected,"NbSpecies"]))
grid.arrange(cowplot::get_legend(p_msa_summary),p_msa_summary+ theme(legend.position = "none") ,p_msa+ theme(legend.position = "none"),nrow=3,ncol=1,heights=c(10,5,2*dginn_df_full_reactive()[selected,"NbSpecies"]))
removeUI(
selector="#tree"
......@@ -204,10 +380,19 @@ shinyServer(
)
#renderDataTable -- DGINN sites
output$dginn_site_data_focus <- DT::renderDataTable({
df <- dginn_site_df_focus_reactive()
},
output$dginn_site_data <- DT::renderDataTable({
selection = 'single',
rownames= FALSE,
options = list(pageLength = 5)
)
output$dginn_site_data_full <- DT::renderDataTable({
df <- dginn_site_df_reactive()
df <- dginn_site_df_full_reactive()
},
selection = 'single',
......@@ -216,20 +401,48 @@ shinyServer(
)
#renderPlotOutput -- ggTree + msa around sites
output$ggtree_ggmsa_site_plot <- renderPlot({
output$ggtree_ggmsa_site_plot_focus <- renderPlot({
selected <- input$dginn_data_rows_selected
selected_site <- input$dginn_site_data_rows_selected
selected <- input$dginn_data_focus_rows_selected
selected_site <- input$dginn_site_data_focus_rows_selected
if (! is.null(selected_site)){
species=dginn_df_reactive()[selected,"Name"]
file=dginn_df_reactive()[selected,"File"]
path="../data/"
gene=dginn_df_reactive()[selected,"Gene"]
species=dginn_df_focus_reactive()[selected,"Name"]
file=dginn_df_focus_reactive()[selected,"File"]
path="../data/dataset_focus/"
gene=dginn_df_focus_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
tree=read.tree(paste(file_url,".phylip_phyml_tree.txt",sep=""))
site <- dginn_site_df_reactive()[selected_site,"site"]*3
site <- dginn_site_df_focus_reactive()[selected_site,"site"]*3
codon_size <- 2
codon_window <- 2
msa_path <- paste(file_url,".phyip",sep="")
ggmsa(msa_path, site-codon_size-(codon_window*3), site+(codon_window*3), color = "Chemistry_NT", seq_name = T,consensus_views = TRUE, disagreement = FALSE)+ geom_seqlogo()+ geom_msaBar()
#p <- ggtree(tree) + geom_tiplab()
#data = tidy_msa(paste(file_url,".best.fas",sep=""), site-10, site+10)
#p + geom_facet(geom = geom_msa, data = data, panel = 'msa', color = "Chemistry_NT") +xlim_tree(1)
}
})
output$ggtree_ggmsa_site_plot_full <- renderPlot({
selected <- input$dginn_data_full_rows_selected
selected_site <- input$dginn_site_data_full_rows_selected
if (! is.null(selected_site)){
species=dginn_df_full_reactive()[selected,"Name"]
file=dginn_df_full_reactive()[selected,"File"]
path="../data/dataset_full/"
gene=dginn_df_full_reactive()[selected,"Gene"]
file_url=paste(path,species,file,sep="/")
tree=read.tree(paste(file_url,".phylip_phyml_tree.txt",sep=""))
site <- dginn_site_df_full_reactive()[selected_site,"site"]*3
codon_size <- 2
codon_window <- 2
msa_path <- paste(file_url,".best.fas",sep="")
......@@ -243,22 +456,30 @@ shinyServer(
}
})
output$tree <- downloadHandler(
output$tree_focus <- downloadHandler(
filename = function() {
paste0(input$tree_focus, ".tree")
},
content = function(file) {
write(tree_data_focus_reactive(), file)
}
)
output$tree_focus <- downloadHandler(
filename = function() {
paste0(input$tree, ".tree")
paste0(input$tree_focus, ".tree")
},
content = function(file) {
write(tree_data_reactive(), file)
write(tree_data_focus_reactive(), file)
}
)
output$msa <- downloadHandler(
output$msa_full <- downloadHandler(
filename = function() {
paste0(input$msa, ".msa")
paste0(input$msa_full, ".msa")
},
content = function(file) {
write(msa_data_reactive(), file)
write(msa_data_full_reactive(), file)
}
)
......
......@@ -25,7 +25,7 @@ shinyUI(
fluidRow(
column(12,
tags$div(class="header", checked=NA,
HTML("This is the online supplementary materials of the manuscript entitled <b>'Evolutionary history of SARS-CoV-2 interacting proteins in primates and bats reveals major host determinants, including TMPRSS2, FYCO1, RIPK1, and TBK1.'</b> by Cariou M. et <i>al.</i><br>doi://<br>Add other informatio stuff ...")
HTML('This is the online material of the manuscript entitled <b>"Distinct evolutionary trajectories of SARS-CoV-2 interacting proteins in bats and primates identify host determinants of COVID-19"</b> by Cariou et al. (doi:// to come). <br><br>The <b>"DGINN full dataset"</b> is the result of the automated screens of positive selection on SARS-CoV-2 interacting proteins. When selecting/clicking on a gene, a visualization of corresponding alignments, phylogenetic trees and results of positive selection analyses (genes and sites), as well as links to download original files, are provided.<br><br>The <b>"Genes of focus "</b> is the result of a curated and enriched analysis of genes of interest. A visualization of corresponding alignments, phylogenetic trees and results of positively selection analyses (genes and sites), as well as links to download original files, are provided.')
)
)
),
......@@ -36,21 +36,51 @@ shinyUI(
fluidRow(
column(12,
tabsetPanel(type = "tabs",
tabPanel("Genes of focus",
tags$div(class="header", checked=NA,
HTML("<br><br><br>For genes under positive selection, <b>please select/click on a row</b> to visualize the sites under positive selection (PSS) and the surrounding codons at the nucleotide level.")),
shinycssloaders::withSpinner(
DT::dataTableOutput("dginn_data_focus")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Table: DGINN gene summary table.</b> This table is the output of DGINN and highlights the nucleotide sites under positive selection (PSS) infered at the codon level by the BppM1M2, BppM7M8, codemlM1M2, codemlM7M8 models in either primates and bats taxonomic lineages for a selection of genes encoding SARSCov-2 Viral Interacting Proteins (aka VIP) identified by the Krogan Laboratory [https://doi.org/10.1038/s41586-020-2286-9].")),
shinycssloaders::withSpinner(
plotOutput("ggtree_plot_focus",height = "800px")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Figure: Phylogenetic tree + MSA</b>. This is a back to back representation of the phylogentic tree and a simplified MSA where lightgrey and darkgrey regions of the MSA correspond respectively to substitution and insertion/deletion events.<br><br>")),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Please select a row</b> to visualise candidates sites in the context of the MSA.<br><br>")),
shinycssloaders::withSpinner(
DT::dataTableOutput("dginn_site_data_focus")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Table: DGINN output by PSS.</b>This table contains a list of candidate PSS with their p-values.")),
shinycssloaders::withSpinner(
plotOutput("ggtree_ggmsa_site_plot_focus",width="400px",height = "800px")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Figure PSS MSA.</b> This is a representation of the nucleotide MSA around the candidate PSS codon.<br><br>"))
),
tabPanel("DGINN full dataset",
tags$div(class="header", checked=NA,
HTML("<br><br><b>Please select/click on a row</b> to visualise candidates PSS infered by DGINN [https://doi.org/10.1093/nar/gkaa680] on top of a simplified Multiple Sequence Alignment (MSA).<br>At the bottom of the phylogenetic tree and MSA, users can download data by following the <b><i>.tree</i></b> and <b><i>.fas</i></b> hyperlinks.
</br>Add other informatio stuff ...<br><br>")),
HTML("<br><br><br>For genes under positive selection, <b>please select/click on a row</b> to visualize the sites under positive selection (PSS) and the surrounding codons at the nucleotide level.")),
shinycssloaders::withSpinner(
DT::dataTableOutput("dginn_data")
DT::dataTableOutput("dginn_data_full")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Table: DGINN gene summary table.</b> This table is the output of DGINN and highlights the nucleotide sites under positive selection (PSS) infered at the codon level by the BppM1M2, BppM7M8, codemlM1M2, codemlM7M8 models in either primates and bats taxonomic lineages for a selection of genes encoding SARSCov-2 Viral Interacting Proteins (aka VIP) identified by the Krogan Laboratory [https://doi.org/10.1038/s41586-020-2286-9].")),
shinycssloaders::withSpinner(
plotOutput("ggtree_plot",height = "800px")
plotOutput("ggtree_plot_full",height = "800px")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Figure: Phylogenetic tree + MSA</b>. This is a back to back representation of the phylogentic tree and a simplified MSA where lightgrey and darkgrey regions of the MSA correspond respectively to substitution and insertion/deletion events.<br><br>")),
......@@ -58,19 +88,18 @@ shinyUI(
HTML("<br><br><b>Please select a row</b> to visualise candidates sites in the context of the MSA.<br><br>")),
shinycssloaders::withSpinner(
DT::dataTableOutput("dginn_site_data")
DT::dataTableOutput("dginn_site_data_full")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Table: DGINN output by PSS.</b>This table contains a list of candidate PSS with their p-values.")),
shinycssloaders::withSpinner(
plotOutput("ggtree_ggmsa_site_plot",width="400px",height = "800px")
plotOutput("ggtree_ggmsa_site_plot_full",width="400px",height = "800px")
),
tags$div(class="header", checked=NA,
HTML("<br><br><b>Figure PSS MSA.</b> This is a representation of the nucleotide MSA around the candidate PSS codon.<br><br>"))
),
tabPanel("DGINN dataset 2","")
)
)
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment