Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
easy16S
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Midoux Cedric
easy16S
Commits
b899b6ec
Commit
b899b6ec
authored
Jun 09, 2020
by
Midoux Cedric
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transfo switch
parent
ddb88463
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
22 deletions
+41
-22
panels/dataInput.R
panels/dataInput.R
+31
-21
server.R
server.R
+3
-1
ui.R
ui.R
+7
-0
No files found.
panels/dataInput.R
View file @
b899b6ec
...
...
@@ -119,9 +119,9 @@ output$dataUI <- renderUI({
})
observeEvent
(
input
$
okData
,
{
physeq
(
NULL
)
raw_
physeq
(
NULL
)
try
(
physeq
(
raw_
physeq
(
switch
(
input
$
dataset
,
"demo"
=
...
...
@@ -171,7 +171,8 @@ observeEvent(input$okData, {
outFile
=
showModal
(
dataInput
(
failed
=
TRUE
))
)
if
(
inherits
(
physeq
(),
"phyloseq"
))
{
if
(
inherits
(
raw_physeq
(),
"phyloseq"
))
{
physeq
(
raw_physeq
())
message
(
paste
(
"[Easy16S] Correct upload with"
,
input
$
dataset
,
"mode :"
,
message
))
removeModal
()
}
else
{
...
...
@@ -190,7 +191,7 @@ filterSample <- function() {
inline
=
TRUE
,
choices
=
c
(
"Sample"
=
"sample"
,
sample_variables
(
physeq
(),
errorIfNULL
=
FALSE
)
sample_variables
(
raw_
physeq
(),
errorIfNULL
=
FALSE
)
),
selected
=
"sample"
),
...
...
@@ -211,10 +212,10 @@ output$filterUI <- renderUI({
if
(
input
$
filterCriteria
==
"sample"
)
{
label
<-
"Sample to keep :"
choices
<-
sample_names
(
physeq
())
choices
<-
sample_names
(
raw_
physeq
())
}
else
{
label
<-
"Variable to keep :"
choices
<-
levels
(
get_variable
(
physeq
(),
input
$
filterCriteria
))
choices
<-
levels
(
get_variable
(
raw_
physeq
(),
input
$
filterCriteria
))
}
observe
({
...
...
@@ -250,16 +251,18 @@ observeEvent(input$selectData, {
}
else
{
try
(
if
(
input
$
filterCriteria
==
"sample"
)
{
physeq
(
prune_samples
(
samples
=
input
$
filterCheck
,
physeq
()))
raw_physeq
(
prune_samples
(
samples
=
input
$
filterCheck
,
raw_
physeq
()))
}
else
{
criteria
<<-
input
$
filterCriteria
check
<<-
input
$
filterCheck
physeq
(
subset_samples
(
physeq
(),
eval
(
parse
(
text
=
criteria
))
%in%
check
))
raw_physeq
(
subset_samples
(
raw_
physeq
(),
eval
(
parse
(
text
=
criteria
))
%in%
check
))
},
silent
=
TRUE
,
outFile
=
showModal
(
dataInput
(
failed
=
TRUE
)))
if
(
inherits
(
physeq
(),
"phyloseq"
))
{
if
(
inherits
(
raw_physeq
(),
"phyloseq"
))
{
message
<-
paste
(
input
$
filterCheck
,
collapse
=
", "
)
message
(
paste
(
"[Easy16S] Select some samples :"
,
message
))
removeModal
()
}
else
{
showModal
(
dataInput
(
failed
=
TRUE
))
...
...
@@ -275,9 +278,8 @@ transformSample <- function() {
radioButtons
(
inputId
=
"transformFun"
,
label
=
"Transform function : "
,
selected
=
"none"
,
choices
=
c
(
"None"
=
"none"
,
"Proportional Transformation"
=
"prop"
,
selected
=
NULL
,
choices
=
c
(
"Proportional Transformation"
=
"prop"
,
"Square Root Transformation"
=
"sqrt"
,
"Square Root Proportional Transformation"
=
"sqrtprop"
,
"Centered Log-Ratio (CLR) Transformation"
=
"clr"
)
...
...
@@ -286,7 +288,6 @@ transformSample <- function() {
wellPanel
(
verbatimTextOutput
(
"transformFun"
)),
footer
=
tagList
(
modalButton
(
"Cancel"
),
actionButton
(
inputId
=
"okData"
,
label
=
"Refresh transformation"
),
actionButton
(
inputId
=
"transformData"
,
label
=
"Transforme"
)
)
)
...
...
@@ -295,7 +296,6 @@ transformSample <- function() {
output
$
transformFun
<-
renderText
({
validate
(
need
(
input
$
transformFun
,
""
))
switch
(
input
$
transformFun
,
"none"
=
""
,
"prop"
=
paste
(
"count_to_prop <- function(x) {return( x / sum(x) )}"
,
"data_prop <- transform_sample_counts(data, count_to_prop)"
,
sep
=
"\n"
),
...
...
@@ -321,19 +321,19 @@ observeEvent(input$transformData, {
{
removeModal
()
}
else
{
shinyWidgets
::
updateSwitchInput
(
session
=
session
,
inputId
=
"useTransf"
,
value
=
FALSE
)
try
(
switch
(
input
$
transformFun
,
"none"
=
{
return
(
physeq
())},
"prop"
=
{
count_to_prop
<-
function
(
x
)
{
return
(
x
/
sum
(
x
)
)}
physeq
(
transform_sample_counts
(
physeq
(),
count_to_prop
))
transform_physeq
(
transform_sample_counts
(
raw_
physeq
(),
count_to_prop
))
},
"sqrt"
=
{
physeq
(
transform_sample_counts
(
physeq
(),
sqrt
))
transform_physeq
(
transform_sample_counts
(
raw_
physeq
(),
sqrt
))
},
"sqrtprop"
=
{
count_to_sqrtprop
<-
function
(
x
)
{
return
(
sqrt
(
x
/
sum
(
x
)))}
physeq
(
transform_sample_counts
(
physeq
(),
count_to_sqrtprop
))
transform_physeq
(
transform_sample_counts
(
raw_
physeq
(),
count_to_sqrtprop
))
},
"clr"
=
{
gm_mean
<-
function
(
x
,
na.rm
=
TRUE
)
{
...
...
@@ -344,20 +344,30 @@ observeEvent(input$transformData, {
x
<-
log
(
x
/
gm_mean
(
x
),
base
)
return
(
x
)
}
physeq
(
transform_sample_counts
(
physeq
(),
clr
))
transform_physeq
(
transform_sample_counts
(
raw_
physeq
(),
clr
))
}
),
silent
=
TRUE
,
outFile
=
showModal
(
dataInput
(
failed
=
TRUE
)))
if
(
class
(
physeq
())
==
"phyloseq"
)
{
if
(
class
(
transform_physeq
())
==
"phyloseq"
)
{
message
(
paste
(
"[Easy16S] Transfom data :"
,
input
$
transformFun
))
shinyWidgets
::
updateSwitchInput
(
session
=
session
,
inputId
=
"useTransf"
,
value
=
TRUE
)
removeModal
()
}
else
{
showModal
(
dataInput
(
failed
=
TRUE
))
}
}
}
})
observeEvent
(
input
$
useTransf
,
if
(
input
$
useTransf
)
{
physeq
(
transform_physeq
())
}
else
{
physeq
(
raw_physeq
())
}
)
### Download Data ###
dataDownload
<-
function
()
{
modalDialog
(
...
...
server.R
View file @
b899b6ec
...
...
@@ -27,7 +27,9 @@ shinyServer
source
(
"panels/tree-server.R"
,
local
=
TRUE
)
physeq
<-
reactiveVal
()
raw_physeq
<-
reactiveVal
()
transform_physeq
<-
reactiveVal
()
showModal
(
dataInput
())
observeEvent
(
input
$
dataButton
,
{
...
...
ui.R
View file @
b899b6ec
...
...
@@ -28,6 +28,13 @@ dashboardHeader(title = "Easy16S"),
"Transform abundance"
,
icon
=
icon
(
"square-root-alt"
),
style
=
"width: 80% ; color: black ; background-color: gray90"
),
shinyWidgets
::
switchInput
(
"useTransf"
,
value
=
FALSE
,
label
=
"Transformed Data"
,
#inline = TRUE,
size
=
"mini"
,
labelWidth
=
"100%"
),
actionButton
(
"downloadButton"
,
"Download data"
,
icon
=
icon
(
"download"
),
...
...
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