Skip to content

Commit

Permalink
Merge pull request #85 from jasenfinch/devel
Browse files Browse the repository at this point in the history
v0.14.8
  • Loading branch information
jasenfinch committed Jan 6, 2022
2 parents 2b6fe7b + 1cc542a commit e17b352
Show file tree
Hide file tree
Showing 70 changed files with 165 additions and 131 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: metabolyseR
Title: Methods for Pre-Treatment, Data Mining and Correlation Analyses of Metabolomics Data
Version: 0.14.7
Version: 0.14.8
Authors@R: person("Jasen", "Finch", email = "[email protected]", role = c("aut", "cre"))
Description: A tool kit for pre-treatment, modelling, feature selection and correlation analyses of metabolomics data.
URL: https://jasenfinch.github.io/metabolyseR
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# metabolyseR 0.14.8

* An error is now thrown during random forest classification when less than two classes are specified.

* [`plotSupervisedRF()`](https://jasenfinch.github.io/metabolyseR/reference/plotSupervisedRF.html) now skips plotting if errors are encountered during random forest training.

# metabolyseR 0.14.7

* Single replicate classes now automatically removed by [`plotLDA()`](https://jasenfinch.github.io/metabolyseR/reference/plotLDA.html).
Expand Down
50 changes: 27 additions & 23 deletions R/plotSupervisedRF.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,35 +59,39 @@ setMethod('plotSupervisedRF',
legendPosition = 'bottom',
labelSize = 2){

rf <- randomForest(x,
rf <- try(randomForest(x,
cls = cls,
rf = rf,
reps = 1,
seed = seed)
seed = seed))

pl <- plotMDS(rf,
cls = cls,
label = label,
ellipses = ellipses,
title = '',
legendPosition = legendPosition,
labelSize = labelSize) +
labs(
caption = str_c('Margin: ',
rf@results$measures$.estimate[4] %>%
round(3)))

if (isTRUE(ROC) & rf@type == 'classification') {
pl <- pl +
plotROC(rf,legendPosition = legendPosition) +
plot_annotation(
title = title,
theme = theme(plot.title = element_text(face = 'bold')))
if (class(rf) != 'try-error') {
pl <- plotMDS(rf,
cls = cls,
label = label,
ellipses = ellipses,
title = '',
legendPosition = legendPosition,
labelSize = labelSize) +
labs(
caption = str_c('Margin: ',
rf@results$measures$.estimate[4] %>%
round(3)))

if (isTRUE(ROC) & rf@type == 'classification') {
pl <- pl +
plotROC(rf,legendPosition = legendPosition) +
plot_annotation(
title = title,
theme = theme(plot.title = element_text(face = 'bold')))
} else {
pl <- pl + labs(title = title)
}

return(pl)
} else {
pl <- pl + labs(title = title)
warning('Errors encounted in random forest training, skipping plotting of supervised random forest.',call. = FALSE)
}

return(pl)
}
)

Expand Down
15 changes: 11 additions & 4 deletions R/randomForest.R
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,25 @@ classification <- function(x,
select(all_of(cls)) %>%
deframe())

cls_list <- clsRem %>%
select(all_of(cls)) %>%
deframe() %>%
str_c('"',.,'"') %>%
str_c(.,collapse = ', ')

warning(str_c('Classes with < 5 replicates removed: ',
str_c(str_c('"',clsRem %>%
select(all_of(cls)) %>%
deframe(),
'"'),collapse = ', ')),
cls_list),
call. = FALSE)

i <- x %>%
sinfo() %>%
select(cls)
}

if (length(unique(deframe(i))) < 2) {
stop('Need at least two classes to do classification.',call. = FALSE)
}

if (length(comparisons) > 0) {
comp <- comparisons
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/articles/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions docs/articles/metabolyseR.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions docs/articles/modelling.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/modelling_files/figure-html/regression-mds-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e17b352

Please sign in to comment.