Skip to content

Commit 51b587c

Browse files
authored
Merge pull request #3 from computational-metabolomics/update_documation
Updates for CMD and BiocCheck
2 parents 0150710 + cdda920 commit 51b587c

File tree

128 files changed

+1158
-605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+1158
-605
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ LICENSE
1414
README.rst
1515
^binder/
1616
^notebooks/
17+
man-roxygen

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ structtoolbox.Rproj
1313
*.tiff
1414
vignettes/.build.timestamp
1515
*.xml
16+
doc

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ r: bioc-devel
33
sudo: false
44
cache: packages
55
warnings_are_errors: false
6-
r_github_packages: r-lib/remotes#340
76
after_success:
87
- Rscript -e 'covr::codecov()'
98
addons:

DESCRIPTION

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ License: GPL-3
99
Encoding: UTF-8
1010
LazyData: true
1111
Collate:
12+
'entity_objects.R'
1213
'anova_class.R'
1314
'HSD_class.R'
1415
'mixed_effect_class.R'
@@ -23,6 +24,8 @@ Collate:
2324
'autoscale_class.R'
2425
'balanced_accuracy_class.R'
2526
'blank_filter_class.R'
27+
'calculate_doc.R'
28+
'chart_plot_doc.R'
2629
'classical_lsq_class.R'
2730
'confounders_clsq_class.R'
2831
'corr_coef_class.R'
@@ -47,6 +50,10 @@ Collate:
4750
'linear_model_class.R'
4851
'log_transform.R'
4952
'mean_centre_class.R'
53+
'model_apply_doc.R'
54+
'model_predict_doc.R'
55+
'model_reverse_doc.R'
56+
'model_train_doc.R'
5057
'mv_feature_filter_class.R'
5158
'mv_sample_filter_class.R'
5259
'pairs_filter_class.R'
@@ -56,6 +63,7 @@ Collate:
5663
'prop_na_class.R'
5764
'r_squared_class.R'
5865
'rsd_filter.R'
66+
'run_doc.R'
5967
'sb_corr.R'
6068
'sbcms_dataset_class.R'
6169
'split_data_class.R'
@@ -64,6 +72,7 @@ Collate:
6472
'ttest_class.R'
6573
'vec_norm_class.R'
6674
'wilcox_test_class.R'
75+
'zzz.R'
6776
Depends: struct
6877
Imports: ggplot2,
6978
pmp,
@@ -81,15 +90,18 @@ Imports: ggplot2,
8190
nlme,
8291
ggthemes,
8392
ggdendro,
84-
Rtsne
93+
Rtsne,
94+
datasets
8595
RoxygenNote: 6.1.1
8696
Suggests:
8797
testthat,
8898
covr,
8999
knitr,
90100
rmarkdown,
91-
BiocStyle
101+
BiocStyle,
102+
sbcms
92103
Remotes: computational-metabolomics/pmp,
93-
computational-metabolomics/struct
104+
computational-metabolomics/struct,
105+
computational-metabolomics/sbcms
94106
VignetteBuilder: knitr
95107
biocViews: WorkflowStep

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ export(wilcox_p_hist)
8989
export(wilcox_test)
9090
exportMethods(calculate)
9191
exportMethods(chart.plot)
92-
exportMethods(evaluate)
9392
exportMethods(method.apply)
9493
exportMethods(model.predict)
9594
exportMethods(model.reverse)

R/HSDEM_class.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ HSDEM<-setClass(
6060
)
6161

