Skip to content

Commit ac7296f

Browse files
authored
Merge pull request #31 from liuzan-info/p2a
add extension
2 parents 52a4e7f + 6743313 commit ac7296f

File tree

3 files changed

+183
-1
lines changed

3 files changed

+183
-1
lines changed

README.md

+95
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- [1. Docker-based installation](#1-docker-based-installation)
3131
- [2. R-based installation](#2-r-based-installation)
3232
- [How to use](#how-to-use)
33+
- [How to extend](#how-to-extend)
3334
- [Detail of R package "PhosMap"](#detail-of-r-package-phosmap)
3435
- [Friendly suggestion](#friendly-suggestion)
3536
- [Reporting issues](#reporting-issues)
@@ -123,6 +124,100 @@ You can find comprehensive documentation and an in-depth video tutorial on this
123124

124125
<p id="rpackage"></p>
125126

127+
## How to extend
128+
Due to its clear design and reliance solely on the _R_ language, PhosMap allows for easy customization of user-defined features. Basic knowledge of _R_ is sufficient, without the need to understand the shiny framework. We provide a step-by-step tutorial available here.
129+
130+
1. Follow the instructions in `How to install --> R-based installation` for installation. Additionally, install the packages required for your customized functionalities.
131+
2. Open the `ui.R` file inside the PhosMap folder and search for the term '**Customization**.' You will then see a template with detailed annotations. You only need to **selectively** modify **the lines with annotations** according to the instructions. These codes determine the display of the graphical interface.
132+
```R
133+
# If you want to expand the software's functionality,
134+
# please uncomment the code below.
135+
# Tip: You can use the Ctrl+Shift+C shortcut to uncomment or comment the selectedcode.
136+
tabPanel(
137+
"Customization",
138+
h2("User-defined Tool", class = "tooltitle"),
139+
h4("This module is designed for implementing user-defined functionalities.
140+
If you have any questions, please submit an issue on Github.", class = "toolsubtitle"),
141+
fluidRow(
142+
column(
143+
4,
144+
panel(
145+
"",
146+
heading = "Parameters Setting",
147+
numericInput(
148+
inputId = "user_num1", # id to be used in server.R, must be unique, is not recommended to change.
149+
label = "user_num1", # label to show that can be changed.
150+
value = 1, # default number that can be changed.
151+
),
152+
numericInput(
153+
inputId = "user_num2", # id to be used in server.R, must be unique, is not recommended to change.
154+
label = "user_num2", # label to show that can be changed.
155+
value = 1, # default number that can be changed.
156+
),
157+
actionButton(
158+
inputId = "user_button", # id to be used in server.R, must be unique, is not recommended to change.
159+
label = "Run", # label to show that can be changed.
160+
)
161+
)
162+
),
163+
column(
164+
8,
165+
h4("Result--Table:"), # instruction, not recommended to change.
166+
dataTableOutput(
167+
outputId = "user_table", # id to be used in server.R, must be unique, is not recommended to change.
168+
),
169+
h4("Result--Plot:"), # instruction, not recommended to change.
170+
plotOutput(
171+
outputId = "user_plot", # id to be used in server.R, must be unique, is not recommended to change.
172+
)
173+
)
174+
)
175+
)
176+
```
177+
3. Open the `server.R` file inside the PhosMap folder and search for the term '**Customization**.' You will then see a template with detailed annotations. We demonstrate the **data retrieval** and utilization, along with the computational core code that you can modify as desired, and how to ultimately **display data frames and images** in the UI interface. These codes determine how the calculations are performed.
178+
```R
179+
# If you want to expand the software's functionality,
180+
# please uncomment the code below.
181+
# Tip: You can use the Ctrl+Shift+C shortcut to uncomment or comment the selected code.
182+
observeEvent(
183+
input$user_button, {
184+
# you can directly work with the data on the data upload interface, whether it is "pipeline data" or "your data".
185+
# a total of four datasets are as follows:
186+
# (To facilitate user understanding of the data, we have defined the functionality to display different data based on the input in the 'define operation logic' section)
187+
## fileset()[[1]]: experimental design dataframe
188+
## fileset()[[2]]: expression dataframe, the partial of PhosMap matrix
189+
## fileset()[[3]]: dataframe including peptide sequences, the partial of PhosMap matrix
190+
## fileset()[[4]]: clinical dataframe
191+
192+
# define operation logic
193+
## load dependency
194+
library(ggplot2)
195+
## retrieve input data
196+
user_num1 = input$user_num1 # retrieve the value of the corresponding input box with id using input$id
197+
user_num2 = input$user_num2
198+
## write core code to perform any operation that can be tested in advance in a normal R environment
199+
inter_value = user_num2 + 1 - 1
200+
plot_data <- data.frame(
201+
x = c(1, 2, 3, 4, 5),
202+
y = c(2, 4, 6, 8, 10)
203+
)
204+
205+
if(user_num1 == 1){
206+
# output a table to UI
207+
output$user_table <- renderDataTable(fileset()[[1]]) # show data
208+
} else{
209+
output$user_table <- renderDataTable(fileset()[[inter_value]]) # show data
210+
211+
p <- ggplot(plot_data, aes(x, y)) +
212+
geom_point()
213+
# output a plot to UI
214+
output$user_plot <- renderPlot(p) # show plot
215+
}
216+
}
217+
)
218+
```
219+
It's straightforward, give it a try. Feel free to submit any questions as issues or contribute interesting features through pull requests. :)
220+
126221
## Detail of R package "PhosMap"
127222
https://github.com/ecnuzdd/PhosMap
128223

server.R

+44
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,50 @@ server<-shinyServer(function(input, output, session){
105105
}
106106
)
107107

108+
#######################################
109+
####### Customization #######
110+
#######################################
111+
# If you want to expand the software's functionality,
112+
# please uncomment the code below.
113+
# Tip: You can use the Ctrl+Shift+C shortcut to uncomment or comment the selected code.
114+
# observeEvent(
115+
# input$user_button, {
116+
# # you can directly work with the data on the data upload interface, whether it is "pipeline data" or "your data".
117+
# # a total of four datasets are as follows:
118+
# # (To facilitate user understanding of the data, we have defined the functionality to display different data based on the input in the 'define operation logic' section)
119+
# ## fileset()[[1]]: experimental design dataframe
120+
# ## fileset()[[2]]: expression dataframe, the partial of PhosMap matrix
121+
# ## fileset()[[3]]: dataframe including peptide sequences, the partial of PhosMap matrix
122+
# ## fileset()[[4]]: clinical dataframe
123+
#
124+
# # define operation logic
125+
# ## load dependency
126+
# library(ggplot2)
127+
# ## retrieve input data
128+
# user_num1 = input$user_num1 # retrieve the value of the corresponding input box with id using input$id
129+
# user_num2 = input$user_num2
130+
# ## write core code to perform any operation that can be tested in advance in a normal R environment
131+
# inter_value = user_num2 + 1 - 1
132+
# plot_data <- data.frame(
133+
# x = c(1, 2, 3, 4, 5),
134+
# y = c(2, 4, 6, 8, 10)
135+
# )
136+
#
137+
# if(user_num1 == 1){
138+
# # output a table to UI
139+
# output$user_table <- renderDataTable(fileset()[[1]]) # show data
140+
# } else{
141+
# output$user_table <- renderDataTable(fileset()[[inter_value]]) # show data
142+
#
143+
# p <- ggplot(plot_data, aes(x, y)) +
144+
# geom_point()
145+
# # output a plot to UI
146+
# output$user_plot <- renderPlot(p) # show plot
147+
# }
148+
# }
149+
# )
150+
151+
108152
#######################################
109153
####### import data ex #######
110154
#######################################

ui.R

+44-1
Original file line numberDiff line numberDiff line change
@@ -2967,7 +2967,50 @@ ui <- renderUI(
29672967
))
29682968
)
29692969
)
2970-
)
2970+
),
2971+
# If you want to expand the software's functionality,
2972+
# please uncomment the code below.
2973+
# Tip: You can use the Ctrl+Shift+C shortcut to uncomment or comment the selected code.
2974+
# tabPanel(
2975+
# "Customization",
2976+
# h2("User-defined Tool", class = "tooltitle"),
2977+
# h4("This module is designed for implementing user-defined functionalities.
2978+
# If you have any questions, please submit an issue on Github.", class = "toolsubtitle"),
2979+
# fluidRow(
2980+
# column(
2981+
# 4,
2982+
# panel(
2983+
# "",
2984+
# heading = "Parameters Setting",
2985+
# numericInput(
2986+
# inputId = "user_num1", # id to be used in server.R, must be unique, is not recommended to change.
2987+
# label = "user_num1", # label to show that can be changed.
2988+
# value = 1, # default number that can be changed.
2989+
# ),
2990+
# numericInput(
2991+
# inputId = "user_num2", # id to be used in server.R, must be unique, is not recommended to change.
2992+
# label = "user_num2", # label to show that can be changed.
2993+
# value = 1, # default number that can be changed.
2994+
# ),
2995+
# actionButton(
2996+
# inputId = "user_button", # id to be used in server.R, must be unique, is not recommended to change.
2997+
# label = "Run", # label to show that can be changed.
2998+
# )
2999+
# )
3000+
# ),
3001+
# column(
3002+
# 8,
3003+
# h4("Result--Table:"), # instruction, not recommended to change.
3004+
# dataTableOutput(
3005+
# outputId = "user_table", # id to be used in server.R, must be unique, is not recommended to change.
3006+
# ),
3007+
# h4("Result--Plot:"), # instruction, not recommended to change.
3008+
# plotOutput(
3009+
# outputId = "user_plot", # id to be used in server.R, must be unique, is not recommended to change.
3010+
# )
3011+
# )
3012+
# )
3013+
# )
29713014
),
29723015
tabPanel(
29733016
"Tutorial",

0 commit comments

Comments
 (0)