Commit 1e84ce41 authored by NAVRATIL VINCENT's avatar NAVRATIL VINCENT
Browse files

init virhostevol dginn shiny app

parent 26866a71
This diff is collapsed.
This diff is collapsed.
(rouAeg_TMPRSS2_XM_016134588:0.05626968,(pteAle_TMPRSS2_NM_001386133:0.00859853,pteVam_TMPRSS2_XM_023538199:0.01337738)0.999850:0.02316226,((rhiFer_TMPRSS2_XM_033088817:0.03274977,(hipArm_TMPRSS2_XM_019626040:0.01405727,hipArm_TMPRSS2_NW_017732334:0.04134221)0.999850:0.02273154)0.999850:0.02653049,((desRot_TMPRSS2_XM_024561824:0.05283153,(phyDis_TMPRSS2_XM_028504691:0.06183253,(stuHon_TMPRSS2_XM_037043001:0.02518806,artJam_TMPRSS2_XM_037144609:0.03025072)0.999850:0.01265798)0.999850:0.01805772)0.999850:0.06961405,(molMol_TMPRSS2_XM_036243106:0.07445678,(minNat_TMPRSS2_XM_016220949:0.07489686,((eptFus_TMPRSS2_XR_003619148:0.01627071,pipKuh_TMPRSS2_XM_036446834:0.07584755)0.999850:0.02245469,((myoDav_TMPRSS2_XM_006754330:0.01050701,myoMyo_TMPRSS2_XM_036350392:0.01268703)0.994946:0.00466736,(myoBra_TMPRSS2_XM_005885695:0.00360941,myoLuc_TMPRSS2_XM_006104440_XM_023746917:0.00721827)0.680516:0.00241590)0.999850:0.00893859)0.999850:0.04999729)0.478701:0.00599404)0.999850:0.01128858)0.999850:0.03116288)0.999850:0.06815320);
File Name Gene 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 BppDFP07_0DFP07 BppDFP07_0DFP07_p-value BppDFP07_0DFP07_NbSites BppDFP07_0DFP07_PSS codemlM1M2 codemlM1M2_p-value codemlM1M2_NbSites codemlM1M2_PSS codemlM7M8 codemlM7M8_p-value codemlM7M8_NbSites codemlM7M8_PSS
Bats_TMPRSS2_codonAln_prank Bats TMPRSS2 496 17 0.11994443953570185779 0.124 na na 0 na N 0.9999980760140125 0 na Y 0.013540419403513491 2 364, 435 Y 0.01756110933912218 6 49, 216, 268, 364, 413, 435 N 1.0 0 na N 0.28365402649970844 0 na
Primates_TMPRSS2_codonAln_prank Primates TMPRSS2 563 28 0.33353462759989532804 0.306 na na 0 na Y 0.010104418438157323 2 224, 412 Y 2.9590581143453536e-05 5 224, 312, 315, 412, 500 Y 0.016719533826509363 42 78, 82, 83, 86, 89, 91, 108, 110, 115, 117, 124, 127, 140, 166, 169, 192, 224, 232, 253, 266, 302, 312, 313, 315, 316, 364, 375, 376, 378, 379, 412, 426, 430, 448, 453, 455, 460, 461, 500, 503, 519, 552 Y 4.265291637964482e-06 2 224, 412 Y 9.163844876377388e-09 5 224, 312, 315, 412, 500
\ No newline at end of file
This diff is collapsed.
(carSyr_TMPRSS2_XM_008068563:0.10498782,(otoGar_TMPRSS2_XM_023518095:0.12480530,(proCoq_TMPRSS2_XM_012640067:0.04867604,micMur_TMPRSS2_XM_012749836:0.10708347)0.999850:0.05038521)0.999850:0.04570907,((aotNan_TMPRSS2_XM_021669490:0.01652995,(calJac_TMPRSS2_XM_008986722:0.02477541,(saiBolBol_TMPRSS2_XM_003927595:0.02265989,(cebCapImi_TMPRSS2_XM_017538613:0.00500929,sapApe_TMPRSS2_XM_032276824:0.00341130)0.999850:0.01822206)0.954161:0.00222602)0.999850:0.00679087)0.999850:0.03721688,(((nomLeu_TMPRSS2_XM_003280394:0.00753261,hylMol_TMPRSS2_XM_032174256:0.00538577)0.999850:0.01464587,(ponAbe_TMPRSS2_XM_024239540:0.01688843,((gorGorGor_TMPRSS2_XM_004062839:0.00000001,gorGorGor_TMPRSS2_XM_019017901:0.00000001)0.999850:0.00730161,((homSap_potTMPRSS2_AK291813:0.00203948,(homSap_potTMPRSS2_AK296860:0.00074562,(homSap_TMPRSS2_AF329454:0.00078264,homSap_potTMPRSS2_U75329:0.00395940)0.993306:0.00135668)0.642405:0.00051088)0.999850:0.00348408,(panTro_TMPRSS2_XM_001172064:0.00287797,panPan_TMPRSS2_XM_003823903:0.00366881)0.999850:0.00325585)0.999850:0.00602644)0.999850:0.01012769)0.998372:0.00311564)0.999850:0.00767126,((pilTep_TMPRSS2_XM_023191879:0.01495455,(traFra_TMPRSS2_XM_033232531:0.00546825,(rhiBie_TMPRSS2_XM_017880225:0.00127629,rhiRox_TMPRSS2_XM_010354508:0.00186499)0.999850:0.00475472)0.999850:0.00495872)0.992504:0.00323405,((chlSab_TMPRSS2_XM_007968757:0.00000001,chlSab_TMPRSS2_XM_007968748:0.00000001)0.999850:0.01276860,((macFas_TMPRSS2_XM_005548643:0.00193949,(macNem_TMPRSS2_XM_011725990:0.00000001,macMul_TMPRSS2_XM_028845316:0.00319274)0.255730:0.00061313)0.999850:0.00802112,((papAnu_TMPRSS2_XM_009202216:0.00196540,theGel_TMPRSS2_XM_025380759:0.00792282)0.999850:0.00571288,(manLeu_TMPRSS2_XM_011984191:0.00695618,cerAty_TMPRSS2_XM_012037328:0.00978181)0.548752:0.00138968)0.999850:0.00247857)0.999850:0.00487056)0.999850:0.00737023)0.999850:0.02855582)0.999850:0.02333118)0.999850:0.03685660);
This diff is collapsed.
(XM_011354834:0.00157719,XM_015600260:0.00240822,(XM_016128506:0.01361053,((XM_033103521:0.03197661,XR_002124005:0.02428585)0.999850:0.01522639,((XM_024557889:0.01959986,(XM_028511095:0.02102910,(XM_037154281:0.01751506,XM_037053455:0.01815479)0.999850:0.00941194)0.999850:0.00401886)0.999850:0.02916657,(XM_036248855:0.03863051,(XM_016212661:0.03156496,(XM_036415359:0.03313243,((XM_006100605:0.00791515,XM_005861025:0.00346474)0.999850:0.00438787,(XM_036316928:0.00404601,XM_006776447:0.01503045)0.999850:0.00273656)0.999850:0.00904132)0.999850:0.02917948)0.996459:0.00336978)0.999850:0.00402107)0.999850:0.01183408)0.999850:0.02736169)0.999850:0.01142755);
library(ggtree)
dginn_data = read.csv2("/Users/navratil/PRABI/git/shinyapps-virhostevol/data/TMPRSS2/DGINN_202103062052_summary.tab",sep="\t")
\ No newline at end of file
library(ggplot2)
dginn_msaplot <- function(p, fasta, offset=0, width=1, color=NULL, window=NULL, dginn_position=NULL, bg_line = TRUE, height = 0.8){
if (missingArg(fasta)) {
x <- NULL
} else if (is(fasta, "DNAbin") || is(fasta, "AAbin") ) {
x <- fasta
} else if (is(fasta, "character")) {
x <- treeio::read.fasta(fasta)
} else {
x <- NULL
}
if (is.null(x) && is(p, "treedata") && length(p@tip_seq)) {
x <- p@tip_seq
p <- ggtree(p) + geom_tiplab()
}
if (is.null(x)) {
stop("multiple sequence alignment is not available...\n-> check the parameter 'fasta'...")
}
x <- as.matrix(x)
if (!all(labels(x) %in% p$data$label)) {
stop("taxa name in input sequences are not match with the ones on the tree, please check your input files...")
}
if (is.null(window)) {
window <- c(1, ncol(x))
}
slice <- seq(window[1], window[2], by=1)
x <- x[, slice]
seqs <- lapply(1:nrow(x), function(i) {
seq <- as.vector(as.character(x[i,]))
seq[seq %in% c('a','t','g','c','*')] <- 'MSA'
seq[dginn_position] <- 'PSS'
seq[! seq %in% c('PSS','MSA')] <- '-'
return(seq)
})
names(seqs) <- labels(x)
if(is.null(color)) {
alphabet <- unlist(seqs) %>% unique
alphabet <- alphabet[alphabet != '-']
## color <- rainbow_hcl(length(alphabet))
color <- getCols(length(alphabet))
names(color) <- alphabet
color <- c(color, '-'=NA)
}
df <- p$data
## if (is.null(width)) {
## width <- (df$x %>% range %>% diff)/500
## }
## convert width to width of each cell
width <- width * (df$x %>% range %>% diff) / diff(window)
df=df[df$isTip,]
start <- max(df$x) * 1.02 + offset
seqs <- seqs[df$label[order(df$y)]]
## seqs.df <- do.call("rbind", seqs)
h <- ceiling(diff(range(df$y))/length(df$y))
xmax <- start + seq_along(slice) * width
xmin <- xmax - width
y <- sort(df$y)
ymin <- y - height/2 *h
ymax <- y + height/2 *h
from <- to <- NULL
lines.df <- data.frame(from=min(xmin), to=max(xmax), y = y)
if (bg_line) {
p <- p + geom_segment(data=lines.df, aes(x=from, xend=to, y=y, yend=y),
size=h*.2, inherit.aes = FALSE)
}
msa <- lapply(1:length(y), function(i) {
data.frame(name=names(seqs)[i],
xmin=xmin,
xmax=xmax,
ymin=ymin[i],
ymax=ymax[i],
seq=seqs[[i]])
})
msa.df <- do.call("rbind", msa)
p <- p + geom_rect(aes(xmin=xmin, xmax=xmax,
ymin=ymin, ymax=ymax,
fill=seq),
data=msa.df, inherit.aes = FALSE) +
scale_fill_manual(values=c(NA,"black","yellow"))
breaks <- graphics::hist(seq_along(slice), breaks=10, plot=FALSE)$breaks
pos <- start + breaks * width
mapping <- data.frame(from=breaks+1, to=pos)
attr(p, "mapping") <- mapping
return(p)
}
source('helper.R')
shinyServer(
function(input, output) {
# reactive function
#
# Taxonomy reactive
#
dginn_df_reactive <- reactive({
dginn_data
})
# renderDataTable -- DGINN data table
output$dginn_data <- DT::renderDataTable({
df <- dginn_df_reactive()
},
selection = 'single')
#renderPlotOutput -- Taxonomy z-score
output$ggtree_plot <- renderPlot({
selected <- input$dginn_data_rows_selected
if (! is.null(selected)){
file=dginn_df_reactive()[selected,"File"]
path="../data/"
gene=dginn_df_reactive()[selected,"Gene"]
file_url=paste(path,gene,file,sep="/")
tree=read.tree(paste(file_url,".phylip_phyml_tree.txt",sep=""))
model=input$model_parameter_rb
dginn_position=as.character(dginn_df_reactive()[selected,paste(model,"PSS",sep="_")])
p <- ggtree(tree) + geom_tiplab(size=3)
dginn_msaplot(p, paste(file_url,".fas",sep=""),dginn_position=as.integer(strsplit(dginn_position,",")[[1]]), offset=1, width=5)
#msaplot(p, paste(file_url,".fas",sep=""), offset=1, width=5)
}
}
)
})
library(shinythemes)
library(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
theme = shinytheme("cerulean"),
# Application title
titlePanel("VirHostEvol"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
),
# Show a plot of the generated distribution
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("DGINN dataset",
DT::dataTableOutput("dginn_data"),
plotOutput("ggtree_plot"),
radioButtons("model_parameter_rb", label = "Select model:",choices = list("BppM1M2","BppM7M8","BppDFP07_0DFP07","codemlM1M2","codemlM7M8"), selected = "BppM1M2")
)
)
)
)
)
)
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