├── .DS_Store
├── .gitattributes
├── Dockerfile
├── LFQ_report.Rmd
├── LICENSE
├── R
├── demo_functions.R
├── enrichment_functions.R
├── functions.R
├── tests.R
└── volcano_function.R
├── README.md
├── data
├── .DS_Store
├── create_example_data.R
├── demo_data.RData
├── example_data.RData
├── exp_design_p10_0144.txt
├── lfq_results.RData
└── proteinGroups.txt
├── dependencies.txt
├── docs
├── CV_plot.png
├── PCA_plot.png
├── Protein_number.png
├── Protein_overlap.png
├── _config.yml
├── correlation_plot.png
├── heatmap.png
├── imputation.png
├── index.md
├── missing_heatmap.png
├── missing_quant.png
├── pvalue_hist.png
└── volcano_plot.png
├── global.R
├── google_analytics-GA4.html
├── google_analytics.js
├── server.R
├── shiny-server.conf
├── ui.R
└── www
├── CV_plot.png
├── Info.Rmd
├── Info.html
├── Info.md
├── Info_cache
├── html
│ ├── __packages
│ ├── exp_design_b71c6ebe27cac9dec05c8ffe7432463e.RData
│ ├── exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdb
│ └── exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdx
└── markdown_strict
│ ├── __packages
│ ├── exp_design_ba255ed02e26d1f4a5a14728288efd24.RData
│ ├── exp_design_ba255ed02e26d1f4a5a14728288efd24.rdb
│ └── exp_design_ba255ed02e26d1f4a5a14728288efd24.rdx
├── LFQ-Analyst_manual.pdf
├── LFQ-Analyst_report.pdf
├── LFQ_analyst.png
├── LFQ_analyst.svg
├── PCA_plot.png
├── Protein_number.png
├── Protein_overlap.png
├── correlation_plot.png
├── css
└── custom.css
├── data
├── experimental_design_example.txt
├── experimental_design_example_feb19.txt
├── proteinGroups_example.txt
└── proteinGroups_example_feb19.txt
├── google-analytics.js
├── google_analytics.js
├── heatmap.png
├── imputation.png
├── js
└── google_analytics.js
├── mbpf_logo.jpg
├── mbpf_logo.png
├── missing_heatmap.png
├── missing_quant.png
├── monash_logo.png
├── pvalue_hist.png
└── volcano_plot.png
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/.DS_Store
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Source files
2 | # ============
3 | *.Rdata text
4 | *.rdb binary
5 | *.rds binary
6 | *.Rd text
7 | *.Rdx binary
8 | *.Rmd text
9 | *.R text
--------------------------------------------------------------------------------
/Dockerfile:
--------------------------------------------------------------------------------
1 | # syntax=docker/dockerfile:1
2 | FROM rocker/shiny-verse:4.2.1
3 |
4 | RUN apt-get update && apt-get install -yq \
5 | libhdf5-dev libnetcdf-dev build-essential libgd-dev libbz2-dev libudunits2-dev libproj-dev libgdal-dev \
6 | texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra
7 |
8 | RUN Rscript -e 'install.packages(c("devtools", "tidyverse", "ggrepel", "httr", "rjson", "mvtnorm", "tmvtnorm", \
9 | "imputeLCMD", "plotly", "DT", "BiocManager","testthat", "RColorBrewer", "shiny","shinyalert","shinydashboard", \
10 | "shinyjs", "svglite", "rhandsontable", "shinyBS", "shinyWidgets", "ggVennDiagram", "shinycssloaders","shiny.info"), dependencies=TRUE)'
11 |
12 | #FROM bioconductor/bioconductor_docker:RELEASE_3_15
13 | RUN Rscript -e 'BiocManager::install(pkgs=c("DEP", "SummarizedExperiment", "limma", "ComplexHeatmap","pcaMethods","impute"), ask=F, dependencies=TRUE)'
14 |
15 | COPY ./ /srv/shiny-server/lfq-analyst
16 | COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
17 | #RUN rm -f /srv/shiny-server/lfq-analyst/.Rprofile
18 | RUN chmod -R +r /srv/shiny-server/lfq-analyst
--------------------------------------------------------------------------------
/LFQ_report.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "LFQ-Analyst report"
3 | date: "`r format(Sys.time(), '%d %B, %Y')`"
4 | params:
5 | data: NA
6 | alpha: NA
7 | lfc: NA
8 | num_signif: NA
9 | tested_contrasts: NA
10 | numbers_input: NA
11 | coverage_input: NA
12 | pca_input: NA
13 | correlation_input: NA
14 | missval_input: NA
15 | detect_input: NA
16 | imputation_input: NA
17 | p_hist_input: NA
18 | heatmap_input: NA
19 | dep: NA
20 | pg_width: NA
21 | cvs_input: NA
22 | output:
23 | pdf_document:
24 | fig_caption: yes
25 | ---
26 | ```{r setup, include=FALSE}
27 | knitr::opts_chunk$set(opts.label="kill_prefix") # Remove line number and Comment "##" from printing
28 | ```
29 |
30 | ## Method details
31 |
32 | The raw data files were analyzed using MaxQuant to obtain protein identifications and their respective label-free quantification values using in-house standard parameters. Of note, the data were normalization based on the assumption that the majority of proteins do not change between the different conditions.
33 | Statistical analysis was performed using an in-house generated R script based on the ProteinGroup.txt file. First, contaminant proteins, reverse sequences and proteins identified “only by site” were filtered out. In addition, proteins that have been only identified by a single peptide and proteins not identified/quantified consistantly in same condition have been removed as well. The LFQ data was converted to log2 scale, samples were grouped by conditions and missing values were imputed using the ‘Missing not At Random’ (MNAR) method, which uses random draws from a left-shifted Gaussian distribution of 1.8 StDev (standard deviation) apart with a width of 0.3. Protein-wise linear models combined with empirical Bayes statistics were used for the differential expression analyses. The _limma_ package from R Bioconductor was used to generate a list of differentially expressed proteins for each pair-wise comparison. A cutoff of the _adjusted p-value_ of 0.05 (Benjamini-Hochberg method) along with a |log2 fold change| of 1 has been applied to determine significantly regulated proteins in each pairwise comparison.
34 |
35 |
36 | ### Quick summary of parameters used:
37 |
38 | * Tested pairwise comparisons = `r params$tested_contrasts`
39 | * Adjusted _p-value_ cutoff <= `r params$alpha`
40 | * Log fold change cutoff >= `r params$lfc`
41 |
42 | ## Results
43 |
44 | #### MaxQuant result output contains `r nrow(params$data)` proteins groups of which _`r nrow(params$dep())`_ proteins were reproducibly quantified.
45 |
46 | #### `r params$num_signif` proteins differ significantly between samples.
47 |
48 | \pagebreak
49 |
50 |
51 | ## Exploratory Analysis (QC Plots)
52 |
53 | #### Principle Component Analysis (PCA) plot
54 |
55 |
56 | ```{r pca_plot, echo=FALSE, fig.height= 4, fig.align='center', warning=FALSE}
57 | print(params$pca_input())
58 | ```
59 | \pagebreak
60 |
61 | #### Sample Correlation matrix
62 |
63 | ```{r correlation_heatmap, echo=FALSE, fig.keep='first',fig.align='center'}
64 | print(params$correlation_input())
65 | ```
66 | \pagebreak
67 |
68 | #### Sample Coefficient of variation (CVs)
69 |
70 | ```{r sample_cv, echo=FALSE, warning=FALSE, message=FALSE, fig.align='center'}
71 | print(params$cvs_input())
72 | ```
73 | \pagebreak
74 |
75 | ### Proteomics Experiment Summary
76 |
77 | Protein quantified per sample (after pre-processing).
78 |
79 | ```{r numbers, echo=FALSE, warning=FALSE, results='hide', message=FALSE }
80 | print(params$numbers_input())
81 | ```
82 | \pagebreak
83 |
84 | Protein overlap in all samples.
85 |
86 |
87 | ```{r coverage, echo=FALSE, warning=FALSE}
88 | print(params$coverage_input())
89 | ```
90 | \pagebreak
91 |
92 |
93 |
94 | ## Missing Value handling
95 |
96 | #### Missing value heatmap
97 | A heatmap for proteins with missing value in each dataset. Each row represent a protein with missing value in one or more replicate. Each replicate is clustered based on presence of missing values in the sample.
98 |
99 |
100 | ```{r missing_value_heatmap, echo=FALSE, message=FALSE, results='hide',warning=FALSE, tidy=TRUE}
101 | params$missval_input()
102 | ```
103 | \pagebreak
104 |
105 | #### Missing value distribution
106 | Protein expression distribution before and after imputation. The plot showing the effect of imputation on protein expression distribution.
107 |
108 | ```{r imputation_effect, echo=FALSE, message=FALSE, warning=FALSE, results='hide'}
109 | print(params$imputation_input())
110 | ```
111 | \pagebreak
112 |
113 | ## Differential Expression Analysis (Results Plots)
114 |
115 | #### Heatmap
116 | A plot representing an overview of expression of all significant (differencially expressed) proteins (rows) in all samples (columns).
117 |
118 |
119 | ```{r heatmap_2, echo=FALSE, warning=FALSE, results='hide', fig.keep='first',fig.align='center'}
120 | print(params$heatmap_input())
121 | ```
122 |
123 | \pagebreak
124 |
125 | #### Volcano Plots
126 |
127 | ```{r volcano, echo=FALSE, warning=FALSE, comment=NA,fig.align='center'}
128 | for(i in params$tested_contrasts){
129 | # print(paste0('volcano_plot_',i,sep=""))
130 | print(plot_volcano_new(params$dep(),contrast = i,label_size = 2, add_names = F))
131 | }
132 | ```
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/R/demo_functions.R:
--------------------------------------------------------------------------------
1 | ### functions to deal with demo data
2 |
3 | LoadToEnvironment <- function(RData, env=new.env()) {
4 | load(RData, env)
5 | return(env)
6 | }
7 |
8 | #env<-LoadToEnvironment("data/example_data.RData")
9 |
10 | #https://stackoverflow.com/questions/31794702/r-shiny-dashboard-tabitems-not-apparing
11 | convertMenuItem <- function(mi,tabName) {
12 | mi$children[[1]]$attribs['data-toggle']="tab"
13 | mi$children[[1]]$attribs['data-value'] = tabName
14 | mi
15 | }
16 |
17 | progress_indicator<-function(text_message){
18 | withProgress(message = text_message,
19 | detail = 'Please wait for a while', value = 0, {
20 | for (i in 1:15) {
21 | incProgress(1/15)
22 | Sys.sleep(0.25)
23 | }
24 | })
25 | }
26 | #env<-LoadToEnvironment("data/example_data.RData")
27 |
--------------------------------------------------------------------------------
/R/enrichment_functions.R:
--------------------------------------------------------------------------------
1 | enrichr_mod <- function(genes, databases = NULL) {
2 | httr::set_config(httr::config(ssl_verifypeer = 0L))
3 | cat("Uploading data to Enrichr... ")
4 | if (is.vector(genes) & ! all(genes == "") & length(genes) != 0) {
5 | temp <- POST(url="http://maayanlab.cloud/Enrichr/enrich",
6 | body=list(list=paste(genes, collapse="\n")))
7 | } else if (is.data.frame(genes)) {
8 | temp <- POST(url="http://maayanlab.cloud/Enrichr/enrich",
9 | body=list(list=paste(paste(genes[,1], genes[,2], sep=","),
10 | collapse="\n")))
11 | } else {
12 | warning("genes must be a non-empty vector of gene names or a dataframe with genes and score.")
13 | }
14 | GET(url="http://maayanlab.cloud/Enrichr/share")
15 | cat("Done.\n")
16 | dbs <- as.list(databases)
17 | dfSAF <- options()$stringsAsFactors
18 | options(stringsAsFactors = FALSE)
19 | result <- lapply(dbs, function(x) {
20 | cat(" Querying ", x, "... ", sep="")
21 | r <- GET(url="http://maayanlab.cloud/Enrichr/export",
22 | query=list(file="API", backgroundType=x))
23 | r <- gsub("'", "'", intToUtf8(r$content))
24 | tc <- textConnection(r)
25 | r <- read.table(tc, sep = "\t", header = TRUE, quote = "", comment.char="")
26 | close(tc)
27 | cat("Done.\n")
28 | return(r)
29 | })
30 | options(stringsAsFactors = dfSAF)
31 | cat("Parsing results... ")
32 | names(result) <- dbs
33 | cat("Done.\n")
34 | return(result)
35 | }
36 |
37 |
38 | ###### ========= Test_gsea new
39 |
40 |
41 | test_gsea_mod <- function(dep,
42 | databases,
43 | contrasts = TRUE) {
44 | # Show error if inputs are not the required classes
45 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
46 | is.character(databases),
47 | is.logical(contrasts),
48 | length(contrasts) == 1)
49 |
50 |
51 | row_data <- rowData(dep, use.names = FALSE)
52 | # Show error if inputs do not contain required columns
53 | if(any(!c("name", "ID") %in% colnames(row_data))) {
54 | stop("'name' and/or 'ID' columns are not present in '",
55 | deparse(substitute(dep)),
56 | "'\nRun make_unique() and make_se() to obtain the required columns",
57 | call. = FALSE)
58 | }
59 | if(length(grep("_p.adj|_diff", colnames(row_data))) < 1) {
60 | stop("'[contrast]_diff' and/or '[contrast]_p.adj' columns are not present in '",
61 | deparse(substitute(dep)),
62 | "'\nRun test_diff() to obtain the required columns",
63 | call. = FALSE)
64 | }
65 |
66 |
67 |
68 | # Run background list
69 | message("Background")
70 | background <- gsub("[.].*", "", row_data$name)
71 | background_enriched <- enrichr_mod(background, databases)
72 | df_background <- NULL
73 | for(database in databases) {
74 | temp <- background_enriched[database][[1]] %>%
75 | mutate(var = database)
76 | df_background <- rbind(df_background, temp)
77 | }
78 | df_background$contrast <- "background"
79 | df_background$n <- length(background)
80 |
81 | OUT <- df_background %>%
82 | mutate(bg_IN = as.numeric(gsub("/.*", "", Overlap)),
83 | bg_OUT = n - bg_IN) %>%
84 | select(Term, bg_IN, bg_OUT)
85 |
86 | if(contrasts) {
87 | # Get gene symbols
88 | df <- row_data %>%
89 | as.data.frame() %>%
90 | select(name, ends_with("_significant")) %>%
91 | mutate(name = gsub("[.].*", "", name))
92 |
93 | # Run enrichR for every contrast
94 | df_enrich <- NULL
95 | for(contrast in colnames(df[2:ncol(df)])) {
96 | message(gsub("_significant", "", contrast))
97 | significant <- df[df[[contrast]],]
98 | genes <- significant$name
99 | enriched <- enrichr_mod(genes, databases)
100 |
101 | # Tidy output
102 | contrast_enrich <- NULL
103 | for(database in databases) {
104 | temp <- enriched[database][[1]] %>%
105 | mutate(var = database)
106 | contrast_enrich <- rbind(contrast_enrich, temp)
107 | }
108 |
109 | if (nrow(contrast_enrich) != 0){
110 | contrast_enrich$contrast <- contrast
111 | contrast_enrich$n <- length(genes)
112 |
113 | # Background correction
114 | cat("Background correction... ")
115 | contrast_enrich <- contrast_enrich %>%
116 | mutate(IN = as.numeric(gsub("/.*", "", Overlap)),
117 | OUT = n - IN) %>%
118 | select(-n) %>%
119 | left_join(OUT, by = "Term") %>%
120 | mutate(log_odds = log2((IN * bg_OUT) / (OUT * bg_IN)))
121 | cat("Done.")
122 |
123 | df_enrich <- rbind(df_enrich, contrast_enrich) %>%
124 | mutate(contrast = gsub("_significant", "", contrast))
125 | } else {
126 | cat("No enough significant genes for enrichment analysis")
127 | }
128 | }
129 | } else {
130 | # Get gene symbols
131 | significant <- row_data %>%
132 | as.data.frame() %>%
133 | select(name, significant) %>%
134 | filter(significant) %>%
135 | mutate(name = gsub("[.].*", "", name))
136 |
137 | # Run enrichR
138 | genes <- significant$name
139 | enriched <- enrichr_mod(genes, databases)
140 |
141 | # Tidy output
142 | df_enrich <- NULL
143 | for(database in databases) {
144 | temp <- enriched[database][[1]] %>%
145 | mutate(var = database)
146 | df_enrich <- rbind(df_enrich, temp)
147 | }
148 | df_enrich$contrast <- "significant"
149 | df_enrich$n <- length(genes)
150 |
151 | # Background correction
152 | cat("Background correction... ")
153 | df_enrich <- df_enrich %>%
154 | mutate(IN = as.numeric(gsub("/.*", "", Overlap)),
155 | OUT = n - IN) %>%
156 | select(-n) %>%
157 | left_join(OUT, by = "Term") %>%
158 | mutate(log_odds = log2((IN * bg_OUT) / (OUT * bg_IN)))
159 | cat("Done.")
160 | }
161 |
162 | return(df_enrich)
163 | }
164 |
165 |
166 | #gene_names_true<-read_table("R/gene_names.txt",col_names = F)
167 |
--------------------------------------------------------------------------------
/R/functions.R:
--------------------------------------------------------------------------------
1 |
2 | matrixplot_modify<-function(data, mapping, pts=list(), smt=list(), ...){
3 | ggplot(data = data, mapping = mapping, ...) +
4 | do.call(geom_point, pts) +
5 | do.call(geom_smooth, smt)
6 | }
7 |
8 |
9 | LFQ_wrapper<-function(maxquant_data,expdesign){
10 |
11 | ### Import input MaxQuant proteinGroups.txt file
12 | maxquant_output<- maxquant_data
13 |
14 | ## Optional experimental structure file
15 | exp_design <- expdesign
16 |
17 | ######========= DATA PREPROCESSING =========#######
18 | # Filter proteins by removing
19 | # 1. Reverse sequences
20 | # 2. Potential contaminants
21 | # 3. Proteins only identified by sites
22 | # 4. Proteins identified by single peptide
23 | data <- maxquant_output %>%
24 | dplyr:::filter(Reverse!="+", Only.identified.by.site!="+", Razor...unique.peptides>=2)
25 |
26 | ## Make data unique by combining gene names and protein ids in rows where either of them is absent
27 | data_unique<- DEP:::make_unique(data,"Gene.names","Protein.IDs",delim=";")
28 |
29 | #####======= Gnerating Summerised Experiment Object for differential expression analysis =======######
30 |
31 | ## get the location of LFQ intensity columns
32 | lfq_columns<-grep("LFQ.", colnames(data_unique))
33 |
34 | ## Convert the protein dataframe into Summerised experiment object for further analysis
35 | data_se<-DEP:::make_se(data_unique,lfq_columns,exp_design)
36 |
37 |
38 | ## Remove the rows with lot of missing values
39 | ## This is important step and depends of "thr" option
40 | ## If thr=0, it means all the replicates in each sample should have valid values, no missing values is allowed
41 | ## thr=1 means atleast 2 out 3 replicates should have valid values in each sample
42 | data_filter<-DEP:::filter_missval(data_se, thr = 1)
43 |
44 | # meanSdPlot(data_filter) This can be optional
45 |
46 | ######============== Normalisation ===========########
47 | ## This function uses variance stabilizing transofmation (vsn) function for background correction
48 | ## Not much useful for proteomics datasets
49 | data_norm<-DEP:::normalize_vsn(data_filter)
50 | #meanSdPlot(data_norm)# Can be optional
51 |
52 | ######================ MISSING VALUE IMPUTATION ===============##########
53 | ## As for this dataset protein intensity plot indicated that proteins with missing value have on average low intensities,
54 | ## I choose missing value imputation to be one of MNAR method
55 | ## Following code will impute missing value with algorithm similar to perseus
56 | ## i.e. random values drawn from normal distribution of 1.8 SD apart with the width of 0.3
57 | data_imp_man<-DEP:::impute(data_filter,fun="man",shift=1.8,scale=0.3)
58 |
59 |
60 | ######============= DIFFERENTIAL EXPRESSION ANALYSIS ============###########
61 |
62 | ## This test uses protein-wise linear model with emperical Bayes statistics (used in R package limma)
63 | ## Limma is modified version of t-test and widely used for transcriptomics analysis
64 | ## Number of different options available such as "all", "control" and "man" to compare various conditions
65 | ## "all"- compares all pairwise comparisons
66 | ## "control"- asks to specify the control sample and compares every other sample against control
67 | ## "man"- manually specify which condition to test
68 |
69 | #data_diff_all_contrasts<-test_diff(data_imp_man,type='all')
70 | # If the data has multiple pairwise comparisions we need to generate volcano plot for each comparison
71 | # "comparison" is a character vectors that stores the name of all comparison and captured from
72 | # the message generated by "test_diff" function
73 | # Example of message "Tested_contrasts: "Control_vs_Condition1", "Control_vs_Condition2""
74 | comparisons<-capture.output(data_diff_all_contrasts<-test_diff(data_imp_man,type='all'),type = "message")
75 |
76 | ## Remove "Tested contrasts:"
77 | comparisons<-gsub(".*: ","",comparisons)
78 | ## Split conditions into character vector
79 | comparisons<-unlist(strsplit(comparisons,","))
80 | ## Remove leading and trailing spaces
81 | comparisons<-trimws(comparisons)
82 |
83 | ## Mark significantly different proteins
84 | ## Input needed to define the threshold
85 | ## "alpha"- adjusted p-value cutoff
86 | ## "lfc"- log2(Fold Change) cutoff
87 | alpha<- 0.05
88 | lfc<- 1
89 | param<- data.frame(alpha, lfc)
90 | dep<-DEP:::add_rejections(data_diff_all_contrasts,alpha = 0.05,lfc = log2(1))
91 |
92 |
93 | ## Plot multiple scatterplots
94 | ## First get the LFQ expression data
95 | ## Use ggpairs function from GGally library to generate multiple matrix plots
96 | paired_data<-as.data.frame(assay(dep))
97 |
98 |
99 |
100 |
101 | ######=============== ENRICHMENT ANALYSIS ============== ##########
102 | ## Protein Set Enrichment Analysis is based on EnrichR
103 | ## Need to specify the databases to perform enrichment test
104 |
105 | ## Gene Ontology Enrichment
106 | # gsea_results_GO <- test_gsea(dep)
107 |
108 |
109 | ## KEGG enrichment
110 | # results_kegg<- test_gsea(dep,databases = c("KEGG_2016"))
111 |
112 |
113 | ####=============== Write Results ===========#######
114 | data_result<-get_results(dep)
115 | # write.csv(data_result,"LFQ_results.csv",row.names = FALSE)
116 |
117 | save.image (file="data/lfq_results.RData")
118 | return(dep)
119 |
120 | }
121 |
122 | # get_pdf_plot<-function(type_of_plot){
123 | # pdf(paste0(type_of_plot,".pdf",sep="")
124 | # plot(type_of_plot)
125 | # dev.off()
126 | # }
127 |
128 | coef_variation<-function(x){
129 | coef=sd(x)/mean(x)
130 | }
131 |
132 | #### Plot CVs
133 |
134 | plot_cvs<-function(se) {
135 |
136 | ## backtransform data
137 | untransformed_intensity<- 2^(assay(se))
138 | exp_design<-colData(se)
139 |
140 | ### merge untransformed to exp design and calculate cvs
141 |
142 | cvs_group<- untransformed_intensity %>% data.frame() %>%
143 | tibble::rownames_to_column() %>%
144 | tidyr::gather("ID", "Intensity", -rowname) %>%
145 | dplyr::left_join(.,data.frame(exp_design), by="ID") %>%
146 | dplyr::group_by(rowname,condition) %>%
147 | dplyr::summarise(cvs=coef_variation(Intensity)) %>%
148 | dplyr::group_by(condition)%>%
149 | dplyr::mutate(condition_median=median(cvs))
150 |
151 | p1 <- ggplot(cvs_group, aes(cvs, color=condition, fill=condition)) +
152 | geom_histogram(alpha=.5, bins= 20, show.legend = FALSE) +
153 | facet_wrap(~condition) +
154 | geom_vline(aes(xintercept=condition_median, group=condition),color='grey40',
155 | linetype="dashed") +
156 | labs(title= 'Sample Coefficient of Variation', x="Coefficient of Variation", y="Count") +
157 | theme_DEP2() +
158 | theme(plot.title = element_text(hjust = 0.5,face = "bold"))
159 |
160 | p1 +geom_text(aes(x=max(cvs_group$cvs)-0.6,
161 | y=max(ggplot_build(p1)$data[[1]]$ymax*1.1),
162 | label=paste0("Median =",round(condition_median,2)*100,"%",by="")),
163 | show.legend = FALSE, size=4)
164 |
165 | }
166 |
167 |
168 | #### Get individual clusters from heatmap
169 | get_cluster_heatmap <- function(dep, type = c("contrast", "centered"),
170 | kmeans = FALSE, k = 6,
171 | col_limit = 6, indicate = NULL,
172 | clustering_distance = c("euclidean", "maximum", "manhattan", "canberra",
173 | "binary", "minkowski", "pearson", "spearman", "kendall", "gower"),
174 | row_font_size = 6, col_font_size = 10, plot = TRUE, ...) {
175 |
176 | # Show error if inputs are not the required classes
177 | if(is.integer(k)) k <- as.numeric(k)
178 | if(is.integer(col_limit)) col_limit <- as.numeric(col_limit)
179 | if(is.integer(row_font_size)) row_font_size <- as.numeric(row_font_size)
180 | if(is.integer(col_font_size)) col_font_size <- as.numeric(col_font_size)
181 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
182 | is.character(type),
183 | is.logical(kmeans),
184 | is.numeric(k),
185 | length(k) == 1,
186 | is.numeric(col_limit),
187 | length(col_limit) == 1,
188 | is.numeric(row_font_size),
189 | length(row_font_size) == 1,
190 | is.numeric(col_font_size),
191 | length(col_font_size) == 1,
192 | is.logical(plot),
193 | length(plot) == 1)
194 |
195 | # Show error if inputs do not contain required columns
196 | type <- match.arg(type)
197 | clustering_distance <- match.arg(clustering_distance)
198 |
199 | # Extract row and col data
200 | row_data <- rowData(dep)
201 | col_data <- colData(dep) %>%
202 | as.data.frame()
203 |
204 | # Show error if inputs do not contain required columns
205 | if(any(!c("label", "condition", "replicate") %in% colnames(col_data))) {
206 | stop(paste0("'label', 'condition' and/or 'replicate' columns are not present in '",
207 | deparse(substitute(dep)), "'"),
208 | call. = FALSE)
209 | }
210 | if(length(grep("_diff", colnames(row_data))) < 1) {
211 | stop(paste0("'[contrast]_diff' columns are not present in '",
212 | deparse(substitute(dep)),
213 | "'.\nRun test_diff() to obtain the required columns."),
214 | call. = FALSE)
215 | }
216 | if(!"significant" %in% colnames(row_data)) {
217 | stop(paste0("'significant' column is not present in '",
218 | deparse(substitute(dep)),
219 | "'.\nRun add_rejections() to obtain the required column."),
220 | call. = FALSE)
221 | }
222 |
223 | # Heatmap annotation
224 | if(!is.null(indicate) & type == "contrast") {
225 | warning("Heatmap annotation only applicable for type = 'centered'",
226 | call. = FALSE)
227 | }
228 | if(!is.null(indicate) & type == "centered") {
229 | ha1 <- get_annotation(dep, indicate)
230 | } else {
231 | ha1 <- NULL
232 | }
233 |
234 | # Filter for significant proteins only
235 | filtered <- dep[row_data$significant, ]
236 |
237 | # Check for missing values
238 | if(any(is.na(assay(filtered)))) {
239 | warning("Missing values in '", deparse(substitute(dep)), "'. ",
240 | "Using clustering_distance = 'gower'",
241 | call. = FALSE)
242 | clustering_distance <- "gower"
243 | obs_NA <- TRUE
244 | } else {
245 | obs_NA <- FALSE
246 | }
247 |
248 | # Get centered intensity values ('centered')
249 | if(type == "centered") {
250 | rowData(filtered)$mean <- rowMeans(assay(filtered), na.rm = TRUE)
251 | df <- assay(filtered) - rowData(filtered)$mean
252 | }
253 | # Get contrast fold changes ('contrast')
254 | if(type == "contrast") {
255 | df <- rowData(filtered) %>%
256 | data.frame() %>%
257 | column_to_rownames(var = "name") %>%
258 | select(dplyr::ends_with("_diff"))
259 | colnames(df) <-
260 | gsub("_diff", "", colnames(df)) %>%
261 | gsub("_vs_", " vs ", .)
262 | }
263 |
264 | # Facultative kmeans clustering
265 | if(kmeans & obs_NA) {
266 | warning("Cannot perform kmeans clustering with missing values",
267 | call. = FALSE)
268 | kmeans <- FALSE
269 | }
270 | if(kmeans & !obs_NA) {
271 | set.seed(1)
272 | df_kmeans <- kmeans(df, k)
273 | if(type == "centered") {
274 | # Order the k-means clusters according to the maximum fold change
275 | # in all samples averaged over the proteins in the cluster
276 | order <- data.frame(df) %>%
277 | cbind(., cluster = df_kmeans$cluster) %>%
278 | dplyr::mutate(row = apply(.[, seq_len(ncol(.) - 1)], 1, function(x) max(x))) %>%
279 | dplyr::group_by(cluster) %>%
280 | dplyr::summarize(index = sum(row)/n()) %>%
281 | dplyr::arrange(desc(index)) %>%
282 | dplyr::pull(cluster) %>%
283 | match(seq_len(k), .)
284 | df_kmeans$cluster <- order[df_kmeans$cluster]
285 | }
286 | if(type == "contrast") {
287 | # Order the k-means clusters according to their average fold change
288 | order <- cbind(df, cluster = df_kmeans$cluster) %>%
289 | dplyr::gather(condition, diff, -cluster) %>%
290 | dplyr::group_by(cluster) %>%
291 | dplyr::summarize(row = mean(diff)) %>%
292 | dplyr::arrange(desc(row)) %>%
293 | dplyr::pull(cluster) %>%
294 | match(seq_len(k), .)
295 | df_kmeans$cluster <- order[df_kmeans$cluster]
296 | }
297 | }
298 |
299 | if(ncol(df) == 1) {
300 | col_clust = FALSE
301 | } else {
302 | col_clust = TRUE
303 | }
304 | if(nrow(df) == 1) {
305 | row_clust = FALSE
306 | } else {
307 | row_clust = TRUE
308 | }
309 | if(clustering_distance == "gower") {
310 | clustering_distance <- function(x) {
311 | dist <- cluster::daisy(x, metric = "gower")
312 | dist[is.na(dist)] <- max(dist, na.rm = TRUE)
313 | return(dist)
314 | }
315 | }
316 |
317 | # Legend info
318 | legend <- ifelse(type == "contrast",
319 | "log2 Fold change",
320 | "log2 Centered intensity")
321 |
322 | # Heatmap
323 | ht1 = Heatmap(df,
324 | col = circlize::colorRamp2(
325 | seq(-col_limit, col_limit, (col_limit/5)),
326 | rev(RColorBrewer::brewer.pal(11, "RdBu"))),
327 | split = if(kmeans) {df_kmeans$cluster} else {NULL},
328 | cluster_rows = col_clust,
329 | cluster_columns = row_clust,
330 | row_names_side = "left",
331 | column_names_side = "top",
332 | clustering_distance_rows = clustering_distance,
333 | clustering_distance_columns = clustering_distance,
334 | heatmap_legend_param = list(color_bar = "continuous",
335 | legend_direction = "horizontal",
336 | legend_width = unit(5, "cm"),
337 | title_position = "lefttop"),
338 | name = legend,
339 | row_names_gp = gpar(fontsize = row_font_size),
340 | column_names_gp = gpar(fontsize = col_font_size),
341 | top_annotation = ha1,
342 | ...)
343 | # return (row_order(ht1))
344 | # Return data.frame
345 | p <- draw(ht1, heatmap_legend_side = "top")
346 | row_clusters<- row_order(ht1)
347 | #mat<-as.matrix(df)
348 |
349 | # for (i in 1:length(row_clusters)){
350 | # if (i==1){
351 | # clu <-t(t(row.names(ht1[row_clusters[[i]],])))
352 | # out <-cbind (clu, paste("cluster", i, sep=""))
353 | # colnames(out)<- c("ProteinID", "Cluster")
354 | # }
355 | # else{
356 | # clu <- t(t(row.names(ht1[row_clusters[[i]],])))
357 | # clu <- cbind(clu, paste("cluster", i, sep = ""))
358 | # out <- cbind(out, clu)
359 | # }
360 | # }
361 | heatmap_list <- list(p, row_clusters)
362 | return(heatmap_list)
363 | }
364 |
365 | # Internal function to get ComplexHeatmap::HeatmapAnnotation object
366 | get_annotation <- function(dep, indicate) {
367 | assertthat::assert_that(
368 | inherits(dep, "SummarizedExperiment"),
369 | is.character(indicate))
370 |
371 | # Check indicate columns
372 | col_data <- colData(dep) %>%
373 | as.data.frame()
374 | columns <- colnames(col_data)
375 | if(all(!indicate %in% columns)) {
376 | stop("'",
377 | paste0(indicate, collapse = "' and/or '"),
378 | "' column(s) is/are not present in ",
379 | deparse(substitute(dep)),
380 | ".\nValid columns are: '",
381 | paste(columns, collapse = "', '"),
382 | "'.",
383 | call. = FALSE)
384 | }
385 | if(any(!indicate %in% columns)) {
386 | indicate <- indicate[indicate %in% columns]
387 | warning("Only used the following indicate column(s): '",
388 | paste0(indicate, collapse = "', '"),
389 | "'")
390 | }
391 |
392 | # Get annotation
393 | anno <- dplyr::select(col_data, indicate)
394 |
395 | # Annotation color
396 | names <- colnames(anno)
397 | anno_col <- vector(mode="list", length=length(names))
398 | names(anno_col) <- names
399 | for(i in names) {
400 | var = anno[[i]] %>% unique() %>% sort()
401 | if(length(var) == 1)
402 | cols <- c("black")
403 | if(length(var) == 2)
404 | cols <- c("orangered", "cornflowerblue")
405 | if(length(var) < 7 & length(var) > 2)
406 | cols <- RColorBrewer::brewer.pal(length(var), "Pastel1")
407 | if(length(var) > 7)
408 | cols <- RColorBrewer::brewer.pal(length(var), "Set3")
409 | names(cols) <- var
410 | anno_col[[i]] <- cols
411 | }
412 |
413 | # HeatmapAnnotation object
414 | ComplexHeatmap::HeatmapAnnotation(df = anno,
415 | col = anno_col,
416 | show_annotation_name = TRUE)
417 | }
418 |
419 |
420 | #### ===== limma BH FDR ===== #####
421 |
422 | test_limma <- function(se, type = c("control", "all", "manual"),
423 | control = NULL, test = NULL,
424 | design_formula = formula(~ 0 + condition),
425 | paired = FALSE) {
426 | #require("dplyr", "tidyr", "purrr")
427 |
428 | # Show error if inputs are not the required classes
429 | assertthat::assert_that(inherits(se, "SummarizedExperiment"),
430 | is.character(type),
431 | class(design_formula) == "formula")
432 | if (paired == FALSE){
433 | design_formula <- design_formula
434 | }else{
435 | design_formula<-formula(~ 0 + condition + replicate)
436 | }
437 |
438 |
439 | # Show error if inputs do not contain required columns
440 | type <- match.arg(type)
441 |
442 | col_data <- colData(se)
443 | raw <- assay(se)
444 |
445 | if(any(!c("name", "ID") %in% colnames(rowData(se)))) {
446 | stop("'name' and/or 'ID' columns are not present in '",
447 | deparse(substitute(se)),
448 | "'\nRun make_unique() and make_se() to obtain the required columns",
449 | call. = FALSE)
450 | }
451 | if(any(!c("label", "condition", "replicate") %in% colnames(col_data))) {
452 | stop("'label', 'condition' and/or 'replicate' columns are not present in '",
453 | deparse(substitute(se)),
454 | "'\nRun make_se() or make_se_parse() to obtain the required columns",
455 | call. = FALSE)
456 | }
457 | if(any(is.na(raw))) {
458 | warning("Missing values in '", deparse(substitute(se)), "'")
459 | }
460 |
461 | if(!is.null(control)) {
462 | # Show error if control input is not valid
463 | assertthat::assert_that(is.character(control),
464 | length(control) == 1)
465 | if(!control %in% unique(col_data$condition)) {
466 | stop("run test_diff() with a valid control.\nValid controls are: '",
467 | paste0(unique(col_data$condition), collapse = "', '"), "'",
468 | call. = FALSE)
469 | }
470 | }
471 |
472 | # variables in formula
473 | variables <- terms.formula(design_formula) %>%
474 | attr(., "variables") %>%
475 | as.character() %>%
476 | .[-1]
477 |
478 | # Throw error if variables are not col_data columns
479 | if(any(!variables %in% colnames(col_data))) {
480 | stop("run make_diff() with an appropriate 'design_formula'")
481 | }
482 | if(variables[1] != "condition") {
483 | stop("first factor of 'design_formula' should be 'condition'")
484 | }
485 |
486 | # Obtain variable factors
487 | for(var in variables) {
488 | temp <- factor(col_data[[var]])
489 | assign(var, temp)
490 | }
491 |
492 | # Make an appropriate design matrix
493 | design <- model.matrix(design_formula, data = environment())
494 | colnames(design) <- gsub("condition", "", colnames(design))
495 |
496 | # Generate contrasts to be tested
497 | # Either make all possible combinations ("all"),
498 | # only the contrasts versus the control sample ("control") or
499 | # use manual contrasts
500 | conditions <- as.character(unique(condition))
501 | if(type == "all") {
502 | # All possible combinations
503 | cntrst <- apply(utils::combn(conditions, 2), 2, paste, collapse = " - ")
504 |
505 | if(!is.null(control)) {
506 | # Make sure that contrast containing
507 | # the control sample have the control as denominator
508 | flip <- grep(paste("^", control, sep = ""), cntrst)
509 | if(length(flip) >= 1) {
510 | cntrst[flip] <- cntrst[flip] %>%
511 | gsub(paste(control, "- ", sep = " "), "", .) %>%
512 | paste(" - ", control, sep = "")
513 | }
514 | }
515 |
516 | }
517 | if(type == "control") {
518 | # Throw error if no control argument is present
519 | if(is.null(control))
520 | stop("run test_diff(type = 'control') with a 'control' argument")
521 |
522 | # Make contrasts
523 | cntrst <- paste(conditions[!conditions %in% control],
524 | control,
525 | sep = " - ")
526 | }
527 | if(type == "manual") {
528 | # Throw error if no test argument is present
529 | if(is.null(test)) {
530 | stop("run test_diff(type = 'manual') with a 'test' argument")
531 | }
532 | assertthat::assert_that(is.character(test))
533 |
534 | if(any(!unlist(strsplit(test, "_vs_")) %in% conditions)) {
535 | stop("run test_diff() with valid contrasts in 'test'",
536 | ".\nValid contrasts should contain combinations of: '",
537 | paste0(conditions, collapse = "', '"),
538 | "', for example '", paste0(conditions[1], "_vs_", conditions[2]),
539 | "'.", call. = FALSE)
540 | }
541 |
542 | cntrst <- gsub("_vs_", " - ", test)
543 |
544 | }
545 | # Print tested contrasts
546 | message("Tested contrasts: ",
547 | paste(gsub(" - ", "_vs_", cntrst), collapse = ", "))
548 |
549 | # Test for differential expression by empirical Bayes moderation
550 | # of a linear model on the predefined contrasts
551 | fit <- lmFit(raw, design = design)
552 | made_contrasts <- makeContrasts(contrasts = cntrst, levels = design)
553 | contrast_fit <- contrasts.fit(fit, made_contrasts)
554 |
555 | if(any(is.na(raw))) {
556 | for(i in cntrst) {
557 | covariates <- strsplit(i, " - ") %>% unlist
558 | single_contrast <- makeContrasts(contrasts = i, levels = design[, covariates])
559 | single_contrast_fit <- contrasts.fit(fit[, covariates], single_contrast)
560 | contrast_fit$coefficients[, i] <- single_contrast_fit$coefficients[, 1]
561 | contrast_fit$stdev.unscaled[, i] <- single_contrast_fit$stdev.unscaled[, 1]
562 | }
563 | }
564 |
565 | eB_fit <- eBayes(contrast_fit)
566 |
567 | # function to retrieve the results of
568 | # the differential expression test using 'fdrtool'
569 | retrieve_fun <- function(comp, fit = eB_fit){
570 | res <- topTable(fit, sort.by = "t", adjust.method="BH", coef = comp,
571 | number = Inf, confint = TRUE)
572 | # res <- res[!is.na(res$t),]
573 | #fdr_res <- fdrtool::fdrtool(res$t, plot = FALSE, verbose = FALSE)
574 | # res$qval <- res$adj.P.Value
575 | #res$lfdr <- fdr_res$lfdr
576 | res$comparison <- rep(comp, dim(res)[1])
577 | res <- tibble::rownames_to_column(res)
578 | return(res)
579 | }
580 |
581 | #limma_res<- topTable(eB_fit, sort.by = 'B', adjust.method="BH", coef = cntrst, number = Inf, confint = T )
582 | # limma_res$comparison <- rep(cntrst, dim(limma_res)[1])
583 | #limma_res <- rownames_to_column(limma_res)
584 | # Retrieve the differential expression test results
585 | limma_res <- purrr::map_df(cntrst, retrieve_fun)
586 |
587 | # Select the logFC, CI and qval variables
588 | table <- limma_res %>%
589 | dplyr::select(rowname, logFC, CI.L, CI.R, P.Value, adj.P.Val, comparison) %>%
590 | dplyr::mutate(comparison = gsub(" - ", "_vs_", comparison)) %>%
591 | tidyr::gather(variable, value, -c(rowname,comparison)) %>%
592 | dplyr::mutate(variable = dplyr::recode(variable, logFC = "diff", P.Value = "p.val", adj.P.Val = "p.adj")) %>%
593 | tidyr::unite(temp, comparison, variable) %>%
594 | tidyr::spread(temp, value)
595 |
596 | # avoid wrong order of similar comparison names
597 | comp_list <- sort(gsub(" - ", "_vs_", cntrst))
598 | ordered_colNames <- c("rowname" ,
599 | lapply(comp_list, function(x) colnames(table)[grep(paste0(x, "(_CI.L|_CI.R|_diff|_p.adj|_p.val)"), colnames(table))]) %>% unlist())
600 |
601 | table <- table %>% select(all_of(ordered_colNames))
602 |
603 | rowData(se) <- merge(rowData(se), table,
604 | by.x = "name", by.y = "rowname", all.x = TRUE)
605 | return(se)
606 | #return(table)
607 | }
608 |
609 | get_results_proteins <- function(dep) {
610 | # Show error if inputs are not the required classes
611 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"))
612 |
613 | row_data <- rowData(dep)
614 | # Show error if inputs do not contain required columns
615 | if(any(!c("name", "ID") %in% colnames(row_data))) {
616 | stop("'name' and/or 'ID' columns are not present in '",
617 | deparse(substitute(dep)),
618 | "'\nRun make_unique() and make_se() to obtain the required columns",
619 | call. = FALSE)
620 | }
621 | if(length(grep("_p.adj|_diff", colnames(row_data))) < 1) {
622 | stop("'[contrast]_diff' and/or '[contrast]_p.adj' columns are not present in '",
623 | deparse(substitute(dep)),
624 | "'\nRun test_diff() to obtain the required columns",
625 | call. = FALSE)
626 | }
627 |
628 | # Obtain average protein-centered enrichment values per condition
629 | row_data$mean <- rowMeans(assay(dep), na.rm = TRUE)
630 | centered <- assay(dep) - row_data$mean
631 | centered <- data.frame(centered) %>%
632 | tibble::rownames_to_column() %>%
633 | tidyr::gather(ID, val, -rowname) %>%
634 | dplyr::left_join(., data.frame(colData(dep)), by = "ID")
635 | centered <- dplyr::group_by(centered, rowname, condition) %>%
636 | dplyr::summarize(val = mean(val, na.rm = TRUE)) %>%
637 | dplyr::mutate(val = signif(val, digits = 3)) %>%
638 | tidyr::spread(condition, val)
639 | colnames(centered)[2:ncol(centered)] <-
640 | paste(colnames(centered)[2:ncol(centered)], "_centered", sep = "")
641 |
642 | # Obtain average enrichments of conditions versus the control condition
643 | ratio <- as.data.frame(row_data) %>%
644 | # tibble::column_to_rownames("name") %>%
645 | dplyr::select(dplyr::ends_with("diff")) %>%
646 | signif(., digits = 3) %>%
647 | tibble::rownames_to_column()
648 | colnames(ratio)[2:ncol(ratio)] <-
649 | gsub("_diff", "_log2 fold change", colnames(ratio)[2:ncol(ratio)])
650 | # df <- left_join(ratio, centered, by = "rowname")
651 |
652 | # Select the adjusted p-values and significance columns
653 | pval <- as.data.frame(row_data) %>%
654 | # tibble::column_to_rownames("name") %>%
655 | dplyr::select(dplyr::ends_with("p.val"),
656 | dplyr::ends_with("p.adj"),
657 | dplyr::ends_with("significant")) %>%
658 | tibble::rownames_to_column()
659 | pval[, grep("p.adj", colnames(pval))] <-
660 | pval[, grep("p.adj", colnames(pval))] %>%
661 | signif(digits = 3)
662 | pval[, grep("p.val", colnames(pval))] <-
663 | pval[, grep("p.val", colnames(pval))] %>%
664 | signif(digits = 3)
665 |
666 | # Join into a results table
667 | ids <- as.data.frame(row_data) %>% dplyr::select(name, ID)
668 | table<-dplyr::left_join(ids,ratio, by=c("name"="rowname"))
669 | table <- dplyr::left_join(table, pval, by = c("name" = "rowname"))
670 | # table <- dplyr::left_join(table, centered, by = c("name" = "rowname")) %>%
671 | # dplyr::arrange(desc(significant))
672 | table<-as.data.frame(row_data)[, colnames(row_data) %in% c("name", "imputed", "num_NAs", "Protein.names")] %>%
673 | dplyr::left_join(table, ., by = "name")
674 | table<-table %>% dplyr::arrange(desc(significant))
675 | colnames(table)[1]<-c("Gene Name")
676 | colnames(table)[2]<-c("Protein IDs")
677 | table <- table %>% dplyr::relocate(Protein.names, .after = last_col())
678 | table <- table %>% dplyr::select(grep("[^Protein.names]",colnames(table)), "Protein.names")
679 | # table$Gene_name<-table$name
680 | return(table)
681 | }
682 |
683 |
684 |
685 | #######################################################
686 | ## Plot Enrichment Results
687 | #######################################################
688 |
689 | plot_enrichment <- function(gsea_results, number = 10, alpha = 0.05,
690 | contrasts = NULL, databases = NULL,
691 | nrow = 1,term_size = 8) {
692 | assertthat::assert_that(is.data.frame(gsea_results),
693 | is.numeric(number),
694 | length(number) == 1,
695 | is.numeric(alpha),
696 | length(alpha) == 1,
697 | is.numeric(term_size),
698 | length(term_size) == 1,
699 | is.numeric(nrow),
700 | length(nrow) == 1)
701 |
702 | # Check gsea_results object
703 | if(any(!c("Term", "var",
704 | "contrast","Adjusted.P.value")
705 | %in% colnames(gsea_results))) {
706 | stop("'", deparse(substitute(gsea_results)),
707 | "' does not contain the required columns",
708 | "\nMake sure that HGNC gene symbols are present",
709 | "\n in your 'Gene Names' column of Results table",
710 | call. = FALSE)
711 | }
712 |
713 | no_enrichment_text <- paste("Enrichment could not be performed.\n",
714 | "\nDownload enrichment result table for more details. \n")
715 |
716 | if(!is.null(contrasts)) {
717 | assertthat::assert_that(is.character(contrasts))
718 |
719 | valid_contrasts <- unique(gsea_results$contrast)
720 |
721 | if(!all(contrasts %in% valid_contrasts)) {
722 | # valid_cntrsts_msg <- paste0("Valid contrasts are: '",
723 | # paste0(valid_contrasts, collapse = "', '"),
724 | # "'")
725 | # stop("Not a valid contrast, please run `plot_gsea()`",
726 | # "with a valid contrast as argument\n",
727 | # valid_cntrsts_msg,
728 | # call. = FALSE)
729 | return(ggplot() +
730 | annotate("text", x = 4, y = 25, size=8, label = no_enrichment_text) +
731 | theme_void()
732 | )
733 | }
734 | if(!any(contrasts %in% valid_contrasts)) {
735 | contrasts <- contrasts[contrasts %in% valid_contrasts]
736 | message("Not all contrasts found",
737 | "\nPlotting the following contrasts: '",
738 | paste0(contrasts, collapse = "', '"), "'")
739 | }
740 |
741 | gsea_results <- filter(gsea_results, contrast %in% contrasts)
742 | }
743 | if(!is.null(databases)) {
744 | assertthat::assert_that(is.character(databases))
745 |
746 | valid_databases <- unique(gsea_results$var)
747 |
748 | if(all(!databases %in% valid_databases)) {
749 | valid_cntrsts_msg <- paste0("Valid databases are: '",
750 | paste0(valid_databases, collapse = "', '"),
751 | "'")
752 | stop("Not a valid database, please run `plot_gsea()`",
753 | "with valid databases as argument\n",
754 | valid_cntrsts_msg,
755 | call. = FALSE)
756 | }
757 | if(any(!databases %in% valid_databases)) {
758 | databases <- databases[databases %in% valid_databases]
759 | message("Not all databases found",
760 | "\nPlotting the following databases: '",
761 | paste0(databases, collapse = "', '"), "'")
762 | }
763 |
764 | gsea_results <- filter(gsea_results, var %in% databases)
765 | }
766 |
767 | # Get top enriched gene sets
768 | terms <- gsea_results %>%
769 | dplyr::group_by(contrast, var) %>%
770 | dplyr::filter(Adjusted.P.value <= alpha) %>%
771 | dplyr::arrange(Adjusted.P.value) %>%
772 | dplyr::slice(seq_len(number)) %>%
773 | .$Term
774 | subset <- gsea_results %>%
775 | dplyr::filter(Term %in% terms) %>%
776 | dplyr::arrange(var, Adjusted.P.value)
777 |
778 | subset$Term <- readr::parse_factor(subset$Term, levels = unique(subset$Term))
779 | subset$var <- readr::parse_factor(subset$var, levels = unique(subset$var))
780 |
781 | # Plot top enriched gene sets
782 | if (nrow(subset) == 0){
783 | p <- ggplot() +
784 | annotate("text", x = 4, y = 25, size=8, label = no_enrichment_text) +
785 | theme_void()
786 | } else {
787 | p<-ggplot(subset, aes(Term,
788 | y=-log10(`Adjusted.P.value`))) +
789 | geom_col(aes(fill = log_odds )) +
790 | facet_wrap(~contrast, nrow = nrow) +
791 | coord_flip() +
792 | labs(y = "-Log10 adjusted p-value",
793 | fill = "Log2 odds ratio (vs. current background)") +
794 | theme_bw() +
795 | theme(legend.position = "top",
796 | legend.text = element_text(size = 9)) +
797 | scale_fill_distiller(palette="Spectral")
798 | }
799 | }
800 |
801 | #### ==== get prefix function
802 |
803 | get_prefix <- function(words) {
804 | # Show error if input is not the required class
805 | assertthat::assert_that(is.character(words))
806 |
807 | # Show error if 'words' contains 1 or less elements
808 | if(length(words) <= 1) {
809 | stop("'words' should contain more than one element")
810 | }
811 | # Show error if 'words' contains NA
812 | if(any(is.na(words))) {
813 | stop("'words' contains NAs")
814 | }
815 |
816 | # Truncate words to smallest name
817 | minlen <- min(nchar(words))
818 | truncated <- substr(words, 1, minlen)
819 |
820 | # Show error if one of the elements is shorter than one character
821 | if(minlen < 1) {
822 | stop("At least one of the elements is too short")
823 | }
824 |
825 | # Get identifical characters
826 | mat <- data.frame(strsplit(truncated, ""), stringsAsFactors = FALSE)
827 | identical <- apply(mat, 1, function(x) length(unique(x)) == 1)
828 |
829 | # Obtain the longest common prefix
830 | prefix <- as.logical(cumprod(identical))
831 | paste(mat[prefix, 1], collapse = "")
832 | }
833 |
834 | #### ===== delete prefix function
835 |
836 | delete_prefix <- function(words) {
837 | # Get prefix
838 | prefix <- get_prefix(words)
839 | # Delete prefix from words
840 | gsub(paste0("^", prefix), "", words)
841 | }
842 |
843 | ### Filter missing values use different threshold per conditions/groups
844 | threshold_detect <- function(sample_rep){
845 | valid_keep <- trunc(sample_rep/2) + 1
846 | threshold <- sample_rep - valid_keep
847 | return(threshold)
848 | }
849 |
850 | keep_function <- function(se){
851 | # Show error if inputs are not the required classes
852 |
853 | # Show error if inputs do not contain required columns
854 | if(any(!c("name", "ID") %in% colnames(rowData(se, use.names = FALSE)))) {
855 | stop("'name' and/or 'ID' columns are not present in '",
856 | deparse(substitute(se)),
857 | "'\nRun make_unique() and make_se() to obtain the required columns",
858 | call. = FALSE)
859 | }
860 | if(any(!c("label", "condition", "replicate") %in% colnames(colData(se)))) {
861 | stop("'label', 'condition' and/or 'replicate' columns are not present in '",
862 | deparse(substitute(se)),
863 | "'\nRun make_se() or make_se_parse() to obtain the required columns",
864 | call. = FALSE)
865 | }
866 |
867 | # Make assay values binary (1 = valid value)
868 | bin_data <- assay(se)
869 |
870 | # new, removed ref columns from dataset
871 | bin_data <- bin_data %>% data.frame()
872 | idx <- is.na(bin_data) # idx <- is.na(assay(se))
873 | bin_data[!idx] <- 1
874 | bin_data[idx] <- 0
875 |
876 | # Filter se on the maximum allowed number of
877 | # missing values per condition (defined by thr)
878 | keep <- bin_data %>%
879 | data.frame() %>%
880 | rownames_to_column() %>%
881 | gather(ID, value, -rowname) %>%
882 | left_join(., data.frame(colData(se)), by = "ID") %>%
883 | group_by(rowname, condition) %>%
884 | summarize(miss_val = n() - sum(value))
885 | return(keep)
886 | }
887 |
888 | filter_missval_new <- function(se,one_condition,exp_df){
889 | threshold <- exp_df$thr[exp_df$condition==one_condition] %>% unlist()
890 | keep <- keep_function(se)
891 | keep1 <- keep %>%
892 | dplyr::filter(condition == one_condition) %>%
893 | dplyr::filter(miss_val <= threshold)
894 | keep1 <- keep1 %>%
895 | tidyr::spread(condition, miss_val)
896 | se_fltrd <- se[keep1$rowname, ]
897 | return(se_fltrd)
898 | }
--------------------------------------------------------------------------------
/R/tests.R:
--------------------------------------------------------------------------------
1 | ### Test if column names are proper in experiment design file
2 |
3 | exp_design_test<-function(exp_design){
4 | col_names<-colnames(exp_design)
5 | ##
6 | if(!"label" %in% col_names){
7 | stop(safeError("The column 'label'(case sensitive) is not found in the Experimental Design File"))
8 | }
9 |
10 | else if (!"condition" %in% col_names){
11 | stop(safeError("The column 'condition' (case sensitive) is not found in the Experimental Design File"))
12 | }
13 |
14 | else if (!"replicate" %in% col_names){
15 | stop(safeError("The column 'replicate' (case sensitive) is not found in the Experimental Design File"))
16 | }
17 |
18 | }
19 |
20 | ### Test if column names are proper in maxquant ProteinGroups file
21 | maxquant_input_test<-function(maxquant_input){
22 | col_names<-colnames(maxquant_input)
23 | ##
24 | if(!"Gene.names" %in% col_names){
25 | stop(safeError("The column 'Gene names' is not found in the MaxQuant proteinGroups File"))
26 | }
27 |
28 | else if (any(grepl("LFQ", col_names))==FALSE){
29 | stop(safeError("Columns starting with 'LFQ' are not found in the MaxQuant proteinGroups File"))
30 | }
31 |
32 | else if (!"Protein.IDs" %in% col_names){
33 | stop(safeError("The column 'Protein IDs' is not found in the MaxQuant proteinGroups File"))
34 | }
35 |
36 | else if (!"Reverse" %in% col_names){
37 | stop(safeError("The column 'Reverse' is not found in the MaxQuant proteinGroups File"))
38 | }
39 |
40 | else if (!"Potential.contaminant" %in% col_names){
41 | stop(safeError("The column 'Potential contaminant' is not found in the MaxQuant proteinGroups File"))
42 | }
43 |
44 | else if (!"Only.identified.by.site" %in% col_names){
45 | stop(safeError("The column 'Only identified by site' is not found in the MaxQuant proteinGroups File"))
46 | }
47 |
48 | else if (!"Razor...unique.peptides" %in% col_names){
49 | stop(safeError("The column 'Razor + unique peptides' is not found in the MaxQuant proteinGroups File"))
50 | }
51 |
52 | else if (!"Protein.names" %in% col_names){
53 | stop(safeError("The column 'Protein names' is not found in the MaxQuant proteinGroups File"))
54 | }
55 |
56 | }
57 |
58 |
59 | ### Test if experimental design names and LFQ column names match
60 |
61 | test_match_lfq_column_design<-function(unique_data, lfq_columns, exp_design){
62 | # Show error if inputs are not the required classes
63 | assertthat::assert_that(is.data.frame(unique_data),
64 | is.integer(lfq_columns),
65 | is.data.frame(exp_design))
66 |
67 | # Show error if inputs do not contain required columns
68 | if(any(!c("name", "ID") %in% colnames(unique_data))) {
69 | stop(safeError("'Gene name' and/or 'Protein ID' columns are not present in
70 | protein groups input file"
71 | ))
72 | }
73 |
74 | if(any(!c("label", "condition", "replicate") %in% colnames(exp_design))) {
75 | stop(safeError("'label', 'condition' and/or 'replicate' columns
76 | are not present in the experimental design"))
77 | }
78 |
79 | if(any(!apply(unique_data[, lfq_columns], 2, is.numeric))) {
80 | stop(safeError("specified 'columns' should be numeric
81 | Run make_se_parse() with the appropriate columns as argument"))
82 | }
83 |
84 | raw <- unique_data[, lfq_columns]
85 |
86 | expdesign <- mutate(exp_design, condition = make.names(condition)) %>%
87 | unite(ID, condition, replicate, remove = FALSE)
88 | rownames(expdesign) <- expdesign$ID
89 |
90 | matched <- match(make.names(delete_prefix(expdesign$label)),
91 | make.names(delete_prefix(colnames(raw))))
92 |
93 | if(any(is.na(matched))) {
94 | stop(safeError("The labels/'run names' in the experimental design DID NOT match
95 | with lfq column names in maxquants proteinGroups file
96 | Run LFQ-Analyst with correct labels in the experimental design"))
97 | }
98 | }
99 |
100 |
101 |
102 | enrichment_output_test<-function(dep, database){
103 | significant <- SummarizedExperiment::rowData(dep) %>%
104 | as.data.frame() %>%
105 | dplyr::select(name, significant) %>%
106 | dplyr::filter(significant) %>%
107 | dplyr::mutate(name = gsub("[.].*", "", name))
108 | test_enrichment_output<-enrichr_mod(significant$name, databases = database)
109 | if(nrow(test_enrichment_output[[1]])==0)
110 | stop(safeError("Enrichment analysis failed.
111 | Please check if the gene names are in Entrenz Gene Symbol format.
112 | (eg. ASM24, MYO6)"))
113 | }
114 |
115 | null_enrichment_test<-function(gsea_result,alpha=0.05){
116 | gsea_df<-gsea_result %>% group_by(contrast, var) %>% dplyr::filter(Adjusted.P.value <= alpha)
117 | if(nrow(gsea_df)==0){
118 | stop(safeError("No enriched term found at FDR cutoff 0.05.
119 | Enrichment plot could not be displayed.
120 | However, the results (non-significant hits) can still be accessed
121 | through 'Download table' tab."))
122 | }
123 | }
124 |
125 | ids_test<-function(filtered_data){
126 | if("Evidence.IDs" %in% colnames(filtered_data)){
127 | filtered_data$`Evidence.IDs`<-stringr::str_trunc(as.character(filtered_data$`Evidence.IDs`), 25000)
128 | }
129 | if("MS.MS.IDs" %in% colnames(filtered_data)){
130 | filtered_data$`MS.MS.IDs`<-stringr::str_trunc(as.character(filtered_data$`MS.MS.IDs`), 25000)
131 | }
132 |
133 | return(filtered_data)
134 |
135 | }
136 |
137 |
--------------------------------------------------------------------------------
/R/volcano_function.R:
--------------------------------------------------------------------------------
1 | ## New function for volcano plot
2 | #library(dplyr)
3 | plot_volcano_new <- function(dep, contrast, label_size = 3,
4 | add_names = TRUE, adjusted = FALSE, plot = TRUE) {
5 | # Show error if inputs are not the required classes
6 | if(is.integer(label_size)) label_size <- as.numeric(label_size)
7 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
8 | is.character(contrast),
9 | length(contrast) == 1,
10 | is.numeric(label_size),
11 | length(label_size) == 1,
12 | is.logical(add_names),
13 | length(add_names) == 1,
14 | is.logical(adjusted),
15 | length(adjusted) == 1,
16 | is.logical(plot),
17 | length(plot) == 1)
18 |
19 | row_data <- rowData(dep, use.names = FALSE)
20 |
21 | # Show error if inputs do not contain required columns
22 | if(any(!c("name", "ID") %in% colnames(row_data))) {
23 | stop(paste0("'name' and/or 'ID' columns are not present in '",
24 | deparse(substitute(dep)),
25 | "'.\nRun make_unique() to obtain required columns."),
26 | call. = FALSE)
27 | }
28 | if(length(grep("_p.adj|_diff", colnames(row_data))) < 1) {
29 | stop(paste0("'[contrast]_diff' and '[contrast]_p.adj' columns are not present in '",
30 | deparse(substitute(dep)),
31 | "'.\nRun test_diff() to obtain the required columns."),
32 | call. = FALSE)
33 | }
34 | if(length(grep("_significant", colnames(row_data))) < 1) {
35 | stop(paste0("'[contrast]_significant' columns are not present in '",
36 | deparse(substitute(dep)),
37 | "'.\nRun add_rejections() to obtain the required columns."),
38 | call. = FALSE)
39 | }
40 |
41 | # Show error if an unvalid contrast is given
42 | if (length(grep(paste("^",contrast,"_diff", sep = ""),
43 | colnames(row_data))) == 0) {
44 | valid_cntrsts <- row_data %>%
45 | data.frame() %>%
46 | select(ends_with("_diff")) %>%
47 | colnames(.) %>%
48 | gsub("_diff", "", .)
49 | valid_cntrsts_msg <- paste0("Valid contrasts are: '",
50 | paste0(valid_cntrsts, collapse = "', '"),
51 | "'")
52 | stop("Not a valid contrast, please run `plot_volcano()` with a valid contrast as argument\n",
53 | valid_cntrsts_msg,
54 | call. = FALSE)
55 | }
56 |
57 | # Generate a data.frame containing all info for the volcano plot
58 | diff <- grep(paste("^",contrast,"_diff", sep = ""),
59 | colnames(row_data))
60 | if(adjusted) {
61 | p_values <- grep(paste("^",contrast, "_p.adj", sep = ""),
62 | colnames(row_data))
63 | } else {
64 | p_values <- grep(paste("^",contrast, "_p.val", sep = ""),
65 | colnames(row_data))
66 | }
67 | signif <- grep(paste("^",contrast, "_significant", sep = ""),
68 | colnames(row_data))
69 | df_tmp <- data.frame(diff = row_data[, diff],
70 | p_values = -log10(row_data[, p_values]),
71 | signif = row_data[, signif],
72 | name = row_data$name)
73 | df<- df_tmp %>% data.frame() %>% filter(!is.na(signif)) %>%
74 | arrange(signif)
75 |
76 | name1 <- gsub("_vs_.*", "", contrast)
77 | name2 <- gsub(".*_vs_", "", contrast)
78 | #return(df)
79 | # Plot volcano with or without labels
80 | p <- ggplot(df, aes(diff, p_values)) +
81 | geom_vline(xintercept = 0) +
82 | geom_point(aes(col = signif)) +
83 | geom_text(data = data.frame(), aes(x = c(Inf, -Inf),
84 | y = c(-Inf, -Inf),
85 | hjust = c(1, 0),
86 | vjust = c(-1, -1),
87 | label = c(name1, name2),
88 | size = 5,
89 | fontface = "bold")) +
90 | labs(title = contrast,
91 | x = expression(log[2]~"Fold change")) +
92 | theme_DEP1() +
93 | theme(legend.position = "none") +
94 | scale_color_manual(values = c("TRUE" = "black", "FALSE" = "grey"))
95 | if (add_names) {
96 | p <- p + ggrepel::geom_text_repel(data = filter(df, signif),
97 | aes(label = name),
98 | size = label_size,
99 | box.padding = unit(0.1, 'lines'),
100 | point.padding = unit(0.1, 'lines'),
101 | segment.size = 0.5)
102 | }
103 | if(adjusted) {
104 | p <- p + labs(y = expression(-log[10]~"Adjusted p-value"))
105 | } else {
106 | p <- p + labs(y = expression(-log[10]~"P-value"))
107 | }
108 | if(plot) {
109 | # return(list(p, df))
110 | # return(df)
111 | return(p)
112 | } else {
113 | df <- df %>%
114 | select(name, diff, p_value, signif) %>%
115 | arrange(desc(x))
116 | colnames(df)[c(1,2,3)] <- c("protein", "log2_fold_change", "p_value_-log10")
117 | if(adjusted) {
118 | colnames(df)[3] <- "adjusted_p_value_-log10"
119 | }
120 | return(df)
121 | }
122 | }
123 |
124 |
125 | #####====== get_volcano_df =======#######
126 | get_volcano_df <- function(dep, contrast, adjusted = FALSE) {
127 | # Show error if inputs are not the required classes
128 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
129 | is.character(contrast),
130 | length(contrast) == 1)
131 |
132 | row_data <- rowData(dep, use.names = FALSE)
133 |
134 | # Show error if inputs do not contain required columns
135 | if(any(!c("name", "ID") %in% colnames(row_data))) {
136 | stop(paste0("'name' and/or 'ID' columns are not present in '",
137 | deparse(substitute(dep)),
138 | "'.\nRun make_unique() to obtain required columns."),
139 | call. = FALSE)
140 | }
141 | if(length(grep("_p.adj|_diff", colnames(row_data))) < 1) {
142 | stop(paste0("'[contrast]_diff' and '[contrast]_p.adj' columns are not present in '",
143 | deparse(substitute(dep)),
144 | "'.\nRun test_diff() to obtain the required columns."),
145 | call. = FALSE)
146 | }
147 | if(length(grep("_significant", colnames(row_data))) < 1) {
148 | stop(paste0("'[contrast]_significant' columns are not present in '",
149 | deparse(substitute(dep)),
150 | "'.\nRun add_rejections() to obtain the required columns."),
151 | call. = FALSE)
152 | }
153 |
154 | # Show error if an unvalid contrast is given
155 | if (length(grep(paste(contrast, "_diff", sep = ""),
156 | colnames(row_data))) == 0) {
157 | valid_cntrsts <- row_data %>%
158 | data.frame() %>%
159 | select(ends_with("_diff")) %>%
160 | colnames(.) %>%
161 | gsub("_diff", "", .)
162 | valid_cntrsts_msg <- paste0("Valid contrasts are: '",
163 | paste0(valid_cntrsts, collapse = "', '"),
164 | "'")
165 | stop("Not a valid contrast, please run `plot_volcano()` with a valid contrast as argument\n",
166 | valid_cntrsts_msg,
167 | call. = FALSE)
168 | }
169 |
170 | # Generate a data.frame containing all info for the volcano plot
171 | diff <- grep(paste(contrast, "_diff", sep = ""),
172 | colnames(row_data))
173 | if(adjusted) {
174 | p_values <- grep(paste(contrast, "_p.adj", sep = ""),
175 | colnames(row_data))
176 | } else {
177 | p_values <- grep(paste(contrast, "_p.val", sep = ""),
178 | colnames(row_data))
179 | }
180 | signif <- grep(paste(contrast, "_significant", sep = ""),
181 | colnames(row_data))
182 | df_tmp <- data.frame(diff = row_data[, diff],
183 | p_values = -log10(row_data[, p_values]),
184 | signif = row_data[, signif],
185 | name = row_data$name)
186 | df<- df_tmp %>% data.frame() %>% filter(!is.na(signif)) %>%
187 | arrange(signif)
188 |
189 | return(df)
190 | }
191 |
192 | ### Function to plot intensities of individual proteins
193 | plot_protein<-function(dep, protein, type){
194 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
195 | is.character(protein),
196 | is.character(type))
197 | subset<-dep[protein]
198 |
199 | df_reps <- data.frame(assay(subset)) %>%
200 | rownames_to_column() %>%
201 | gather(ID, val, -rowname) %>%
202 | left_join(., data.frame(colData(subset)), by = "ID")
203 | df_reps$rowname <- parse_factor(as.character(df_reps$rowname), levels = protein)
204 |
205 | df_CI<- df_reps %>%
206 | group_by(condition, rowname) %>%
207 | summarize(mean = mean(val, na.rm = TRUE),
208 | sd = sd(val, na.rm = TRUE),
209 | n = n()) %>%
210 | mutate(error = qnorm(0.975) * sd / sqrt(n),
211 | CI.L = mean - error,
212 | CI.R = mean + error) %>%
213 | as.data.frame()
214 | df_CI$rowname <- parse_factor(as.character(df_CI$rowname), levels = protein)
215 |
216 | if(type=="violin"){
217 | p<-ggplot(df_reps, aes(condition, val))+
218 | geom_violin(fill="grey90", scale = "width",
219 | draw_quantiles = 0.5,
220 | trim =TRUE) +
221 | geom_jitter(aes(color = factor(replicate)),
222 | size = 3, position = position_dodge(width=0.3)) +
223 | labs(
224 | y = expression(log[2]~"Intensity"),
225 | col = "Replicates") +
226 | facet_wrap(~rowname) +
227 | scale_color_brewer(palette = "Dark2")+
228 | theme_DEP1()+
229 | theme(axis.title.x = element_blank())
230 | }
231 |
232 | if(type=="boxplot"){
233 | p<-ggplot(df_reps, aes(condition, val))+
234 | geom_boxplot()+
235 | geom_jitter(aes(color = factor(replicate)),
236 | size = 3, position = position_dodge(width=0.3)) +
237 | labs(
238 | y = expression(log[2]~"Intensity"),
239 | col = "Replicates") +
240 | facet_wrap(~rowname) +
241 | scale_color_brewer(palette = "Dark2")+
242 | theme_DEP1() +
243 | theme(axis.title.x = element_blank())
244 | }
245 |
246 | if(type=="interaction"){
247 | p<-ggplot(df_reps, aes(condition, val))+
248 | geom_point(aes(color = factor(replicate)),
249 | size = 3) +
250 | geom_line(aes(group= factor(replicate), color= factor(replicate)))+
251 | labs(
252 | y = expression(log[2]~"Intensity"),
253 | col = "Replicates") +
254 | facet_wrap(~rowname) +
255 | scale_color_brewer(palette = "Dark2")+
256 | theme_DEP1()+
257 | theme(axis.title.x = element_blank())
258 | }
259 |
260 | if(type=="dot"){
261 | p<-ggplot(df_CI, aes(condition, mean))+
262 | geom_point(data=df_reps, aes(x=condition, y=val, color = factor(replicate)),
263 | size = 3, position= position_dodge(width = 0.2)) +
264 | geom_errorbar(aes(ymin = CI.L, ymax = CI.R), width = 0.2)+
265 | labs(
266 | y = expression(log[2]~"Intensity"~"(\u00B195% CI)"),
267 | col = "Replicates") +
268 | facet_wrap(~rowname) +
269 | scale_color_brewer(palette = "Dark2")+
270 | theme_DEP1() +
271 | theme(axis.title.x = element_blank())
272 | }
273 |
274 | return(p)
275 | }
276 |
277 | plot_volcano_mod <- function(dep, contrast, label_size = 3,
278 | add_names = TRUE, adjusted = FALSE, plot = TRUE) {
279 | # Show error if inputs are not the required classes
280 | if(is.integer(label_size)) label_size <- as.numeric(label_size)
281 | assertthat::assert_that(inherits(dep, "SummarizedExperiment"),
282 | is.character(contrast),
283 | length(contrast) == 1,
284 | is.numeric(label_size),
285 | length(label_size) == 1,
286 | is.logical(add_names),
287 | length(add_names) == 1,
288 | is.logical(adjusted),
289 | length(adjusted) == 1,
290 | is.logical(plot),
291 | length(plot) == 1)
292 |
293 | row_data <- rowData(dep, use.names = FALSE)
294 |
295 | # Show error if inputs do not contain required columns
296 | if(any(!c("name", "ID") %in% colnames(row_data))) {
297 | stop(paste0("'name' and/or 'ID' columns are not present in '",
298 | deparse(substitute(dep)),
299 | "'.\nRun make_unique() to obtain required columns."),
300 | call. = FALSE)
301 | }
302 | if(length(grep("_p.adj|_diff", colnames(row_data))) < 1) {
303 | stop(paste0("'[contrast]_diff' and '[contrast]_p.adj' columns are not present in '",
304 | deparse(substitute(dep)),
305 | "'.\nRun test_diff() to obtain the required columns."),
306 | call. = FALSE)
307 | }
308 | if(length(grep("_significant", colnames(row_data))) < 1) {
309 | stop(paste0("'[contrast]_significant' columns are not present in '",
310 | deparse(substitute(dep)),
311 | "'.\nRun add_rejections() to obtain the required columns."),
312 | call. = FALSE)
313 | }
314 |
315 | # Show error if an unvalid contrast is given
316 | if (length(grep(paste("^",contrast, "_diff", sep = ""),
317 | colnames(row_data))) == 0) {
318 | valid_cntrsts <- row_data %>%
319 | data.frame() %>%
320 | select(ends_with("_diff")) %>%
321 | colnames(.) %>%
322 | gsub("_diff", "", .)
323 | valid_cntrsts_msg <- paste0("Valid contrasts are: '",
324 | paste0(valid_cntrsts, collapse = "', '"),
325 | "'")
326 | stop("Not a valid contrast, please run `plot_volcano()` with a valid contrast as argument\n",
327 | valid_cntrsts_msg,
328 | call. = FALSE)
329 | }
330 |
331 | # Generate a data.frame containing all info for the volcano plot
332 | diff <- grep(paste("^",contrast, "_diff", sep = ""),
333 | colnames(row_data))
334 | if(adjusted) {
335 | p_values <- grep(paste("^",contrast, "_p.adj", sep = ""),
336 | colnames(row_data))
337 | } else {
338 | p_values <- grep(paste("^", contrast, "_p.val", sep = ""),
339 | colnames(row_data))
340 | }
341 | signif <- grep(paste("^",contrast, "_significant", sep = ""),
342 | colnames(row_data))
343 | df <- data.frame(x = row_data[, diff],
344 | y = -log10(row_data[, p_values]),
345 | significant = row_data[, signif],
346 | name = row_data$name) %>%
347 | filter(!is.na(significant)) %>%
348 | arrange(significant)
349 |
350 | name1 <- gsub("_vs_.*", "", contrast)
351 | name2 <- gsub(".*_vs_", "", contrast)
352 |
353 | # Plot volcano with or without labels
354 | p <- ggplot(df, aes(x, y)) +
355 | geom_vline(xintercept = 0) +
356 | geom_point(aes(col = significant)) +
357 | geom_text(data = data.frame(), aes(x = c(Inf, -Inf),
358 | y = c(-Inf, -Inf),
359 | hjust = c(1, 0),
360 | vjust = c(-1, -1),
361 | label = c(name1, name2),
362 | size = 5,
363 | fontface = "bold")) +
364 | labs(title = contrast,
365 | x = expression(log[2]~"Fold change")) +
366 | theme_DEP1() +
367 | theme(legend.position = "none") +
368 | scale_color_manual(values = c("TRUE" = "black", "FALSE" = "grey"))
369 | if (add_names) {
370 | p <- p + ggrepel::geom_text_repel(data = filter(df, significant),
371 | aes(label = name),
372 | size = label_size,
373 | box.padding = unit(0.1, 'lines'),
374 | point.padding = unit(0.1, 'lines'),
375 | segment.size = 0.5)
376 | }
377 | if(adjusted) {
378 | p <- p + labs(y = expression(-log[10]~"Adjusted p-value"))
379 | } else {
380 | p <- p + labs(y = expression(-log[10]~"P-value"))
381 | }
382 | if(plot) {
383 | return(p)
384 | } else {
385 | df <- df %>%
386 | select(name, x, y, significant) %>%
387 | arrange(desc(x))
388 | colnames(df)[c(1,2,3)] <- c("protein", "log2_fold_change", "p_value_-log10")
389 | if(adjusted) {
390 | colnames(df)[3] <- "adjusted_p_value_-log10"
391 | }
392 | return(df)
393 | }
394 | }
395 |
396 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://www.repostatus.org/#active)
2 | 
3 | 
4 |
5 | # LFQ-Analyst
6 | A tool for analysing label-free quantitative proteomics dataset https://bioinformatics.erc.monash.edu/apps/LFQ-Analyst/
7 |
8 | 
9 |
10 |
11 |
12 |
13 |
14 |
15 | ## Motivation
16 |
17 | - Automate downstream statistical analysis of Label free quantitative proteomics data (generated by MaxQuant)
18 |
19 |
20 | ### Input
21 |
22 | - MaxQuant **proteinGroups.txt** file
23 | - An experiment design table (tab separated file) containing three columns ("label", "condition", "replicate")
24 |
25 | #### Data pre-filtering criteria
26 |
27 | - Remove potential contaminants
28 | - Remove reverse sequences
29 | - Remove proteins identified only by sites
30 | - Remove proteins identified/quantified by a single Razor or unique peptide
31 | - Remove observation with high proportion of missing values (intensity values must be present
32 | at least 2 out of three replicates)
33 |
34 | #### Advanced parameters to choose
35 |
36 | - Differencial expression cutoff
37 | - Adjusted p-value cutoff (FDR cutoff on quantitation)
38 | - Log2 fold change cutoff
39 | - Option to choose paired test for matched pair data
40 | - Types of imputation
41 | - A number of missing value imputation options including knn, Minpob etc.
42 | - Type of FDR correction
43 | - Benjamin Hochberg (BH) method
44 | - t-statistics correction: Implemented in
45 | [fdrtools](http://strimmerlab.org/software/fdrtool/)
46 | - Option to include proteins identified/quantified with a single unique peptide.
47 | - Select how many clusters of differentially expressed proteins needed for the heatmap (default is 6)
48 |
49 |
50 |
51 | ### Outputs
52 |
53 | #### Result table
54 |
55 | - **LFQ Results Table:** Includes names (Gene names), Protein Ids, Log
56 | fold changes/ ratios (each pairwise comparisons), Adjusted
57 | *p-values* (applying FDR corrections), *p-values*, Boolean values
58 | for significance, average protein intensity (log transformed) in
59 | each sample.
60 |
61 | #### Result Plots
62 | 1. Interactive volcano plot for each pairwise comparison.
63 | 2. Heatmap of differencially expressed proteins
64 | 3. Protein intensity plots for a single or group of selected proteins from table.
65 |
66 | #### QC Plots
67 | 1. PCA plot (Could move to QC section)
68 | 2. Sample Correlation (pearson correlation)
69 | 3. Sample Coefficient of variations (CVs)
70 | 4. Number of proteins per sample
71 | 5. Sample coverage (overlap of identified proteins across every sample)
72 | 6. Missing value heatmap
73 | 7. Imputation effect on sample distribution
74 |
75 | ### Download options
76 |
77 | **Download tables** (csv format)
78 |
79 | 1. Results: Same as *LFQ Results Table*
80 | 2. Unimputed data matrix: Original protein intensities before
81 | imputation in each sample.
82 | 3. Imputed data matrix: Protein intensities after performing selected
83 | imputation method
84 | 4. Full results: Combined table of all above data outputs i.e. with and
85 | without imputation information, along with fold change and p-values.
86 |
87 | **Download Report**
88 | - A summary report for each analysis that
89 | includes method, summary statistics and plots.
90 |
91 |
92 | ### Local installation
93 |
94 | The current version of LFQ-Analyst is hosted on `R - 4.2.1`. The detailed dependency information can be found in the `dependencies.txt` file.
95 |
96 | Once installed all the dependencies following steps to run the server locally.
97 |
98 | - Using git and Rstudio
99 | ```
100 | ## Clone the repository
101 | git clone https://github.com/MonashBioinformaticsPlatform/LFQ-Analyst.git
102 |
103 | ## Move to the folder
104 | cd LFQ-Analyst
105 |
106 | ## Inside R console or R studio
107 | > library("shiny")
108 |
109 | > runApp()
110 |
111 | ```
112 |
113 | - Using Docker
114 |
115 | Install & start Docker demon on your PC
116 |
117 | ```
118 | ## Option one:
119 | ## Pull LFQ-Analyst image from Docker Hub (From terminal)
120 | > docker pull haileyzhang/lfq-analyst:tagname
121 |
122 | ## Option two:
123 | ## Clone the repository
124 | git clone https://github.com/MonashBioinformaticsPlatform/LFQ-Analyst.git
125 |
126 | ## Move to the folder
127 | cd LFQ-Analyst
128 |
129 | ## Build LFQ-Analyst (Any name after -t)
130 | > docker build -f Dockerfile -t LFQ-Analyst .
131 |
132 | ## Run LFQ-Analyst (From terminal)
133 |
134 | > docker run -p 3838:3838 LFQ-Analyst
135 |
136 | ## Open local interface
137 |
138 | https://localhost:3838/LFQ-Analyst
139 |
140 |
141 | ```
142 |
--------------------------------------------------------------------------------
/data/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/data/.DS_Store
--------------------------------------------------------------------------------
/data/create_example_data.R:
--------------------------------------------------------------------------------
1 | ### create example data rds
2 |
3 | maxquant_output<-read.table("data/proteinGroups.txt",header=TRUE,sep="\t")
4 |
5 | exp_design <- read.table("data/exp_design_p10_0144.txt",
6 | header=TRUE,
7 | sep = "\t",
8 | stringsAsFactors=FALSE)
9 |
10 | save(maxquant_output, exp_design, file = "data/example_data.RData")
11 |
12 |
--------------------------------------------------------------------------------
/data/demo_data.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/data/demo_data.RData
--------------------------------------------------------------------------------
/data/example_data.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/data/example_data.RData
--------------------------------------------------------------------------------
/data/exp_design_p10_0144.txt:
--------------------------------------------------------------------------------
1 | label condition replicate
2 | H1 CD34High 1
3 | H2 CD34High 2
4 | H3 CD34High 3
5 | H4 CD34High 4
6 | L1 CD34Low 1
7 | L2 CD34Low 2
8 | L3 CD34Low 3
9 | L4 CD34Low 4
10 | N1 CD34Neg 1
11 | N2 CD34Neg 2
12 | N3 CD34Neg 3
13 | N4 CD34Neg 4
--------------------------------------------------------------------------------
/data/lfq_results.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/data/lfq_results.RData
--------------------------------------------------------------------------------
/dependencies.txt:
--------------------------------------------------------------------------------
1 | R version 4.2.1 (2022-06-23)
2 | Platform: x86_64-pc-linux-gnu (64-bit)
3 | Running under: Ubuntu 16.04.3 LTS
4 |
5 | Matrix products: default
6 | LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
7 |
8 | locale:
9 | [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C
10 | [3] LC_TIME=en_AU.UTF-8 LC_COLLATE=en_AU.UTF-8
11 | [5] LC_MONETARY=en_AU.UTF-8 LC_MESSAGES=en_AU.UTF-8
12 | [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C
13 | [9] LC_ADDRESS=C LC_TELEPHONE=C
14 | [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C
15 |
16 | attached base packages:
17 | [1] grid parallel stats4 stats graphics grDevices utils
18 | [8] datasets methods base
19 |
20 | other attached packages:
21 | [1] shinycssloaders_1.0.0 svglite_2.1.0
22 | [3] rjson_0.2.21 httr_1.4.4
23 | [5] ggrepel_0.9.1 DT_0.25
24 | [7] limma_3.52.4 ComplexHeatmap_2.12.1
25 | [9] shinyalert_3.0.0 shinyjs_2.1.0
26 | [11] shinydashboard_0.7.2 testthat_3.1.5
27 | [13] DEP_1.18.0 forcats_0.5.2
28 | [15] stringr_1.4.1 dplyr_1.0.10
29 | [17] purrr_0.3.5 readr_2.1.3
30 | [19] tidyr_1.2.1 tibble_3.1.8
31 | [21] ggplot2_3.3.6 tidyverse_1.3.2
32 | [23] shiny_1.7.2 SummarizedExperiment_1.26.1
33 | [25] Biobase_2.56.0 GenomicRanges_1.48.0
34 | [27] GenomeInfoDb_1.32.4 IRanges_2.30.1
35 | [29] S4Vectors_0.34.0 BiocGenerics_0.42.0
36 | [31] MatrixGenerics_1.8.1 matrixStats_0.62.0
37 |
38 | loaded via a namespace (and not attached):
39 | [1] uuid_1.1-0 readxl_1.4.1
40 | [3] backports_1.4.1 circlize_0.4.15
41 | [5] systemfonts_1.0.4 plyr_1.8.7
42 | [7] gmm_1.7 crosstalk_1.2.0
43 | [9] BiocParallel_1.30.4 digest_0.6.30
44 | [11] foreach_1.5.2 htmltools_0.5.3
45 | [13] magick_2.7.3 fansi_1.0.3
46 | [15] memoise_2.0.1 magrittr_2.0.3
47 | [17] googlesheets4_1.0.1 cluster_2.1.4
48 | [19] doParallel_1.0.17 tzdb_0.3.0
49 | [21] modelr_0.1.9 imputeLCMD_2.1
50 | [23] sandwich_3.0-2 colorspace_2.0-3
51 | [25] rvest_1.0.3 haven_2.5.1
52 | [27] xfun_0.34 crayon_1.5.2
53 | [29] RCurl_1.98-1.9 jsonlite_1.8.2
54 | [31] impute_1.70.0 zoo_1.8-11
55 | [33] iterators_1.0.14 glue_1.6.2
56 | [35] gtable_0.3.1 gargle_1.2.1
57 | [37] zlibbioc_1.42.0 XVector_0.36.0
58 | [39] GetoptLong_1.0.5 DelayedArray_0.22.0
59 | [41] shape_1.4.6 scales_1.2.1
60 | [43] vsn_3.64.0 mvtnorm_1.1-3
61 | [45] DBI_1.1.3 Rcpp_1.0.9
62 | [47] mzR_2.30.0 xtable_1.8-4
63 | [49] clue_0.3-62 preprocessCore_1.58.0
64 | [51] MsCoreUtils_1.8.0 htmlwidgets_1.5.4
65 | [53] RColorBrewer_1.1-3 ellipsis_0.3.2
66 | [55] farver_2.1.1 pkgconfig_2.0.3
67 | [57] XML_3.99-0.11 sass_0.4.2
68 | [59] dbplyr_2.2.1 utf8_1.2.2
69 | [61] labeling_0.4.2 tidyselect_1.2.0
70 | [63] rlang_1.0.6 later_1.3.0
71 | [65] munsell_0.5.0 cellranger_1.1.0
72 | [67] tools_4.2.1 cachem_1.0.6
73 | [69] cli_3.4.1 generics_0.1.3
74 | [71] broom_1.0.1 fdrtool_1.2.17
75 | [73] evaluate_0.17 fastmap_1.1.0
76 | [75] mzID_1.34.0 yaml_2.3.6
77 | [77] knitr_1.40 fs_1.5.2
78 | [79] ncdf4_1.19 mime_0.12
79 | [81] xml2_1.3.3 brio_1.1.3
80 | [83] compiler_4.2.1 rstudioapi_0.14
81 | [85] png_0.1-7 affyio_1.66.0
82 | [87] reprex_2.0.2 bslib_0.4.0
83 | [89] stringi_1.7.8 highr_0.9
84 | [91] MSnbase_2.22.0 lattice_0.20-45
85 | [93] ProtGenerics_1.28.0 Matrix_1.5-1
86 | [95] tmvtnorm_1.5 vctrs_0.4.2
87 | [97] pillar_1.8.1 norm_1.0-10.0
88 | [99] lifecycle_1.0.3 BiocManager_1.30.18
89 | [101] jquerylib_0.1.4 MALDIquant_1.21
90 | [103] GlobalOptions_0.1.2 bitops_1.0-7
91 | [105] httpuv_1.6.6 R6_2.5.1
92 | [107] pcaMethods_1.88.0 affy_1.74.0
93 | [109] renv_0.16.0 promises_1.2.0.1
94 | [111] codetools_0.2-18 MASS_7.3-58.1
95 | [113] assertthat_0.2.1 fontawesome_0.3.0
96 | [115] withr_2.5.0 GenomeInfoDbData_1.2.8
97 | [117] parallel_4.2.1 hms_1.1.2
98 | [119] rmarkdown_2.17 googledrive_2.0.0
99 | [121] Cairo_1.6-0 lubridate_1.8.0
100 | [123] tinytex_0.42
101 |
102 |
--------------------------------------------------------------------------------
/docs/CV_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/CV_plot.png
--------------------------------------------------------------------------------
/docs/PCA_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/PCA_plot.png
--------------------------------------------------------------------------------
/docs/Protein_number.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/Protein_number.png
--------------------------------------------------------------------------------
/docs/Protein_overlap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/Protein_overlap.png
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/docs/correlation_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/correlation_plot.png
--------------------------------------------------------------------------------
/docs/heatmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/heatmap.png
--------------------------------------------------------------------------------
/docs/imputation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/imputation.png
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | Differential expression analysis of label-free proteomics data
2 | ===========================================================
3 |
4 | # Introduction
5 | ------------
6 |
7 | This tool is developed to automate downstream statistical analysis of
8 | quantitative proteomics (label-free) datasets generated by MaxQuant.
9 |
10 | # Input
11 | -----
12 |
13 | - MaxQuant **proteinGroups.txt** file that **Must** contain *Gene
14 | name* and *Protein IDs* column.
15 | - An **experiment design table**: A tab separated file **only**
16 | containing **three** columns namely: "*label*", "*condition*",
17 | "*replicate*". The column names are **case sensitive**
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 | H1 |
30 | CD34High |
31 | 1 |
32 |
33 |
34 | H2 |
35 | CD34High |
36 | 2 |
37 |
38 |
39 | H3 |
40 | CD34High |
41 | 3 |
42 |
43 |
44 | H4 |
45 | CD34High |
46 | 4 |
47 |
48 |
49 | L1 |
50 | CD34Low |
51 | 1 |
52 |
53 |
54 | L2 |
55 | CD34Low |
56 | 2 |
57 |
58 |
59 | L3 |
60 | CD34Low |
61 | 3 |
62 |
63 |
64 | L4 |
65 | CD34Low |
66 | 4 |
67 |
68 |
69 |
70 |
71 | **Note:** The label column must match the labels present in **LFQ
72 | Intensity** columns of **proteinGroups.txt** file. For example, include
73 | **"H1"** in label column if **"LFQ Intensity H1"** column present in
74 | your proteinGroups file.
75 |
76 | ## Advanced Options
77 | ----------------
78 |
79 | #### Significant protein filtering criteria
80 |
81 | - Adjusted p-value cutoff: default is **0.05**
82 | - Log fold change cutoff: default is **1**
83 |
84 | #### Missing value imputation options
85 |
86 | - **Perseus-type:** This method is based on popular missing value
87 | imputation procedure implemented in *Perseus* software by MaxQuant
88 | team. The missing values are replaced by random numbers drawn from a
89 | normal distribution of *1.8* standard deviation down shift and with a
90 | width of *0.3* of each sample.
91 | - **bpca:** Bayesian missing value imputation
92 | - **knn:** Missing values replace by nearest neighbor averaging
93 | technique
94 | - **QRILC:** A missing data imputation method that performs the
95 | imputation of left-censored missing data using random draws from a
96 | truncated distribution with parameters estimated using quantile
97 | regression.
98 | - **MinDet:** Performs the imputation of left-censored missing data
99 | using a deterministic minimal value approach. Considering a
100 | expression data with n samples and p features, for each sample, the
101 | missing entries are replaced with a minimal value observed in that
102 | sample. The minimal value observed is estimated as being the q-th
103 | quantile (default q = 0.01) of the observed values in that sample.
104 | - **MinProb:** Performs the imputation of left-censored missing data
105 | by random draws from a Gaussian distribution centered to a minimal
106 | value. Considering an expression data matrix with n samples and p
107 | features, for each sample, the mean value of the Gaussian
108 | distribution is set to a minimal observed value in that sample. The
109 | minimal value observed is estimated as being the q-th quantile
110 | (default q = 0.01) of the observed values in that sample. The
111 | standard deviation is estimated as the median of the feature
112 | standard deviations. Note that when estimating the standard
113 | deviation of the Gaussian distribution, only the peptides/proteins
114 | which present more than 50% recorded values are considered.
115 | - **min:** Replaces the missing values by the smallest non-missing
116 | value in the data.
117 | - **zero:** Replaces the missing values by **0**.
118 |
119 | #### False Discovery Rate (FDR) correction option
120 |
121 | - Benjamin Hochberg (BH) method
122 | - t-statistics correction: Implemented in
123 | [fdrtools](http://strimmerlab.org/software/fdrtool/)
124 |
125 | #### Data pre-filtering criteria
126 |
127 | Following data-cleaning criteria is applied before performing
128 | differential expression analysis.
129 |
130 | - Remove potential contaminants
131 | - Remove reverse sequences
132 | - Remove proteins identified only by sites
133 | - Remove proteins identified/quantified by a single Razor or unique
134 | peptide
135 | - Remove observation with high proportion of missing values (intensity
136 | values must be present at least 2 out of three replicates)
137 |
138 | #### Differential expression analysis
139 |
140 | Protein-wise linear models combined with empirical Bayes statistics are
141 | used for the differential expression analysis. We use a *Bioconductor*
142 | package *limma* to carry out the analysis using automatically generates
143 | the contrasts from experiment design table provided by the user allowing
144 | the generation of results for all possible comparisons. It also take
145 | into account user defined cutoffs to filter significantly different
146 | proteins.
147 |
148 | Output
149 | ------
150 |
151 | #### Result table
152 |
153 | - **LFQ Results Table:** Includes names (Gene names), Protein Ids, Log
154 | fold changes/ ratios (each pairwise comparisons), Adjusted
155 | *p-values* (applying FDR corrections), *p-values*, Boolean values
156 | for significance, average protein intensity (log transformed) in
157 | each sample.
158 |
159 | #### Result Plots
160 |
161 | 1. **PCA plot**: A Principal Component Analysis(PCA) is a technique
162 | used to emphasize variation and bring out strong patterns in a
163 | dataset. In brief, the more similar 2 samples are, the closer they
164 | cluster together. Of course, this means that biological replicates
165 | (and in particular technical replicates) should cluster tightly
166 | together. For further information, here are a few links, which
167 | explains the principals of PCAs:
168 | [Info](ttp://ordination.okstate.edu/PCA.htm) and [Basic
169 | introduction](http://setosa.io/ev/principal-component-analysis/)
170 |
171 | 
172 |
173 | 1. **Heatmap**: The heatmap representation gives an overview of all
174 | significant/differentially expressed proteins (rows) in all samples
175 | (columns). This visualization allows the identification of general
176 | trends such as if one sample or replicate is highly different
177 | compared to the others and might be considered as an outlier.
178 | Additionally, the hierarchical clustering of samples (columns)
179 | indicates how related the different samples are and
180 | hierarchical clustering of proteins (rows) identifies similarly
181 | behaving proteins. This analysis divides differentially expressed
182 | proteins into *six* clusters/groups. User also have option to
183 | download protein information from individual cluster.
184 |
185 | 
186 |
187 | 1. **Volcano plot**: A volcano plot is generated for each pairwise
188 | comparison. It is a graphical visualization by plotting the “Fold
189 | Change (Log2)” on the x-axis versus the –log10 of the “ *p-value*”
190 | on the y-axis. Interesting candidate proteins are located in the
191 | left and right upper quadrant. User can toggle the display name
192 | checkbox to highlight names of differentially expressed proteins or
193 | use 'adjusted *p-value*' as y-axis. Importantly, user can highlight
194 | protein or their interest (colored maroon) by selecting the row from
195 | "**LFQ Results Table**". This highlighted plot can be downloaded
196 | using " *Save Highlighted Plot*" button.
197 |
198 | 
199 |
200 | #### QC plots
201 |
202 | 1. **Sample Correlation Plot**: A correlation matrix is plotted as a
203 | heatmap to visualize the Pearson correlation coefficients between
204 | the different samples. 
205 | 2. **Sample CVs Plots**: A plot representing distribution of protein
206 | level coefficient of variation for each condition. Each plot also
207 | contains a vertical line representing median CVs percentage within
208 | that condition. 
209 | 3. **Protein Numbers**: A bar-plot representing number of proteins
210 | identified and quantified in each sample.
211 | 
212 | 4. **Sample coverage**: A plot highlighting overlap between identified
213 | proteins across all samples in the experiment.
214 | 
215 | 5. **Normalization**: Two plots representing the effect of variant
216 | stabilizing normalization (vsn) method on protein intensity
217 | distribution in each sample. **Note**: As MaxQuant protein intensity
218 | is already been normalized using MaxLFQ algorithm, further
219 | normalisation is not done during data analysis. This plot is just
220 | for visualisation purpose.
221 | 6. **Missing values- Quant**: To check whether missing values are
222 | biased to lower intense proteins, the densities and cumulative
223 | fractions are plotted for proteins with and without missing values.
224 | 
225 | 7. **Missing values- Heatmap**: To explore the pattern of missing
226 | values in the data, a heatmap is plotted indicating whether values
227 | are missing (0) or not (1). Only proteins with at least one missing
228 | value are visualized. 
229 | 8. **Imputation**: A density plot of protein intensity (log2)
230 | distribution for each condition after and before missing value
231 | imputation being performed. 
232 | 9. ***p-value* Histogram**: A histogram of p-value distribution for all
233 | the proteins across all pairwise comparison.
234 | 
235 |
236 | ## Download options
237 |
238 | - **Download tables** (csv format)
239 |
240 | 1. Results: Same as *LFQ Results Table*
241 | 2. Unimputed data matrix: Original protein intensities before
242 | imputation in each sample.
243 | 3. Imputed data matrix: Protein intensities after performing selected
244 | imputation method
245 | 4. Full results: Combined table of all above data outputs i.e. with and
246 | without imputation information, along with fold change and p-values.
247 |
248 | - **Download Report** (word format) A summary report document
249 | including some statistics and plots.
250 |
251 | - **Download Plots** (PDF format) A PDF document containing all the
252 | plots generated during the analysis.
253 |
--------------------------------------------------------------------------------
/docs/missing_heatmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/missing_heatmap.png
--------------------------------------------------------------------------------
/docs/missing_quant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/missing_quant.png
--------------------------------------------------------------------------------
/docs/pvalue_hist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/pvalue_hist.png
--------------------------------------------------------------------------------
/docs/volcano_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/docs/volcano_plot.png
--------------------------------------------------------------------------------
/global.R:
--------------------------------------------------------------------------------
1 | VERSION <- "v1.3"
2 |
3 | library("SummarizedExperiment")
4 | library("tidyverse")
5 | library("DEP")
6 | library("testthat")
7 | library("shiny")
8 | library("shinydashboard")
9 | library("shinyjs")
10 | library("shinyalert")
11 | library("ComplexHeatmap")
12 | library("limma")
13 | library("DT")
14 | library("ggrepel")
15 | library("httr")
16 | library("rjson")
17 | library("svglite")
18 | library("shinycssloaders")
19 | library("shiny.info")
20 | source("R/functions.R")
21 | source("R/volcano_function.R")
22 | source("R/tests.R")
23 | source("R/demo_functions.R")
24 | source("R/enrichment_functions.R")
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/google_analytics-GA4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/google_analytics.js:
--------------------------------------------------------------------------------
1 | // ============ NOTE =================
2 | // Users of this app are encouraged to keep this analytics script in the app directory
3 | // This will help developer track the usage for future funding persective.
4 |
5 | // Initial Tracking Code
6 | (function(i,s,o,g,r,a,m){
7 | i['GoogleAnalyticsObject']=r;
8 | i[r]=i[r] ||
9 | function(){
10 | (i[r].q=i[r].q||[]).push(arguments);
11 | },i[r].l=1*new Date();
12 | a=s.createElement(o),
13 | m=s.getElementsByTagName(o)[0];
14 | a.async=1;
15 | a.src=g;
16 | m.parentNode.insertBefore(a,m);
17 | })(window,document,'script',
18 | 'https://www.google-analytics.com/analytics.js','ga');
19 |
20 | ga('create', 'UA-66833365-2', 'auto');
21 | ga('send', 'pageview');
22 |
23 | // Event Tracking Code
24 | $(document).on('shiny:inputchanged', function(event) {
25 | if(event.name == 'bins' || event.name == 'col'){
26 | ga('send', 'event', 'input',
27 | 'updates', event.name, event.value);
28 | }
29 | });
30 |
31 | // User Tracking Code
32 | $(document).one('shiny:idle', function() {
33 | ga('set','userId', Shiny.user);
34 | });
35 |
--------------------------------------------------------------------------------
/shiny-server.conf:
--------------------------------------------------------------------------------
1 | # Instruct Shiny Server to run applications as the user "shiny"
2 | run_as shiny;
3 | http_keepalive_timeout 600;
4 | preserve_logs true;
5 |
6 | # Define a server that listens on port 3838
7 | server {
8 | listen 3838;
9 |
10 | # Define a location at the base URL
11 | location / {
12 |
13 | # Host the directory of Shiny Apps stored in this directory
14 | site_dir /srv/shiny-server;
15 |
16 | # Log all Shiny output to files in this directory
17 | log_dir /var/log/shiny-server;
18 |
19 | # When a user visits the base URL rather than a particular application,
20 | # an index of the applications available in this directory will be shown.
21 | directory_index on;
22 | disable_websockets off;
23 | app_init_timeout 1800;
24 | app_idle_timeout 1800;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ui.R:
--------------------------------------------------------------------------------
1 | # Define UI for data upload app ----
2 | ui <- function(request){shinyUI(
3 | dashboardPage(
4 | skin = "blue",
5 | dashboardHeader(title = "LFQ-Analyst"),
6 | # disable = TRUE),# Disable title bar
7 | dashboardSidebar(
8 | useShinyalert(),
9 | sidebarMenu(
10 | id="tabs_selected",
11 | convertMenuItem(menuItem('Home', icon=icon("home"), selected = TRUE, tabName = "home"), tabName = "home"),
12 | convertMenuItem(menuItem("Analysis", tabName="analysis", icon=icon("flask"),
13 | #menuItem("Input Files", tabName="file", icon=icon("file"), #selected = TRUE,
14 | fileInput('file1',
15 | 'Upload MaxQuant ProteinGroups.txt',
16 | accept=c('text/csv',
17 | 'text/comma-separated-values,text/plain',
18 | '.csv')),
19 |
20 | fileInput('file2',
21 | 'Upload Experimental Design Matrix',
22 | accept=c('text/csv',
23 | 'text/comma-separated-values,text/plain',
24 | '.csv')),
25 |
26 |
27 | # ),
28 | tags$hr(),
29 | menuItem("Advanced Options",tabName="advanced", icon = icon("cogs"),
30 | numericInput("p",
31 | "Adjusted p-value cutoff",
32 | min = 0.0001, max = 0.1, value = 0.05),
33 | numericInput("lfc",
34 | "Log2 fold change cutoff",
35 | min = 0, max = 10, value = 1),
36 | checkboxInput("paired",
37 | "Paired test", FALSE),
38 |
39 | radioButtons("imputation",
40 | "Imputation type",
41 | choices = c("Perseus-type"="man", MsCoreUtils::imputeMethods())[1:9],
42 | selected = "man"),
43 |
44 | radioButtons("fdr_correction",
45 | "Type of FDR correction",
46 | choices = c("Benjamini Hochberg"="BH",
47 | "t-statistics-based"="fdrtool"
48 | ), selected= "BH"),
49 | checkboxInput("single_peptide",
50 | "Include single peptide identifications", FALSE),
51 | numericInput("k_number",
52 | "Number of clusters in heatmap",
53 | min = 1, max = 20, value = 6)
54 | ),
55 | tags$hr(),
56 | actionButton("analyze", "Start Analysis"),
57 | tags$hr(),
58 | p(a("Example LFQ data", target= "_blank",
59 | href="data/proteinGroups_example.txt",
60 | download="proteinGroups_example.txt")),
61 | p(a("Example Experimental Design file", target= "_blank",
62 | href="data/experimental_design_example.txt",
63 | download="experimental_design_example.txt"))
64 |
65 | #,
66 | #actionButton("load_data", "Load example data")
67 | ), tabName = 'analysis'),
68 |
69 | convertMenuItem(menuItem('Demo', icon=icon("eye"), tabName = "demo"), tabName = "demo"),
70 | convertMenuItem(menuItem('User Guide', icon=icon("question"),
71 | #href = "https://monashbioinformaticsplatform.github.io/LFQ-Analyst/",
72 | tabName = "info"), tabName = "info")
73 | )
74 | ), # sidebar close
75 |
76 | ################################################################
77 | ## DASHBOARD BODY
78 | ################################################################
79 |
80 | dashboardBody(
81 | useShinyjs(), #imp to use shinyjs functions
82 | tags$head(includeScript("google_analytics.js")),
83 | tags$head(includeHTML(("google_analytics-GA4.html"))),
84 |
85 | tags$head(
86 | tags$link(rel = "stylesheet", type = "text/css", href = "./css/custom.css")
87 | ),
88 |
89 | tags$style(
90 | ".box {
91 | border-top: none;
92 | box-shadow: 0 0px 0px rgb(0 0 0 / 10%);
93 | }"
94 | ),
95 |
96 | # Add logo to the body
97 | # tags$img(src="mbpf_logo.jpg",height=50, align="right"),
98 |
99 | ## Add tabItems
100 | # id="body",
101 | tabItems(
102 |
103 | tabItem(tabName = "home",
104 | fluidRow(
105 | box(
106 | title = "Important Updates",
107 | # h3("LFQ-Analyst: An easy-to-use interactive web-platform to analyze and visualize proteomics data
108 | # preprocessed with MaxQuant."),
109 | # tags$hr(),
110 | h4(tags$b("Analyst Suites")," Website available now"),
111 | h5(tags$ul(
112 | "Get access to additional Analyst Apps: ", tags$a(href = "https://analyst-suites.org/",
113 | target = "_blank", "https://analyst-suites.org/")
114 | )),
115 | # br(),
116 | h4(tags$b("Developer Version (recommended)")),
117 | h5(tags$ul(
118 | "Includes more features: ", tags$a(href = "https://analyst-suites.org/apps/lfq-analyst-dev/",
119 | target = "_blank", "LFQ-Analyst(Dev.)")
120 | )),
121 | # br(),
122 | h4(tags$b("Questions/Suggestions/Bug reports: ")),
123 | h5(tags$ul(
124 | "Leave comments to our GitHub: ", tags$a(href = "https://github.com/MonashBioinformaticsPlatform/LFQ-Analyst",
125 | target = "_blank", "here")
126 | )),
127 | width = 12,
128 | solidHeader = TRUE,
129 | status = "primary"
130 | ), # box 1 closed
131 | box(
132 | title = "Overview",
133 | h3("LFQ-Analyst: An easy-to-use interactive web-platform to analyze and visualize proteomics data
134 | preprocessed with MaxQuant."),
135 | p("LFQ-Analyst is an easy-to-use, interactive web application developed to perform
136 | differential expression analysis with “one click” and to visualize label-free quantitative proteomic
137 | datasets preprocessed with MaxQuant. LFQ-Analyst provides a wealth of user-analytic features
138 | and offers numerous publication-quality result output graphics and tables to facilitate statistical
139 | and exploratory analysis of label-free quantitative datasets. "),
140 | br(),
141 | HTML('
'),
142 | br(),
143 | h4("Sidebar tabs"),
144 | tags$ul(
145 | tags$li(tags$b("Analysis: "),"perform your own analysis"),
146 | tags$li(tags$b("Demo: "),"familiarise yourself with LFQ-Analyst by browsing through pre-analysed results"),
147 | tags$li(tags$b("User Guide: "), "download an in-depth manual")
148 | ),
149 | width = 12,
150 | solidHeader = TRUE,
151 | collapsed = TRUE,
152 | # collapsible = TRUE,
153 | status = "success"
154 | )#box 2 closed
155 | ) #fluidrow close
156 | ), # home tab close
157 | tabItem(tabName = "analysis",
158 | div(id="quickstart_info",
159 | fluidPage(
160 | box(
161 | title = "Getting Started",
162 | h3(tags$b(span("Quick Start", style="text-decoration:underline"))),
163 | tags$ul(
164 | tags$li("Upload your ", tags$b("proteinGroups.txt "), "generated by MaxQuant."),
165 | tags$li("Upload your ", tags$b(" experimental design "),"table. "),
166 |
167 | tags$li(tags$b("Optional: "),"Adjust the p-value cut-off, the log2 fold change cut-off,
168 | the imputation type, FDR correction method and/or number of clusters in heatmap
169 | in the", tags$b("Advanced Options")),
170 | tags$li("Press ", tags$b("'Start Analysis' ")),
171 | tags$li(tags$b("Hint: "), " Use the ", tags$b("User Guide ")," tab for a detailed explanation of inputs,
172 | advanced options and outputs"),
173 | tags$li(tags$b("Note: "), " The experimental design file is not the" , tags$b("'mqpar.xml' "),"file
174 | from MaxQuant. Use the example file template provided.")
175 | ),
176 | br(),
177 | HTML('
'),
178 | width = 12,
179 | solidHeader = TRUE,
180 | status = "danger"
181 | )
182 | )
183 | ), # QUICKSTART INFO CLOSE
184 | shinyjs::hidden(div(id="downloadbox",
185 | fluidRow(
186 | box(
187 | column(6,uiOutput("downloadTable"),offset = 1),
188 | column(4,uiOutput("downloadButton")), # make the button on same line
189 | width = 4),
190 |
191 | infoBoxOutput("significantBox",width = 4),
192 | box(
193 | column(5,uiOutput("downloadreport")), # offset for dist between buttons
194 | #tags$br(),
195 | #column(5,uiOutput('downloadPlots')),
196 | width = 4
197 | )
198 | ))), #close div and first row
199 |
200 | # align save button
201 | tags$style(type='text/css', "#downloadButton { width:100%; margin-top: 25px;}"),
202 | tags$style(type='text/css', "#downloadreport { width:100%; vertical-align- middle; margin-top: 25px;
203 | margin-bottom: 25px;}"),
204 | #tags$style(type='text/css', "#downloadPlots { width:100%; margin-top: 25px;}"),
205 |
206 | tags$br(), # Blank lines
207 | tags$br(),
208 |
209 | ## Data table and result plots box
210 | fluidRow(
211 | shinyjs::hidden(div(id="results_tab",
212 | box(
213 | title = "LFQ Results Table",
214 | DT::dataTableOutput("contents"),
215 | # actionButton("clear", "Deselect Rows"),
216 | actionButton("original", "Refresh Table"),
217 | width = 6,
218 | status = "success",
219 | #color=""
220 | solidHeader = TRUE
221 | ),
222 | # column(
223 | box(
224 | width= 6,
225 | collapsible = TRUE,
226 | #status="primary",
227 | #solidHeader=TRUE,
228 | tabBox(
229 | title = "Result Plots",
230 | width = 12,
231 | tabPanel(title = "Volcano plot",
232 | fluidRow(
233 | box(uiOutput("volcano_cntrst"), width = 5),
234 | box(numericInput("fontsize",
235 | "Font size",
236 | min = 0, max = 8, value = 4),
237 | width = 3),
238 | box(checkboxInput("check_names",
239 | "Display names",
240 | value = FALSE),
241 | checkboxInput("p_adj",
242 | "Adjusted p values",
243 | value = FALSE),
244 | width = 4),
245 | tags$p("Select protein from LFQ Results Table to highlight on the plot OR
246 | drag the mouse on plot to show expression of proteins in Table")
247 | #Add text line
248 | # tags$p("OR"),
249 | # tags$p("Drag the mouse on plot to show expression of proteins in Table")
250 | ),
251 |
252 | fluidRow(
253 | plotOutput("volcano", height = 600,
254 | # hover = "protein_hover"),
255 | #),
256 | # click = "protein_click"),
257 | brush = "protein_brush",
258 | click = "protein_click"),
259 | downloadButton('downloadVolcano', 'Save Highlighted Plot'),
260 | actionButton("resetPlot", "Clear Selection")
261 | #)),
262 | )),
263 | tabPanel(title= "Heatmap",
264 | fluidRow(
265 | plotOutput("heatmap", height = 600)
266 | ),
267 | fluidRow(
268 | box(numericInput("cluster_number",
269 | "Cluster to download",
270 | min=1, max=6, value = 1), width = 6),
271 | box(downloadButton('downloadCluster',"Save Cluster"),
272 | downloadButton('download_hm_svg', "Save svg"),
273 | width = 5),
274 | # align save button
275 | tags$style(type='text/css', "#downloadCluster {margin-top: 25px;}"),
276 | tags$style(type='text/css', "#download_hm_svg {margin-top: 25px;}")
277 | )
278 | ),
279 | tabPanel(title = "Protein Plot",
280 | fluidRow(
281 | box(radioButtons("type",
282 | "Plot type",
283 | choices = c("Box Plot"= "boxplot",
284 | "Violin Plot"="violin",
285 | "Interaction Plot"= "interaction",
286 | "Intensity Plot"="dot"
287 | ),
288 | selected = "boxplot",
289 | inline = TRUE),
290 | width = 12
291 | ),
292 | tags$p("Select one or more rows from LFQ Results Table to plot individual
293 | protein intesities across conditions and replicates")
294 | ),
295 | fluidRow(
296 | plotOutput("protein_plot"),
297 | downloadButton('downloadProtein', 'Download Plot')
298 | )
299 | )
300 | # verbatimTextOutput("protein_info"))
301 | )
302 | ) # box or column end
303 | ))),
304 |
305 | ## QC Box
306 | fluidRow(
307 | shinyjs::hidden(div(id="qc_tab",
308 | column(
309 | width=6,
310 | tabBox(title = "QC Plots", width = 12,
311 | tabPanel(title = "PCA Plot",
312 | plotOutput("pca_plot", height=600),
313 | downloadButton('download_pca_svg', "Save svg")
314 | ),
315 | tabPanel(title="Sample Correlation",
316 | plotOutput("sample_corr", height = 600),
317 | downloadButton('download_corr_svg', "Save svg")
318 | ),
319 | tabPanel(title= "Sample CVs",
320 | plotOutput("sample_cvs", height = 600),
321 | downloadButton('download_cvs_svg', "Save svg")
322 | ),
323 | tabPanel(title = "Protein Numbers",
324 | plotOutput("numbers", height = 600),
325 | downloadButton('download_num_svg', "Save svg")
326 | ),
327 |
328 | tabPanel(title = "Sample coverage",
329 | plotOutput("coverage", height = 600),
330 | downloadButton('download_cov_svg', "Save svg")
331 | ),
332 | tabPanel(title = "Normalization",
333 | plotOutput("norm", height = 600),
334 | downloadButton('download_norm_svg', "Save svg")
335 | ),
336 | # tabPanel(title = "Missing values - Quant",
337 | # plotOutput("detect", height = 600)
338 | # ),
339 | tabPanel(title = "Missing values - Heatmap",
340 | plotOutput("missval", height = 600),
341 | downloadButton('download_missval_svg', "Save svg")
342 | ),
343 | tabPanel(title = "Imputation",
344 | plotOutput("imputation", height = 600),
345 | downloadButton('download_imp_svg', "Save svg")
346 | )#,
347 | # tabPanel(title = "p-value Histogram",
348 | # plotOutput("p_hist", height = 600)
349 | # )
350 | ) # Tab box close
351 | ),
352 | column(
353 | width=6,
354 | tabBox(title = "Enrichment", width = 12,
355 | tabPanel(title="Gene Ontology",
356 | fluidRow(
357 | column(6,
358 | uiOutput("contrast")),
359 | column(6,
360 | selectInput("go_database", "GO database:",
361 | c("Molecular Function"="GO_Molecular_Function_2021",
362 | "Cellular Component"="GO_Cellular_Component_2021",
363 | "Biological Process"="GO_Biological_Process_2021"))
364 | ),
365 | column(12,actionButton("go_analysis", "Run Enrichment")),
366 | column(12,
367 | box(width = 12,uiOutput("spinner_go"),height = 400)
368 | ),
369 | column(12,downloadButton('downloadGO', 'Download Table'))
370 | )
371 | ),
372 | tabPanel(title= "Pathway enrichment",
373 | fluidRow(
374 | column(6,
375 | uiOutput("contrast_1")),
376 | column(6,
377 | selectInput("pathway_database", "Pathway database:",
378 | c("KEGG"="KEGG_2021_Human",
379 | "Reactome"="Reactome_2022"))
380 | ),
381 | column(12,actionButton("pathway_analysis", "Run Enrichment")),
382 | column(12,
383 | box(width = 12,uiOutput("spinner_pa"),height = 400)
384 | ),
385 | column(12,downloadButton('downloadPA', 'Download Table'))
386 | )
387 | )
388 |
389 | ) # Tab box close
390 | )
391 | ))) # fluidrow qc close
392 |
393 |
394 | #bookmarkButton()
395 | ), #analysis tab close
396 |
397 | tabItem(tabName = "info",
398 | fluidRow(
399 | box(
400 | title = "User Guide",
401 | h3("LFQ-Analyst: Manual"),
402 | # div(p(HTML(paste0('A detail online user manual can be accessed ',
403 | # a(href = 'https://monashbioinformaticsplatform.github.io/LFQ-Analyst/',
404 | # target='_blank', 'here'))))),
405 | div(p(HTML(paste0("A detailed user manual can be accessed",
406 | a(href = './LFQ-Analyst_manual.pdf',
407 | target='_blank', tags$b("here.")))))),
408 | h4("Contact Us"),
409 | p("For any feedback or question regarding LFQ-Analyst, please contact the
410 | Monash Proteomics and Metabolomics Platform:"),
411 | tags$ul(
412 | # tags$li("Anup Shah: anup.shah(at)monash.edu"),
413 | tags$li("Ralf Schittenhelm: ralf.schittenhelm(at)monash.edu"),
414 | tags$li("Haijian Zhang: hailey.zhang1(at)monash.edu")
415 | ),
416 |
417 | h4("How to Cite LFQ-Analyst?"),
418 |
419 | div(p(HTML(paste0("Please Cite: Shah AD, Goode RJA, Huang C, Powell DR, Schittenhelm RB.
420 | LFQ-Analyst: An easy-to-use interactive web-platform to analyze and
421 | visualize proteomics data preprocessed with MaxQuant. DOI:",
422 | a(href = 'https://pubs.acs.org/doi/10.1021/acs.jproteome.9b00496',
423 | target='_blank', tags$b("10.1021/acs.jproteome.9b00496")))))),
424 |
425 |
426 | h4("News and Updates"),
427 |
428 | tags$ul(
429 | tags$li("27-12-2021: LFQ-Analyst being accessed by more than 5000 users worldwide"),
430 | tags$li("30-09-2021: LFQ-Analyst being accessed by more than 4000 users worldwide"),
431 | tags$li("03-05-2021: LFQ-Analyst being accessed by more than 3000 users worldwide"),
432 | tags$li("24-02-2021: Correlation plot now use all protein expression data"),
433 | tags$li("25-11-2020: LFQ-Analyst being accessed by more than 2000 users worldwide"),
434 | tags$li("07-04-2020: LFQ-Analyst being accessed by more than 1000 users worldwide"),
435 | tags$li("03-01-2020: LFQ-Analyst manuscript published in volume 19 of JPR"),
436 | tags$li("28-10-2019: LFQ-Analyst paper published online in Journal of Proteome Research (JPR)"),
437 | tags$li("02-10-2019: Svg figures download feature added"),
438 | tags$li("09-09-2019: Paired test support added"),
439 | tags$li("09-09-2019: Option to include single peptide observations in the analysis"),
440 | tags$li("19-02-2019: LFQ-Analyst made public")
441 | ),
442 | width = 12,
443 | solidHeader = TRUE,
444 | status = "primary"
445 | ) #includeMarkdown("www/Info.md")
446 | )
447 | ),# info tab close
448 |
449 | tabItem(tabName = "demo",
450 | div(id="downloadbox_dm",
451 | fluidRow(
452 | box(
453 | column(6,uiOutput("downloadTable_dm"),offset = 1),
454 | column(4,uiOutput("downloadButton_dm")), # make the button on same line
455 | width = 4),
456 |
457 | infoBoxOutput("significantBox_dm",width = 4),
458 | box(
459 | column(5,uiOutput("downloadreport_dm")), # offset for dist between buttons
460 | #tags$br(),
461 | # column(5,uiOutput('downloadPlots_dm')),
462 | width = 4
463 | )
464 | )), #close div and first row
465 |
466 | # align save button
467 | tags$style(type='text/css', "#downloadButton_dm { width:100%; margin-top: 25px;}"),
468 | tags$style(type='text/css', "#downloadreport_dm { width:100%; margin-top: 25px; margin-bottom: 25px;}"),
469 | # tags$style(type='text/css', "#downloadPlots_dm { width:100%; margin-top: 25px;}"),
470 |
471 | tags$br(), # Blank lines
472 | tags$br(),
473 |
474 | ## Data table and result plots box
475 | fluidRow(
476 | div(id="results_tab_dm",
477 | box(
478 | title = "LFQ Results Table",
479 | DT::dataTableOutput("contents_dm"),
480 | # actionButton("clear", "Deselect Rows"),
481 | actionButton("original_dm", "Refresh Table"),
482 | width = 6,
483 | status = "success",
484 | #color=""
485 | solidHeader = TRUE
486 | ),
487 | # column(
488 | box(
489 | width= 6,
490 | collapsible = TRUE,
491 | #status="primary",
492 | #solidHeader=TRUE,
493 | tabBox(
494 | title = "Result Plots",
495 | width = 12,
496 | tabPanel(title = "Volcano plot",
497 | fluidRow(
498 | box(uiOutput("volcano_cntrst_dm"), width = 5),
499 | box(numericInput("fontsize_dm",
500 | "Font size",
501 | min = 0, max = 8, value = 4),
502 | width = 3),
503 | box(checkboxInput("check_names_dm",
504 | "Display names",
505 | value = FALSE),
506 | checkboxInput("p_adj_dm",
507 | "Adjusted p values",
508 | value = FALSE),
509 | width = 4),
510 | tags$p("Select protein from LFQ Results Table to highlight on the plot OR
511 | drag the mouse on plot to show expression of proteins in Table")
512 | #Add text line
513 | # tags$p("OR"),
514 | # tags$p("Drag the mouse on plot to show expression of proteins in Table")
515 | ),
516 |
517 | fluidRow(
518 | plotOutput("volcano_dm", height = 600,
519 | # hover = "protein_hover"),
520 | #),
521 | # click = "protein_click"),
522 | brush = "protein_brush_dm",
523 | click = "protein_click_dm"),
524 | downloadButton('downloadVolcano_dm', 'Save Highlighted Plot'),
525 | actionButton("resetPlot_dm", "Clear Selection")
526 | #)),
527 | )),
528 | tabPanel(title= "Heatmap",
529 | fluidRow(
530 | plotOutput("heatmap_dm", height = 600)
531 | ),
532 | fluidRow(
533 | box(numericInput("cluster_number_dm",
534 | "Cluster to download",
535 | min=1, max=6, value = 1), width = 6),
536 | box(downloadButton('downloadCluster_dm',"Save Cluster"),width = 3),
537 | # align save button
538 | tags$style(type='text/css', "#downloadCluster_dm {margin-top: 25px;}"),
539 | )
540 | ),
541 | tabPanel(title = "Protein Plot",
542 | fluidRow(
543 | box(radioButtons("type_dm",
544 | "Plot type",
545 | choices = c("Box Plot"= "boxplot",
546 | "Violin Plot"="violin",
547 | "Interaction Plot"= "interaction",
548 | "Intensity Plot"="dot"
549 | ),
550 | selected = "boxplot",
551 | inline = TRUE),
552 | width = 12
553 | ),
554 | tags$p("Select one or more rows from LFQ Results Table to plot individual
555 | protein intesities across conditions and replicates")
556 | ),
557 | fluidRow(
558 | plotOutput("protein_plot_dm"),
559 | downloadButton('downloadProtein_dm', 'Download Plot')
560 | )
561 | )
562 | # verbatimTextOutput("protein_info"))
563 | )
564 | ) # box or column end
565 | )),
566 |
567 | ## QC Box
568 | fluidRow(
569 | div(id="qc_tab_dm",
570 | column(
571 | width=6,
572 | tabBox(title = "QC Plots", width = 12,
573 | tabPanel(title = "PCA Plot",
574 | plotOutput("pca_plot_dm"), height=600),
575 | tabPanel(title="Sample Correlation",
576 | plotOutput("sample_corr_dm", height = 600)
577 | ),
578 | tabPanel(title= "Sample CVs",
579 | plotOutput("sample_cvs_dm", height = 600)
580 | ),
581 | tabPanel(title = "Protein Numbers",
582 | plotOutput("numbers_dm", height = 600)
583 | ),
584 |
585 | tabPanel(title = "Sample coverage",
586 | plotOutput("coverage_dm", height = 600)
587 | ),
588 | tabPanel(title = "Normalization",
589 | plotOutput("norm_dm", height = 600)
590 | ),
591 | # tabPanel(title = "Missing values - Quant",
592 | # plotOutput("detect_dm", height = 600)
593 | # ),
594 | tabPanel(title = "Missing values - Heatmap",
595 | plotOutput("missval_dm", height = 600)
596 | ),
597 | tabPanel(title = "Imputation",
598 | plotOutput("imputation_dm", height = 600)
599 | )#,
600 | # tabPanel(title = "p-value Histogram",
601 | # plotOutput("p_hist_dm", height = 600)
602 | # )
603 | ) # Tab box close
604 | ),
605 | column(
606 | width=6,
607 | tabBox(title = "Enrichment", width = 12,
608 | tabPanel(title="Gene Ontology",
609 | fluidRow(
610 | column(6,
611 | uiOutput("contrast_dm")
612 | ),
613 | column(6,
614 | selectInput("go_database_dm", "GO database:",
615 | c("Molecular Function"="GO_Molecular_Function_2021",
616 | "Cellular Component"="GO_Cellular_Component_2021",
617 | "Biological Process"="GO_Biological_Process_2021"))
618 | ),
619 | column(12,actionButton("go_analysis_dm", "Run Enrichment")),
620 | column(12,
621 | box(width = 12,uiOutput("spinner_go_dm"),height = 400)
622 | ),
623 | column(12,downloadButton('downloadGO_dm', 'Download Table'))
624 | )
625 |
626 | ),
627 | tabPanel(title= "Pathway enrichment",
628 | fluidRow(
629 | column(6,
630 | uiOutput("contrast_dm_1")
631 | ),
632 | column(6,
633 | selectInput("pathway_database_dm", "Pathway database:",
634 | c("KEGG"="KEGG_2021_Human",
635 | "Reactome"="Reactome_2022"))
636 | ),
637 | column(12,actionButton("pathway_analysis_dm", "Run Enrichment")),
638 | column(12,
639 | box(width = 12,uiOutput("spinner_pa_dm"),height = 400)
640 | ),
641 | column(12,downloadButton('downloadPA_dm', 'Download Table'))
642 | )
643 | ) #### Tab demo closed
644 |
645 | ) # Tab box close
646 | )
647 | )) # fluidrow qc close
648 | # tabItems(
649 | ) # Tab items close
650 |
651 | #)# info tab lose
652 | # )#tabitems close
653 | ),
654 | tags$footer(
655 | tags$p("Supported by: Monash Proteomics and Metabolomics Platform & Monash Bioinformatics Platform,
656 | Monash University"),
657 | align = "right"), # Dasbboardbody close
658 | shiny.info::version(position = "bottom right")
659 |
660 | ) #Dashboard page close
661 | )
662 | )#Shiny U Close
663 | }
664 |
--------------------------------------------------------------------------------
/www/CV_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/CV_plot.png
--------------------------------------------------------------------------------
/www/Info.Rmd:
--------------------------------------------------------------------------------
1 | ---
2 | title: "LFQ Analysis"
3 | output: md_document
4 | keep_md: true
5 | #runtime: shiny
6 | # rmdformats::material:
7 | # highlight: kate
8 | # output:
9 | # theme: cayman
10 | # prettydoc::html_pretty:
11 | # highlight: github
12 | # keep_md: true
13 | # editor_options:
14 | # chunk_output_type: inline
15 | ---
16 |
17 | ```{r knitr_init, echo=FALSE, cache=FALSE}
18 | library(knitr)
19 | library(rmdformats)
20 |
21 | ## Global options
22 | options(max.print="50")
23 | opts_chunk$set(echo=FALSE,
24 | cache=TRUE,
25 | prompt=FALSE,
26 | tidy=TRUE,
27 | comment=NA,
28 | message=FALSE,
29 | warning=FALSE)
30 | opts_knit$set(width=50)
31 | ```
32 |
33 | # Differential experssion analysis label free proteomics data
34 |
35 | ## Introduction
36 | This tool is developed to automate downstream statistical analysis of quantitative proteomics (label-free) datasets generated by MaxQuant.
37 |
38 | ## Input
39 | - MaxQuant **proteinGroups.txt** file that **Must** contain *Gene name* and _Protein IDs_ column.
40 | - An **experiment design table**: A tab separated file **only** containing **three** columns namely: "_label_", "_condition_", "_replicate_". The column names are **case sensitive**
41 |
42 |
43 | ```{r exp_design, echo=FALSE, results='asis'}
44 | exp_design<-read.delim("../data/exp_design_p10_0144.txt",
45 | sep = "\t")
46 | kable(exp_design[1:8,])
47 | ```
48 |
49 | |label |condition | replicate|
50 | |:--------|:------------|---------:|
51 | |H1 |CD34High | 1|
52 | |H2 |CD34High | 2|
53 | |H3 |CD34High | 3|
54 | |H4 |CD34High | 4|
55 | |L1 |CD34Low | 1|
56 | |L2 |CD34Low | 2|
57 | |L3 |CD34Low | 3|
58 | |L4 |CD34Low | 4|
59 |
60 |
61 |
62 | **Note:** The label column must match the lables present in **LFQ Intensity** columns of **proteinGroups.txt** file. For example, include **"H1"** in lable column if **"LFQ Intensity H1"** column present in your proteinGroups file.
63 |
64 | ## Advanced Options
65 |
66 | #### Significant protein filtering criteria
67 | - Adjusted p-value cutoff: default is **0.05**
68 | - Log fold change cutoff: default is **1**
69 |
70 | #### Missing value imputation options
71 | - **Perseus-type:** This method is based on popular missing value imputation procedure implemented in _Perseus_ software by MaxQuant team. The missing values are replaced by random numbers drawn from a normal distribution of _1.8_ standard devation down shift and with a width of _0.3_ of each sample.
72 | - **bpca:** Bayesian missing value imputation
73 | - **knn:** Missing values replace by nearest neighbour averaging technique
74 | - **QRILC:** A missing data imputation method that performs the imputation of left-censored missing data using random draws from a truncated distribution with parameters estimated using quantile regression.
75 | - **MinDet:** Performs the imputation of left-censored missing data using a deterministic minimal value approach. Considering a expression data with n samples and p features, for each sample, the missing entries are replaced with a minimal value observed in that sample. The minimal value observed is estimated as being the q-th quantile (default q = 0.01) of the observed values in that sample.
76 | - **MinProb:** Performs the imputation of left-censored missing data by random draws from a Gaussian distribution centred to a minimal value. Considering an expression data matrix with n samples and p features, for each sample, the mean value of the Gaussian distribution is set to a minimal observed value in that sample. The minimal value observed is estimated as being the q-th quantile (default q = 0.01) of the observed values in that sample. The standard deviation is estimated as the median of the feature standard deviations. Note that when estimating the standard deviation of the Gaussian distribution, only the peptides/proteins which present more than 50% recorded values are considered.
77 | - **min:** Replaces the missing values by the smallest non-missing value in the data.
78 | - **zero:** Replaces the missing values by **0**.
79 |
80 | #### False Discovery Rate (FDR) correction option
81 | - Benjamin Hocheberg (BH) method
82 | - t-statistics correction: Implemented in [fdrtools](http://strimmerlab.org/software/fdrtool/)
83 |
84 |
85 | #### Data pre-filtering criteria
86 | Following data-cleaning criteria is applied before performing differential experssion analysis.
87 |
88 | - Remove potential contaminants
89 | - Remove reverse sequences
90 | - Remove proteins identified only by sites
91 | - Remove proteins identified/quantified by a single Razor or unique peptide
92 | - Remove observation with high proportion of missing values (intensity values must be present
93 | at least 2 out of three replicates)
94 |
95 | #### Differential expression analysis
96 | Protein-wise linear models combined with empirical Bayes statistics are used for the differential expression analysis. We use a _bioconductor_ package _limma_ to carry out the analysis using automatically generates the contrasts from experiment design table provided by the user allowing the generation of results for all possible comparisons. It also take into account user defined cutoffs to filter significantly different proteins.
97 |
98 | ## Output
99 |
100 | #### Result table
101 | - **LFQ Results Table:** Includes names (Gene names), Protein Ids, Log fold changes/ ratios (each pairwise comparisons), Adjusted _p-values_ (applying FDR corrections), _p-values_, boolean values for significance, average protein intensity (log transformed) in each sample.
102 |
103 | #### Result Plots
104 | 1. **PCA plot**: A Principal Componant Analysis(PCA) is a technique used to emphasize variation and bring out strong patterns in a dataset. In brief, the more similar 2 samples are, the closer they cluster together. Of course, this means that biological replicates (and in particular technical replicates) should cluster tightly together. For further information, here are a few links, which explains the principals of PCAs: [Info](ttp://ordination.okstate.edu/PCA.htm) and [Basic introduction](http://setosa.io/ev/principal-component-analysis/)
105 |
106 | 
107 |
108 |
109 | 2. **Heatmap**: The heatmap representation gives an overview of all significant/differentially expressed proteins (rows) in all samples (columns). This visualization allows the identfication of general trends such as if one sample or replicate is highly different compared to the others and might be considerd as an outlier. Additionally, the hierarchical clustering of samples (columns) indicates how related the different samples are and hierarchicalclustering of proteins (rows) identifies similarly behaving proteins. This analysis divides differencially expressed proteins into _six_ clusters/groups. User also have option to download protein information from individual cluster.
110 |
111 | 
112 |
113 | 3. **Volcano plot**: A volcano plot is generated for each pairwise comparison. It is a graphical visualization by plotting the “Fold Change (Log2)” on the x-axis versus the –log10 of the “ _p-value_” on the y-axis. Interesting candidate proteins are located in the left and right upper quadrant. User can toggle the display name checkbox to highlight names of differencially expressed proteins or use 'adjusted _p-value_' as y-axis. Importantly, user can highlight protein or their interest (colored moroon) by selecting the row from "**LFQ Results Table**". This highlighted plot can be downloaded using " _Save Highlited Plot_" button.
114 |
115 | 
116 |
117 | #### QC plots
118 | 1. **Sample Correlation Plot**: A correlation matrix is plotted as a heatmap to visualize the Pearson correlation coefficients between the different samples.
119 | 
120 | 2. **Sample CVs Plots**: A plot representing distribution of protein level coefficient of variation for each condition. Each plot also contains a vertical line representing median CVs percentage withing that condition.
121 | 
122 | 3. **Protein Numbers**: A bar-plot representing number of proteins identified and quantified in each sample.
123 | 
124 | 4. **Sample coverage**: A plot highlighting overlap between identified proteins across all samples in the experiment.
125 | 
126 | 5. **Normalization**: Two plots representing the effect of variant stabilising normalisation (vsn) method on protein intensity distribution in each sample. **Note**: As MaxQuant protein intensity is already been normalised using MaxLFQ algorithm, further normalisation is not done during data analysis. This plot is just for visualisation puporse.
127 | 6. **Missing values- Quant**: To check whether missing values are biased to lower intense proteins, the densities and cumulative fractions are plotted for proteins with and without missing values.
128 | 
129 | 7. **Missing values- Heatmap**: To explore the pattern of missing values in the data, a heatmap is plotted indicating whether values are missing (0) or not (1). Only proteins with at least one missing value are visualized.
130 | 
131 | 8. **Imputation**: A desity plot of protein intensity (log2) distrubution for each condition after and before missing value imputation being performed.
132 | 
133 | 9. **_p-value_ Histogram**: A histogram of p-value distribution for all the proteins across all pairwise comparison.
134 | 
135 |
136 |
137 |
138 | #### Download options
139 |
140 | - **Download tables** (csv format)
141 | 1. Results: Same as _LFQ Results Table_
142 | 2. Unimputed data matrix: Original protein intensities before imputation in each sample.
143 | 3. Imputed data matrix: Protein intensities after performing selected imputaion method
144 | 4. Full results: Combined table of all above data outputs i.e. with and without imputation information along with fold change and p-values.
145 |
146 | - **Download Report** (word format)
147 | A summary report document including some statistics and plots.
148 |
149 | - **Download Plots** (PDF format)
150 | A PDF document containing all the plots generated during the analysis.
151 |
152 |
--------------------------------------------------------------------------------
/www/Info.md:
--------------------------------------------------------------------------------
1 | Differential experssion analysis label free proteomics data
2 | ===========================================================
3 |
4 | # Introduction
5 | ------------
6 |
7 | This tool is developed to automate downstream statistical analysis of
8 | quantitative proteomics (label-free) datasets generated by MaxQuant.
9 |
10 | # Input
11 | -----
12 |
13 | - MaxQuant **proteinGroups.txt** file that **Must** contain *Gene
14 | name* and *Protein IDs* column.
15 | - An **experiment design table**: A tab separated file **only**
16 | containing **three** columns namely: "*label*", "*condition*",
17 | "*replicate*". The column names are **case sensitive**
18 |
19 |
20 |
21 |
26 |
27 |
28 |
29 | H1 |
30 | CD34High |
31 | 1 |
32 |
33 |
34 | H2 |
35 | CD34High |
36 | 2 |
37 |
38 |
39 | H3 |
40 | CD34High |
41 | 3 |
42 |
43 |
44 | H4 |
45 | CD34High |
46 | 4 |
47 |
48 |
49 | L1 |
50 | CD34Low |
51 | 1 |
52 |
53 |
54 | L2 |
55 | CD34Low |
56 | 2 |
57 |
58 |
59 | L3 |
60 | CD34Low |
61 | 3 |
62 |
63 |
64 | L4 |
65 | CD34Low |
66 | 4 |
67 |
68 |
69 |
70 |
71 | **Note:** The label column must match the lables present in **LFQ
72 | Intensity** columns of **proteinGroups.txt** file. For example, include
73 | **"H1"** in lable column if **"LFQ Intensity H1"** column present in
74 | your proteinGroups file.
75 |
76 | ## Advanced Options
77 | ----------------
78 |
79 | #### Significant protein filtering criteria
80 |
81 | - Adjusted p-value cutoff: default is **0.05**
82 | - Log fold change cutoff: default is **1**
83 |
84 | #### Missing value imputation options
85 |
86 | - **Perseus-type:** This method is based on popular missing value
87 | imputation procedure implemented in *Perseus* software by MaxQuant
88 | team. The missing values are replaced by random numbers drawn from a
89 | normal distribution of *1.8* standard devation down shift and with a
90 | width of *0.3* of each sample.
91 | - **bpca:** Bayesian missing value imputation
92 | - **knn:** Missing values replace by nearest neighbour averaging
93 | technique
94 | - **QRILC:** A missing data imputation method that performs the
95 | imputation of left-censored missing data using random draws from a
96 | truncated distribution with parameters estimated using quantile
97 | regression.
98 | - **MinDet:** Performs the imputation of left-censored missing data
99 | using a deterministic minimal value approach. Considering a
100 | expression data with n samples and p features, for each sample, the
101 | missing entries are replaced with a minimal value observed in that
102 | sample. The minimal value observed is estimated as being the q-th
103 | quantile (default q = 0.01) of the observed values in that sample.
104 | - **MinProb:** Performs the imputation of left-censored missing data
105 | by random draws from a Gaussian distribution centred to a minimal
106 | value. Considering an expression data matrix with n samples and p
107 | features, for each sample, the mean value of the Gaussian
108 | distribution is set to a minimal observed value in that sample. The
109 | minimal value observed is estimated as being the q-th quantile
110 | (default q = 0.01) of the observed values in that sample. The
111 | standard deviation is estimated as the median of the feature
112 | standard deviations. Note that when estimating the standard
113 | deviation of the Gaussian distribution, only the peptides/proteins
114 | which present more than 50% recorded values are considered.
115 | - **min:** Replaces the missing values by the smallest non-missing
116 | value in the data.
117 | - **zero:** Replaces the missing values by **0**.
118 |
119 | #### False Discovery Rate (FDR) correction option
120 |
121 | - Benjamin Hocheberg (BH) method
122 | - t-statistics correction: Implemented in
123 | [fdrtools](http://strimmerlab.org/software/fdrtool/)
124 |
125 | #### Data pre-filtering criteria
126 |
127 | Following data-cleaning criteria is applied before performing
128 | differential experssion analysis.
129 |
130 | - Remove potential contaminants
131 | - Remove reverse sequences
132 | - Remove proteins identified only by sites
133 | - Remove proteins identified/quantified by a single Razor or unique
134 | peptide
135 | - Remove observation with high proportion of missing values (intensity
136 | values must be present at least 2 out of three replicates)
137 |
138 | #### Differential expression analysis
139 |
140 | Protein-wise linear models combined with empirical Bayes statistics are
141 | used for the differential expression analysis. We use a *bioconductor*
142 | package *limma* to carry out the analysis using automatically generates
143 | the contrasts from experiment design table provided by the user allowing
144 | the generation of results for all possible comparisons. It also take
145 | into account user defined cutoffs to filter significantly different
146 | proteins.
147 |
148 | Output
149 | ------
150 |
151 | #### Result table
152 |
153 | - **LFQ Results Table:** Includes names (Gene names), Protein Ids, Log
154 | fold changes/ ratios (each pairwise comparisons), Adjusted
155 | *p-values* (applying FDR corrections), *p-values*, boolean values
156 | for significance, average protein intensity (log transformed) in
157 | each sample.
158 |
159 | #### Result Plots
160 |
161 | 1. **PCA plot**: A Principal Componant Analysis(PCA) is a technique
162 | used to emphasize variation and bring out strong patterns in a
163 | dataset. In brief, the more similar 2 samples are, the closer they
164 | cluster together. Of course, this means that biological replicates
165 | (and in particular technical replicates) should cluster tightly
166 | together. For further information, here are a few links, which
167 | explains the principals of PCAs:
168 | [Info](ttp://ordination.okstate.edu/PCA.htm) and [Basic
169 | introduction](http://setosa.io/ev/principal-component-analysis/)
170 |
171 | 
172 |
173 | 1. **Heatmap**: The heatmap representation gives an overview of all
174 | significant/differentially expressed proteins (rows) in all samples
175 | (columns). This visualization allows the identfication of general
176 | trends such as if one sample or replicate is highly different
177 | compared to the others and might be considerd as an outlier.
178 | Additionally, the hierarchical clustering of samples (columns)
179 | indicates how related the different samples are and
180 | hierarchicalclustering of proteins (rows) identifies similarly
181 | behaving proteins. This analysis divides differncially expressed
182 | proteins into *six* clusters/groups. User also have option to
183 | download protein information from individual cluster.
184 |
185 | 
186 |
187 | 1. **Volcano plot**: A volcano plot is generated for each pairwise
188 | comparison. It is a graphical visualization by plotting the “Fold
189 | Change (Log2)” on the x-axis versus the –log10 of the “ *p-value*”
190 | on the y-axis. Interesting candidate proteins are located in the
191 | left and right upper quadrant. User can toggle the display name
192 | checkbox to highlight names of differencially expressed proteins or
193 | use 'adjusted *p-value*' as y-axis. Importantly, user can highlight
194 | protein or their interest (colored moroon) by selecting the row from
195 | "**LFQ Results Table**". This highlighted plot can be downloaded
196 | using " *Save Highlited Plot*" button.
197 |
198 | 
199 |
200 | #### QC plots
201 |
202 | 1. **Sample Correlation Plot**: A correlation matrix is plotted as a
203 | heatmap to visualize the Pearson correlation coefficients between
204 | the different samples. 
205 | 2. **Sample CVs Plots**: A plot representing distribution of protein
206 | level coefficient of variation for each condition. Each plot also
207 | contains a vertical line representing median CVs percentage withing
208 | that condition. 
209 | 3. **Protein Numbers**: A bar-plot representing number of proteins
210 | identified and quantified in each sample.
211 | 
212 | 4. **Sample coverage**: A plot highlighting overlap between identified
213 | proteins across all samples in the experiment.
214 | 
215 | 5. **Normalization**: Two plots representing the effect of variant
216 | stabilising normalisation (vsn) method on protein intensity
217 | distribution in each sample. **Note**: As MaxQuant protein intensity
218 | is already been normalised using MaxLFQ algorithm, further
219 | normalisation is not done during data analysis. This plot is just
220 | for visualisation puporse.
221 | 6. **Missing values- Quant**: To check whether missing values are
222 | biased to lower intense proteins, the densities and cumulative
223 | fractions are plotted for proteins with and without missing values.
224 | 
225 | 7. **Missing values- Heatmap**: To explore the pattern of missing
226 | values in the data, a heatmap is plotted indicating whether values
227 | are missing (0) or not (1). Only proteins with at least one missing
228 | value are visualized. 
229 | 8. **Imputation**: A desity plot of protein intensity (log2)
230 | distrubution for each condition after and before missing value
231 | imputation being performed. 
232 | 9. ***p-value* Histogram**: A histogram of p-value distribution for all
233 | the proteins across all pairwise comparison.
234 | 
235 |
236 | ## Download options
237 |
238 | - **Download tables** (csv format)
239 |
240 | 1. Results: Same as *LFQ Results Table*
241 | 2. Unimputed data matrix: Original protein intensities before
242 | imputation in each sample.
243 | 3. Imputed data matrix: Protein intensities after performing selected
244 | imputaion method
245 | 4. Full results: Combined table of all above data outputs i.e. with and
246 | without imputation information along with fold change and p-values.
247 |
248 | - **Download Report** (word format) A summary report document
249 | including some statistics and plots.
250 |
251 | - **Download Plots** (PDF format) A PDF document containing all the
252 | plots generated during the analysis.
253 |
--------------------------------------------------------------------------------
/www/Info_cache/html/__packages:
--------------------------------------------------------------------------------
1 | base
2 | methods
3 | datasets
4 | utils
5 | grDevices
6 | graphics
7 | stats
8 | knitr
9 | rmdformats
10 |
--------------------------------------------------------------------------------
/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.RData
--------------------------------------------------------------------------------
/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdb
--------------------------------------------------------------------------------
/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/html/exp_design_b71c6ebe27cac9dec05c8ffe7432463e.rdx
--------------------------------------------------------------------------------
/www/Info_cache/markdown_strict/__packages:
--------------------------------------------------------------------------------
1 | base
2 | methods
3 | datasets
4 | utils
5 | grDevices
6 | graphics
7 | stats
8 | knitr
9 | rmdformats
10 |
--------------------------------------------------------------------------------
/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.RData:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.RData
--------------------------------------------------------------------------------
/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.rdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.rdb
--------------------------------------------------------------------------------
/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.rdx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Info_cache/markdown_strict/exp_design_ba255ed02e26d1f4a5a14728288efd24.rdx
--------------------------------------------------------------------------------
/www/LFQ-Analyst_manual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/LFQ-Analyst_manual.pdf
--------------------------------------------------------------------------------
/www/LFQ-Analyst_report.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/LFQ-Analyst_report.pdf
--------------------------------------------------------------------------------
/www/LFQ_analyst.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/LFQ_analyst.png
--------------------------------------------------------------------------------
/www/PCA_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/PCA_plot.png
--------------------------------------------------------------------------------
/www/Protein_number.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Protein_number.png
--------------------------------------------------------------------------------
/www/Protein_overlap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/Protein_overlap.png
--------------------------------------------------------------------------------
/www/correlation_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/correlation_plot.png
--------------------------------------------------------------------------------
/www/css/custom.css:
--------------------------------------------------------------------------------
1 | /*.main-header .logo {
2 | font-family: "Georgia", Times, "Times New Roman", serif;
3 | font-weight: bold;
4 | font-size: 24px;
5 | }
6 | */
7 |
8 | /* navbar (rest of the header) */
9 | .skin-blue .main-header .logo {
10 | background-color: #4054b3;
11 | }
12 |
13 | .skin-blue .main-header .logo:hover {
14 | background-color: #4054b3;
15 | }
16 |
17 | .skin-blue .main-header .navbar {
18 | background-color: #4054b3;
19 | }
20 |
21 |
22 | .box.box-solid.box-primary>.box-header {
23 | color:#fff;
24 | background:#D32D41
25 | }
26 |
27 | .box.box-solid.box-primary{
28 | border-bottom-color:#D32D41;
29 | border-left-color:#D32D41;
30 | border-right-color:#D32D41;
31 | border-top-color:#D32D41;
32 | }
33 |
34 | .box.box-solid.box-danger>.box-header {
35 | color:#fff;
36 | background:#6AB187
37 | }
38 |
39 | .box.box-solid.box-danger{
40 | border-bottom-color:#6AB187;
41 | border-left-color:#6AB187;
42 | border-right-color:#6AB187;
43 | border-top-color:#6AB187;
44 | }
45 |
46 | .responsive {
47 | max-width: 100%;
48 | height: auto;
49 | }
50 |
51 | .footer {
52 | position:absolute;
53 | bottom:10;
54 | width:80%;
55 | height:20px; /* Height of the footer */
56 | color: white;
57 | background-color: #4054b3;
58 | z-index: 1000;
59 | }
60 |
61 |
--------------------------------------------------------------------------------
/www/data/experimental_design_example.txt:
--------------------------------------------------------------------------------
1 | label condition replicate
2 | Total_309B Benign 1
3 | Total_309M Malignant 1
4 | Total_445B Benign 2
5 | Total_445M Malignant 2
6 | Total_555B Benign 3
7 | Total_555M Malignant 3
8 | Total_588B Benign 4
9 | Total_588M Malignant 4
10 | Total_636B Benign 5
11 | Total_636M Malignant 5
12 | Total_667B Benign 6
13 | Total_667M Malignant 6
14 | Total_741B Benign 7
15 | Total_741M Malignant 7
16 | Total_764B Benign 8
17 | Total_764M Malignant 8
18 | Total_876B Benign 9
19 | Total_876M Malignant 9
20 | Total_883B Benign 10
21 | Total_883M Malignant 10
22 |
--------------------------------------------------------------------------------
/www/data/experimental_design_example_feb19.txt:
--------------------------------------------------------------------------------
1 | label condition replicate
2 | H2 CD34High 1
3 | H3 CD34High 2
4 | H4 CD34High 3
5 | H5 CD34High 4
6 | L2 CD34Low 1
7 | L3 CD34Low 2
8 | L4 CD34Low 3
9 | L5 CD34Low 4
10 | N2 CD34Neg 1
11 | N3 CD34Neg 2
12 | N4 CD34Neg 3
13 | N5 CD34Neg 4
--------------------------------------------------------------------------------
/www/google-analytics.js:
--------------------------------------------------------------------------------
1 |
2 | window.dataLayer = window.dataLayer || [];
3 | function gtag(){dataLayer.push(arguments);}
4 | gtag('js', new Date());
5 |
6 | gtag('config', 'UA-66833365-2');
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/www/google_analytics.js:
--------------------------------------------------------------------------------
1 | // Initial Tracking Code
2 | (function(i,s,o,g,r,a,m){
3 | i['GoogleAnalyticsObject']=r;
4 | i[r]=i[r] ||
5 | function(){
6 | (i[r].q=i[r].q||[]).push(arguments);
7 | },i[r].l=1*new Date();
8 | a=s.createElement(o),
9 | m=s.getElementsByTagName(o)[0];
10 | a.async=1;
11 | a.src=g;
12 | m.parentNode.insertBefore(a,m);
13 | })(window,document,'script',
14 | 'https://www.google-analytics.com/analytics.js','ga');
15 |
16 | ga('create', 'UA-66833365-2', 'auto');
17 | ga('send', 'pageview');
18 |
19 | // Event Tracking Code
20 | $(document).on('shiny:inputchanged', function(event) {
21 | if(event.name == 'bins' || event.name == 'col'){
22 | ga('send', 'event', 'input',
23 | 'updates', event.name, event.value);
24 | }
25 | });
26 |
27 | // User Tracking Code
28 | $(document).one('shiny:idle', function() {
29 | ga('set','userId', Shiny.user);
30 | });
31 |
--------------------------------------------------------------------------------
/www/heatmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/heatmap.png
--------------------------------------------------------------------------------
/www/imputation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/imputation.png
--------------------------------------------------------------------------------
/www/js/google_analytics.js:
--------------------------------------------------------------------------------
1 | // Initial Tracking Code
2 | (function(i,s,o,g,r,a,m){
3 | i['GoogleAnalyticsObject']=r;
4 | i[r]=i[r] ||
5 | function(){
6 | (i[r].q=i[r].q||[]).push(arguments);
7 | },i[r].l=1*new Date();
8 | a=s.createElement(o),
9 | m=s.getElementsByTagName(o)[0];
10 | a.async=1;
11 | a.src=g;
12 | m.parentNode.insertBefore(a,m);
13 | })(window,document,'script',
14 | 'https://www.google-analytics.com/analytics.js','ga');
15 |
16 | ga('create', 'UA-66833365-2', 'auto');
17 | ga('send', 'pageview');
18 |
19 | // Event Tracking Code
20 | $(document).on('shiny:inputchanged', function(event) {
21 | if(event.name == 'bins' || event.name == 'col'){
22 | ga('send', 'event', 'input',
23 | 'updates', event.name, event.value);
24 | }
25 | });
26 |
27 | // User Tracking Code
28 | $(document).one('shiny:idle', function() {
29 | ga('set','userId', Shiny.user);
30 | });
31 |
--------------------------------------------------------------------------------
/www/mbpf_logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/mbpf_logo.jpg
--------------------------------------------------------------------------------
/www/mbpf_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/mbpf_logo.png
--------------------------------------------------------------------------------
/www/missing_heatmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/missing_heatmap.png
--------------------------------------------------------------------------------
/www/missing_quant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/missing_quant.png
--------------------------------------------------------------------------------
/www/monash_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/monash_logo.png
--------------------------------------------------------------------------------
/www/pvalue_hist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/pvalue_hist.png
--------------------------------------------------------------------------------
/www/volcano_plot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MonashBioinformaticsPlatform/LFQ-Analyst/65a12a303483fddbd3f80e6a4fe537e3ca960823/www/volcano_plot.png
--------------------------------------------------------------------------------