6262
#' @export
63+
#' @template method_apply
6364
setMethod(f="method.apply",
6465
signature=c("HSDEM",'dataset'),
6566
definition=function(M,D) {
@@ -106,7 +107,10 @@ setMethod(f="method.apply",
106107
for (k in 1:length(FF)) {
107108
if (!is.na(testlm[[1]])) {
108109
testhsd=tryCatch({
109-
output2[[k]]=as.data.frame(pairs(emmeans(LM,FF[[k]],data=temp)))
110+
output2[[k]]=as.data.frame(
111+
pairs(
112+
emmeans::emmeans(LM,FF[[k]],
113+
data=temp)))
110114
}, warning = function(w) {
111115
NA
112116
} , message = function(m) {

R/HSD_class.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ HSD<-setClass(
7070
)
7171

7272
#' @export
73+
#' @template method_apply
7374
setMethod(f="method.apply",
7475
signature=c("HSD",'dataset'),
7576
definition=function(M,D) {

R/PCA_class.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ PCA<-setClass(
3939
)
4040

4141
#' @export
42+
#' @template model_train
4243
setMethod(f="model.train",
4344
signature=c("PCA",'dataset'),
4445
definition=function(M,D)
@@ -82,6 +83,7 @@ setMethod(f="model.train",
8283
)
8384

8485
#' @export
86+
#' @template model_predict
8587
setMethod(f="model.predict",
8688
signature=c("PCA",'dataset'),
8789
definition=function(M,D)

R/PCA_plotfcns.R

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pca_correlation_plot<-setClass(
2828
)
2929

3030
#' @export
31+
#' @template chart_plot
3132
setMethod(f="chart.plot",
3233
signature=c("pca_correlation_plot",'PCA'),
3334
definition=function(obj,dobj)
@@ -70,7 +71,9 @@ pca_scores_plot<-setClass(
7071
params.factor_name='entity',
7172
params.ellipse='enum',
7273
params.label_filter='entity',
73-
params.groups='ANY' # will be deprecated
74+
params.groups='ANY', # will be deprecated
75+
params.label_factor='entity',
76+
params.label_size='entity'
7477
),
7578

7679
prototype = list(name='PCA scores plot',
@@ -93,7 +96,8 @@ pca_scores_plot<-setClass(
9396
params.factor_name=entity(name='Factor name',
9497
value='factor',
9598
type='character',
96-
description='The column name of sample meta to use for plotting.'
99+
description='The column name of sample meta to use for plotting. A second column can be included to plot using symbols.',
100+
max_length=2
97101
),
98102
params.ellipse=enum(name = 'Plot ellipses',description=c(
99103
'"all" will plot all ellipses',
@@ -106,7 +110,15 @@ pca_scores_plot<-setClass(
106110
value=character(0),
107111
type='character',
108112
description='Only include the param.group labels included in params.label_filter. If zero length then all labels will be included.'
109-
)
113+
),
114+
params.label_factor=entity(names='Factor for labels',
115+
description='The column name of sample_meta to use as labels. "rownames" will use the row names from sample_meta.',
116+
type='character',
117+
value='rownames'),
118+
params.label_size=entity(names='Text size of labels',
119+
description='The text size of labels. Note this is not in Font Units. Default 3.88.',
120+
type='numeric',
121+
value=3.88)
110122
)
111123
)
112124

@@ -116,6 +128,7 @@ pca_scores_plot<-setClass(
116128
#' @import ggplot2
117129
#' @importFrom scales squish
118130
#' @export
131+
#' @template chart_plot
119132
setMethod(f="chart.plot",
120133
signature=c("pca_scores_plot",'PCA'),
121134
definition=function(obj,dobj)
@@ -126,10 +139,22 @@ setMethod(f="chart.plot",
126139
}
127140
opt=param.list(obj)
128141
scores=output.value(dobj,'scores')$data
129-
pvar=(colSums(scores*scores)/output.value(dobj,'ssx'))*100 # percent variance
130-
pvar=round(pvar,digits = 2) # round to 2 decimal places
131-
shapes <- rep(19,nrow(scores)) # filled circles for all samples
132-
slabels <- rownames(scores)
142+
pvar = (colSums(scores*scores)/output.value(dobj,'ssx'))*100 # percent variance
143+
pvar = round(pvar,digits = 2) # round to 2 decimal places
144+
145+
if (length(obj$factor_name)==1) {
146+
shapes = 19 # filled circles for all samples
147+
} else {
148+
shapes = factor(dobj$scores$sample_meta[[obj$factor_name[2]]])
149+
}
150+
151+
if (obj$label_factor=='rownames') {
152+
slabels = rownames(dobj$scores$sample_meta)
153+
} else {
154+
slabels = dobj$scores$sample_meta[[obj$label_factor]]
155+
}
156+
opt$factor_name=opt$factor_name[[1]] # only use the first factor from now on
157+
133158
x=scores[,opt$components[1]]
134159
y=scores[,opt$components[2]]
135160
xlabel=paste("PC",opt$components[[1]],' (',sprintf("%.1f",pvar[opt$components[[1]]]),'%)',sep='')
@@ -158,16 +183,27 @@ setMethod(f="chart.plot",
158183
# build the plot
159184
A <- data.frame (group=opt$groups,x=x, y=y)
160185

161-
out=ggplot (data=A, aes_(x=~x,y=~y,colour=~group,label=~slabels,shapes=~shapes)) +
186+
if (length(obj$factor_name)==2) {
187+
out=ggplot (data=A, aes_(x=~x,y=~y,colour=~group,label=~slabels,shape=~shapes))
188+
} else {
189+
out=ggplot (data=A, aes_(x=~x,y=~y,colour=~group,label=~slabels))
190+
}
191+
out=out+
162192

163193
geom_point(na.rm=TRUE) +
164194
xlab(xlabel) +
165195
ylab(ylabel) +
166-
ggtitle('PCA Scores', subtitle=NULL) +
196+
ggtitle('PCA Scores', subtitle=NULL)
167197

168-
if (obj$ellipse %in% c('all','group')) {
169-
stat_ellipse(type='norm') # ellipse for individual groups
170-
}
198+
if (length(obj$factor_name)==2) {
199+
out=out+labs(shape=obj$factor_name[[2]],colour=obj$factor_name[[1]])
200+
} else {
201+
out=out+labs(shape=obj$factor_name[[1]])
202+
}
203+
204+
if (obj$ellipse %in% c('all','group')) {
205+
out = out +stat_ellipse(type='norm') # ellipse for individual groups
206+
}
171207

172208
if (is(opt$groups,'factor')) { # if a factor then plot by group using the colours from pmp package
173209
out=out+scale_colour_manual(values=plotClass$manual_colors,name=opt$factor_name)
@@ -194,10 +230,9 @@ setMethod(f="chart.plot",
194230
{
195231
if (!all(points$in.ell))
196232
{
197-
198233
temp=subset(points,!points$in.ell)
199234
temp$group=opt$groups[!points$in.ell]
200-
out=out+geom_text(data=temp,aes_(x=~x,y=~y,label=~label,colour=~group),vjust="inward",hjust="inward")
235+
out=out+geom_text(data=temp,aes_(x=~x,y=~y,label=~label,colour=~group),size=obj$label_size,vjust="inward",hjust="inward")
201236

202237
}
203238
}
@@ -248,7 +283,7 @@ pca_biplot_plot<-setClass(
248283
type='numeric',
249284
description='the components to be plotted e.g. c(1,2) plots component 1 on the x axis and component 2 on the y axis.',
250285
max_length=2
251-
),
286+
),
252287
params.points_to_label=entity(name='points_to_label',
253288
value='none',
254289
type='character',
@@ -285,6 +320,7 @@ pca_biplot_plot<-setClass(
285320
)
286321

287322
#' @export
323+
#' @template chart_plot
288324
setMethod(f="chart.plot",
289325
signature=c("pca_biplot_plot",'PCA'),
290326
definition=function(obj,dobj)
@@ -405,6 +441,7 @@ pca_loadings_plot<-setClass(
405441

406442

407443
#' @export
444+
#' @template chart_plot
408445
setMethod(f="chart.plot",
409446
signature=c("pca_loadings_plot",'PCA'),
410447
definition=function(obj,dobj)
@@ -466,6 +503,7 @@ PCA.scree<-setClass(
466503
)
467504

468505
#' @export
506+
#' @template chart_plot
469507
setMethod(f="chart.plot",
470508
signature=c("PCA.scree",'PCA'),
471509
definition=function(obj,dobj)
@@ -522,6 +560,7 @@ PCA.dstat<-setClass(
522560
)
523561

524562
#' @export
563+
#' @template chart_plot
525564
setMethod(f="chart.plot",
526565
signature=c("PCA.dstat",'PCA'),
527566
definition=function(obj,dobj)

R/PLSDA_charts.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#' @import struct
99
#' @export plsda_scores_plot
1010
#' @include PLSDA_class.R
11+
#' @examples
12+
#' C = plsda_scores_plot()
1113
plsda_scores_plot<-setClass(
1214
"plsda_scores_plot",
1315
contains='chart',
@@ -47,6 +49,7 @@ plsda_scores_plot<-setClass(
4749
)
4850

4951
#' @export
52+
#' @template chart_plot
5053
setMethod(f="chart.plot",
5154
signature=c("plsda_scores_plot",'PLSDA'),
5255
definition=function(obj,dobj)

0 commit comments

Comments
 (0)