Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
migale
affiliationExplorer
Commits
b52f357b
Commit
b52f357b
authored
Feb 21, 2020
by
Sandra Derozier
Browse files
Issue:
#3
parent
9e4d5d1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
R/app_server.R
View file @
b52f357b
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#' @importFrom phyloseq.extended write_phyloseq
#' @importFrom phyloseq.extended write_phyloseq
#' @importFrom shinyjs hide show
#' @importFrom shinyjs hide show
#' @importFrom dplyr distinct
#' @importFrom dplyr distinct
#' @importFrom tidyverse stringr
app_server
<-
function
(
input
,
output
,
session
)
{
app_server
<-
function
(
input
,
output
,
session
)
{
# Load package data in the session (for testing purpose)
# Load package data in the session (for testing purpose)
# data("physeq", package = "affiliationExplorer")
# data("physeq", package = "affiliationExplorer")
...
@@ -37,7 +38,8 @@ app_server <- function(input, output, session) {
...
@@ -37,7 +38,8 @@ app_server <- function(input, output, session) {
data
<-
reactiveValues
(
data
<-
reactiveValues
(
amb_otus
=
unique
(
affi
$
OTU
),
## Ambiguous otus
amb_otus
=
unique
(
affi
$
OTU
),
## Ambiguous otus
cleaned
=
phyloseq
::
tax_table
(
physeq
)[
unique
(
affi
$
OTU
),
]
%>%
as
(
"matrix"
),
## Their current affiliation
cleaned
=
phyloseq
::
tax_table
(
physeq
)[
unique
(
affi
$
OTU
),
]
%>%
as
(
"matrix"
),
## Their current affiliation
affi
=
NULL
## Placeholder for conflicting affiliations of current ASV
affi
=
NULL
,
## Placeholder for conflicting affiliations of current ASV
sequence
=
NULL
## Placeholder for current OTU sequence
)
)
# Add ASV Select Input
# Add ASV Select Input
...
@@ -49,19 +51,31 @@ app_server <- function(input, output, session) {
...
@@ -49,19 +51,31 @@ app_server <- function(input, output, session) {
choices
=
data
$
amb_otus
,
choices
=
data
$
amb_otus
,
multiple
=
FALSE
)
multiple
=
FALSE
)
)
)
# Add Sequence Checkbox
insertUI
(
select
=
"#tmp"
,
where
=
"beforeEnd"
,
ui
=
checkboxInput
(
"seq"
,
label
=
"Sequence display"
,
value
=
FALSE
)
)
observeEvent
(
input
$
asv
,
{
observeEvent
(
input
$
asv
,
{
# Extract Affiliation for a given OTU
# Extract Affiliation for a given OTU
data
$
affi
<-
extract_affiliation
(
affi
,
input
$
asv
)
%>%
dplyr
::
distinct
()
data
$
affi
<-
extract_affiliation
(
affi
,
input
$
asv
)
data
$
sequence
<-
extract_sequence
(
affi
,
input
$
asv
)
amb
<-
find_level
(
data
$
affi
)
amb
<-
find_level
(
data
$
affi
)
output
$
txt
<-
renderUI
(
HTML
({
paste
(
"<p><b>"
,
input
$
asv
,
"- "
,
nrow
(
data
$
affi
)
,
"conflicting affiliations, ambiguity at rank "
,
amb
,
"</b></p>"
)}))
output
$
txt
<-
renderUI
(
HTML
({
paste
(
"<p><b>"
,
input
$
asv
,
"- "
,
nrow
(
data
$
affi
)
,
"conflicting affiliations, ambiguity at rank "
,
amb
,
"</b></p>"
)}))
output
$
help
<-
renderUI
(
HTML
({
paste
(
"<cite>Select new affiliation by clicking on a row (double click on a cell to edit its content).<br/>"
,
output
$
help
<-
renderUI
(
HTML
({
paste
(
"<cite>Select new affiliation by clicking on a row (double click on a cell to edit its content).<br/>"
,
"Click \"Update ASV\" to update affiliation (with selected row) or \"Skip ASV\" to move to the next one</cite>"
)}))
"Click \"Update ASV\" to update affiliation (with selected row) or \"Skip ASV\" to move to the next one
.
</cite>"
)}))
output
$
table
<-
DT
::
renderDT
({
data
$
affi
},
output
$
table
<-
DT
::
renderDT
({
data
$
affi
},
selection
=
list
(
mode
=
'single'
,
selected
=
NULL
,
target
=
'row'
),
selection
=
list
(
mode
=
'single'
,
selected
=
NULL
,
target
=
'row'
),
editable
=
TRUE
)
editable
=
TRUE
)
## Show considered replacement if one is selected
## Show considered replacement if one is selected
output
$
selection
<-
renderUI
({
output
$
selection
<-
renderUI
({
s
=
input
$
table_rows_selected
s
=
input
$
table_rows_selected
...
@@ -76,6 +90,15 @@ app_server <- function(input, output, session) {
...
@@ -76,6 +90,15 @@ app_server <- function(input, output, session) {
})
})
})
})
observeEvent
(
input
$
seq
,
{
if
(
input
$
seq
)
{
output
$
sequence
<-
renderUI
(
HTML
({
paste
(
"<b>Sequence:</b><br/>"
,
paste
(
unlist
(
strsplit
(
gsub
(
"(.{80})"
,
"\\1 "
,
data
$
sequence
),
" "
)),
collapse
=
"<br/>"
),
"<br/><br/>"
)}))
}
else
{
output
$
sequence
<-
renderUI
(
HTML
(
""
))
}
})
## Allow manual corrections
## Allow manual corrections
observeEvent
(
input
$
table_cell_edit
,
{
observeEvent
(
input
$
table_cell_edit
,
{
data
$
affi
<<-
DT
::
editData
(
data
$
affi
,
input
$
table_cell_edit
,
"table"
)
data
$
affi
<<-
DT
::
editData
(
data
$
affi
,
input
$
table_cell_edit
,
"table"
)
...
...
R/app_ui.R
View file @
b52f357b
...
@@ -40,6 +40,7 @@ app_ui <- function() {
...
@@ -40,6 +40,7 @@ app_ui <- function() {
HTML
(
"<br/>"
),
HTML
(
"<br/>"
),
DT
::
DTOutput
(
"table"
),
DT
::
DTOutput
(
"table"
),
#HTML("<br/>"),
#HTML("<br/>"),
htmlOutput
(
"sequence"
),
htmlOutput
(
"selection"
),
htmlOutput
(
"selection"
),
HTML
(
"<br/>"
),
HTML
(
"<br/>"
),
actionButton
(
"clean"
,
"Update ASV"
),
actionButton
(
"clean"
,
"Update ASV"
),
...
...
R/utils.R
View file @
b52f357b
...
@@ -70,7 +70,16 @@ sort_ambiguous_otu <- function(physeq, affi) {
...
@@ -70,7 +70,16 @@ sort_ambiguous_otu <- function(physeq, affi) {
extract_affiliation
<-
function
(
affi
,
otu
)
{
extract_affiliation
<-
function
(
affi
,
otu
)
{
affi
%>%
affi
%>%
dplyr
::
filter
(
OTU
==
otu
)
%>%
dplyr
::
filter
(
OTU
==
otu
)
%>%
dplyr
::
select
(
Kingdom
:
Species
)
dplyr
::
select
(
Kingdom
:
Species
)
%>%
dplyr
::
distinct
()
}
## Extract all affiliation for a given OTU
extract_sequence
<-
function
(
affi
,
otu
)
{
affi
%>%
dplyr
::
filter
(
OTU
==
otu
)
%>%
dplyr
::
pull
(
sequence
)
%>%
head
(
1
)
}
}
## Find level of ambiguity
## Find level of ambiguity
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment