-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDashboard.Rmd
More file actions
96 lines (81 loc) · 2.97 KB
/
Dashboard.Rmd
File metadata and controls
96 lines (81 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: "SARS-CoV-2 Non-human Shifts "
output: flexdashboard::flex_dashboard
runtime: shiny
---
```{r setup, include=FALSE}
library(shiny)
library(tidyverse)
library(flexdashboard)
library(ape)
library(phangorn)
library(DECIPHER)
library(tictoc)
library(ggtree)
library(plotly)
```
```{r global, include=FALSE}
KnownSeqs <- read.dna("all_aligned.fasta", format = "fasta")
KnownSeqsMeta <- read.table("metadata.csv", header = T, sep = ',')
```
Column {.sidebar}
-----------------------------------------------------------------------
Upload your data here.
```{r}
fileInput("sample", label = "Sequence data:", buttonLabel = "Browse...", placeholder = "No file selected")
selectInput("species", label = "Select organism:",
choices = c("", "All", "canis_lupus", "felis_catus", "human", "mink",
"panthera_leo", "panthera_tigris_jacksoni"), selected = "")
selectInput("location", label = "Select location:",
choices = c("", "All", "China", "Netherlands", "Poland", "Wisconsin-USA", "Unknown"),
selected = "")
```
Column
-----------------------------------------------------------------------
### SARS-CoV-2 Tree
```{r}
# Defining dataset to use
renderTable({
#renderPlot({
if(input$species == "All" & input$location == "All"){
DesiredSeqs <- KnownSeqs
DesiredIds <- KnownSeqsMeta$seqids
}else if(input$species == "All" & input$location != "All"){
DesiredIds <- KnownSeqsMeta %>% dplyr::filter(location == input$location) %>% select(seqid)
DesiredIndex <- which(names(KnownSeqs) %in% DesiredIds)
DesiredSeqs <- KnownSeqs[DesiredIndex]
}else if(input$species != "All" & input$location == "All") {
DesiredIds <- KnownSeqsMeta %>% dplyr::filter(species == input$species) %>% select(seqid)
DesiredIndex <- which(names(KnownSeqs) %in% DesiredIds)
DesiredSeqs <- KnownSeqs[DesiredIndex]
}else if(length(input$species) & length(input$location)){
DesiredIds <- KnownSeqsMeta %>% dplyr::filter(species == input$species, location == input$location) %>% select(seqid)
DesiredIndex <- which(names(KnownSeqs) %in% DesiredIds)
DesiredSeqs <- KnownSeqs[DesiredIndex]
}
DesiredIds
# Adding sample data
#file <- input$sample
#SampleSeq <- readDNAStringSet(file$datapath, format = "fasta")
#DesiredSeqsConv <- DesiredSeqs %>% as.list %>% as.character %>%
# lapply(., paste0, collapse = "") %>% unlist %>% DNAStringSet
#aligned <- AlignProfiles(DesiredSeqsConv, SampleSeq)
#names(as.DNAbin(aligned))
# Phylogenetic tree construction, uncomment when ready
# Initial tree
#tic()
#msa <- phyDat(as.DNAbin(aligned), type = "DNA")
#dm <- dist.ml(msa)
#treeNJ <- NJ(dm)
#ttime=toc
#ML tuning
#fit <- pml(treeNJ, data=aln)
#can also try ratchet/stochastic for rearrangement, but slower (better topology)
#fitGTR <- optim.plm(fit, model="GTR",optInv=TRUE,optGamma=TRUE,
# rearrangement="NNI",control=pml.control(trace=0))
# Plotting tree
#t <- ggtree(treeNJ)
#t
#ggplotly(t)
})
```