Skip to content

Commit f5e564f

Browse files
committed
Vignettes: improved figures appearance, allignment and size.
1 parent 2796d5a commit f5e564f

3 files changed

+35
-24
lines changed

vignettes/pmp_vignette_peak_matrix_processing_for_metabolomics_datasets.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ MTBLS79_glog <- glog_transformation(df=MTBLS79_mv_imputed,
227227
visualise if the optimsation of the given parameter has converged at the
228228
minima.
229229

230-
```{r plot_glog}
230+
```{r plot_glog, fig.width=5}
231231
opt_lambda <-
232232
processing_history(MTBLS79_glog)$glog_transformation$lambda_opt
233233
glog_plot_optimised_lambda(df=MTBLS79_mv_imputed,

vignettes/pmp_vignette_sbc_spectral_quality_assessment.Rmd

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ vignette: >
3030
```{r setup, include = FALSE}
3131
knitr::opts_chunk$set(
3232
collapse = TRUE,
33-
comment = "#>"
33+
comment = "#>",
34+
fig.width=5,
35+
fig.height=5
3436
)
3537
```
3638

@@ -118,7 +120,7 @@ acceptable level of technical variation where signal correction is not required.
118120
The following code calculates and plots the RSD% values of the features within
119121
the dataset.
120122

121-
```{r fig.height=9, fig.width=5, message=FALSE, warning=FALSE}
123+
```{r fig.height=5, fig.width=4, message=FALSE, warning=FALSE}
122124
# separate the LCMS data from the meta data
123125
data(MTBLS79)
124126
data <- SummarizedExperiment::assay(MTBLS79[feature_names, ])
@@ -160,10 +162,11 @@ ggplot(data=plotdata, aes(x=Class, y=feature, fill=RSD)) +
160162

161163
A violin plot is a useful way of summarising the RSD% over all samples/QCs in
162164
the data set. Note a very high QC sample RSD% value for feature '409.05716'.
163-
```{r, fig.width=6, fig.height=6}
165+
```{r}
164166
ggplot(data=plotdata, aes(x=Class, y=RSD, fill=Class)) +
165167
geom_violin(draw_quantiles=c(0.25,0.5,0.75)) +
166168
ylab("RSD%") +
169+
guides(fill=FALSE) +
167170
theme(panel.background=element_blank())
168171
```
169172

@@ -173,7 +176,7 @@ and is more similar to the signal variation of the biological samples. We can
173176
calculate similar statistics per batch and visualise the results with a box
174177
plot.
175178

176-
```{r message=FALSE, warning=FALSE, fig.width=6, fig.height=6}
179+
```{r message=FALSE, warning=FALSE, fig.height=6}
177180
# prepare some matrices to store the results
178181
RSDQC <- matrix(ncol=8, nrow=nrow(data))
179182
RSDsample <- matrix(ncol=8, nrow=nrow(data))
@@ -211,7 +214,10 @@ plotdata$Class <- as.factor(plotdata$Class)
211214
ggplot(data=plotdata, aes(x=Class, y=RSD, fill=Class)) + geom_boxplot() +
212215
facet_wrap(~ batch, ncol=3) +
213216
ylab("RSD%") +
214-
theme(panel.background=element_blank())
217+
xlab("") +
218+
scale_x_discrete(labels=NULL) +
219+
theme(panel.background=element_blank(), axis.text.x=element_blank(),
220+
axis.ticks.x=element_blank())
215221
```
216222

217223
**Summary of RSD% of QC samples**
@@ -232,7 +238,7 @@ An alternative measure of QC and biological sample variability is the so called
232238
D-ratio, which indicates if the technical variation within the QC samples
233239
exceeds the biological variation within biological samples.
234240

235-
```{r message=FALSE, warning=FALSE, fig.width=6, fig.height=6}
241+
```{r message=FALSE, warning=FALSE}
236242
237243
# prepare a list of colours for plotting
238244
manual_color = c("#386cb0", "#ef3b2c", "#7fc97f", "#fdb462", "#984ea3",
@@ -291,7 +297,7 @@ spectral features.
291297
See @guida2016 for a more detailed review on common pre-processing steps and
292298
methods.
293299

294-
```{r, fig.width=6, fig.height=6}
300+
```{r, fig.width=6.5, fig.height=5}
295301
pca_data <- MTBLS79[feature_names, ]
296302
297303
pca_data <- pqn_normalisation(pca_data, classes=class, qc_label="QC")
@@ -340,7 +346,7 @@ below illustrates the measured signal of QC samples across all 8 batches. To be
340346
able to compare all 20 features measured at different signal ranges, the data
341347
will be scaled to unit variance (UV).
342348

343-
```{r message=FALSE, warning=FALSE, fig.height=12, fig.width=6}
349+
```{r message=FALSE, warning=FALSE, fig.height=10}
344350
345351
# autoscale the QC data
346352
QCdata <- data[ ,QChits]
@@ -365,7 +371,7 @@ across the eight batches, and that some features are following a similar
365371
pattern, i.e. they are correlated. We can create a similar plot to the one
366372
above including linear regression fit between measured data points.
367373

368-
```{r, warning=FALSE, fig.height=12, fig.width=6}
374+
```{r, warning=FALSE, fig.height=10}
369375
ggplot(data=plotdata, aes(x=index, y=intensity, col=batch)) +
370376
geom_point(size=2) +
371377
facet_wrap(~ variable, ncol=4) +
@@ -379,7 +385,7 @@ calculate actual correlation values within QC samples for each measured
379385
feature, and we will use Kendall's *tau* statistic to estimate a rank-based
380386
measure of association.
381387

382-
```{r message=FALSE, warning=FALSE, fig.height=15, fig.width=10}
388+
```{r message=FALSE, warning=FALSE, fig.height=7.5}
383389
sampleorder <- c(1:ncol(QCdata))
384390
385391
correlations <- matrix(ncol=2, nrow=nrow(data))
@@ -516,7 +522,7 @@ ggplot(data=plotdata, aes(x=batch, y=feature, fill=value)) +
516522
Let's have a closer look to '451.01086' measured feature and how signal
517523
correction can be applied.
518524

519-
```{r, warning=FALSE, message=FALSE, fig.width=6, fig.height=6}
525+
```{r, warning=FALSE, message=FALSE}
520526
data <- data.frame(data=
521527
as.vector(SummarizedExperiment::assay(MTBLS79["451.01086", ])), batch=batch,
522528
class=factor(class, ordered=TRUE))
@@ -534,7 +540,7 @@ measured intensities can be observed between analytical batches.
534540

535541
Similar plot for QC samples only
536542

537-
```{r, fig.width=6, fig.height=6}
543+
```{r}
538544
539545
QCdata <- data[data$class == "QC",]
540546
@@ -645,7 +651,7 @@ out
645651
Now the smoothed spline fit is used to predict values for the biological
646652
sample for the current batch.
647653

648-
```{r, fig.width=6, fig.height=6}
654+
```{r}
649655
valuePredict=predict(sp.obj, order[batch==nb])
650656
651657
plotchr <- as.numeric(data$class)
@@ -674,7 +680,7 @@ for signal drift. This can usually be done by subtracting the fitted values
674680
from the actual measured values for each feature. To avoid getting negative
675681
values we will add the median value of the feature to the corrected data.
676682

677-
```{r, fig.width=6, fig.height=6, warning=FALSE}
683+
```{r, warning=FALSE}
678684
fitmedian <- median(plotdata$measured, na.rm=TRUE)
679685
plotdata$corrected_subt <- (plotdata$measured - plotdata$fitted) + fitmedian
680686
@@ -697,7 +703,7 @@ An alternative to subtraction of the fitted values is to divide them by the
697703
median of the fit and use the resulting coefficients to correct the data points.
698704
The same general relative trends should be observed in either case.
699705

700-
```{r, fig.width=6, fig.height=6, warning=FALSE}
706+
```{r, warning=FALSE}
701707
plotdata$corrected_div <- plotdata$measured/(plotdata$fitted/fitmedian)
702708
703709
plotdata3 <- plotdata[,c("Class", "order", "corrected_subt", "corrected_div")]
@@ -720,7 +726,7 @@ ggplot(data=plotdata3, aes(x=order, y=intensity, color=data, shape=Class)) +
720726
So far we have applied signal correction for data points within one analytical
721727
batch. The code below will perform the same steps for each of the 8 batches.
722728

723-
```{r, fig.width=6, fig.height=6, warning=FALSE}
729+
```{r, warning=FALSE}
724730
725731
outl <- rep(NA, nrow(data))
726732
@@ -766,7 +772,7 @@ ggplot(data=plotdata2, aes(x=order, y=log(intensity,10),
766772
After smoothed spline fit per each batch is calculated, we can apply signal
767773
correction within each batch.
768774

769-
```{r, fig.width=6, fig.height=6, warning=FALSE}
775+
```{r, warning=FALSE}
770776
771777
# median intensity value is used to adjust batch effect
772778
@@ -807,7 +813,7 @@ First, a grand median is calculated across all batches, and then difference
807813
between each batch median and the grand median is subtracted from all the
808814
samples in that batch, to remove the difference.
809815

810-
```{r, fig.width=6, fig.height=6, warning=FALSE}
816+
```{r, warning=FALSE}
811817
mpa <- rep(NA, nrow(data))
812818
813819
for (bch in 1:8) {
@@ -845,7 +851,7 @@ ggplot(data=plotdata2, aes(x=order, y=log(intensity,10),
845851

846852
We can calculate RSD% before and after correction.
847853

848-
```{r, fig.width=6, fig.height=6, warning=FALSE}
854+
```{r, warning=FALSE}
849855
FUN <- function(x) sd(x, na.rm=TRUE)/mean(x, na.rm=TRUE) * 100
850856
851857
# RSD% of biological and QC samples within all 6 batches:
@@ -892,7 +898,7 @@ corrected_data <- QCRSC(df=data, order=sample_order, batch=batch,
892898
We can calculate RSD% statistics per batch before and after correction and
893899
visualise the results with a box plot.
894900

895-
```{r, fig.width=6, fig.height=6, warning=FALSE}
901+
```{r, warning=FALSE}
896902
data <- SummarizedExperiment::assay(data)
897903
corrected_data <- SummarizedExperiment::assay(corrected_data)
898904
RSDQC <- matrix(ncol=8, nrow=nrow(data))
@@ -952,7 +958,10 @@ plotdata$Class <- as.factor(plotdata$Class)
952958
ggplot(data=plotdata, aes(x=Class, y=RSD, fill=Class)) + geom_boxplot() +
953959
facet_wrap(~ batch, ncol=3) +
954960
ylab("RSD%") +
955-
theme(panel.background=element_blank()) +
961+
xlab("") +
962+
scale_x_discrete(labels=NULL) +
963+
theme(panel.background=element_blank(), axis.text.x=element_blank(),
964+
axis.ticks.x=element_blank()) +
956965
scale_y_continuous(limits=c(0, 50))
957966
958967
plotdata <- rbind(plotdataBio, plotdataBio_corrected)
@@ -963,7 +972,9 @@ plotdata$Class <- as.factor(plotdata$Class)
963972
ggplot(data=plotdata, aes(x=Class, y=RSD, fill=Class)) + geom_boxplot() +
964973
facet_wrap(~ batch, ncol=3) +
965974
ylab("RSD%") +
966-
theme(panel.background=element_blank())
975+
xlab("") +
976+
theme(panel.background=element_blank(), axis.text.x=element_blank(),
977+
axis.ticks.x=element_blank())
967978
968979
```
969980

vignettes/pmp_vignette_signal_batch_correction_mass_spectrometry.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ corrected_data <- QCRSC(df=data, order=sample_order, batch=batch,
134134
Function 'sbc_plot' provides visual comparison of the data before and after
135135
correction. For example we can check output for features '1', '5', and '30' in
136136
peak matrix.
137-
```{r message=FALSE, warning=FALSE, fig.height=6, fig.width=6}
137+
```{r message=FALSE, warning=FALSE, fig.height=5, fig.width=5}
138138
plots <- sbc_plot (df=MTBLS79, corrected_df=corrected_data, classes=class,
139139
batch=batch, output=NULL, indexes=c(1, 5, 30))
140140
plots

0 commit comments

Comments
 (0)