Skip to content

Commit

Permalink
Merge pull request #94 from jasenfinch/devel
Browse files Browse the repository at this point in the history
v0.15.3
  • Loading branch information
jasenfinch committed Aug 24, 2023
2 parents 20a96f5 + c99073f commit 2f1312d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 12 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.15.2
Version: 0.15.3
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.15.3

* Fixed the margin value displayed in plots from [`plotSupervisedRF()`](https://jasenfinch.github.io/metabolyseR/reference/plotSupervisedRF.html)

* The [`plotExplanatoryHeatmap()`](https://jasenfinch.github.io/metabolyseR/reference/plotExplanatoryHeatmap.html) method for the [`Analysis`](https://jasenfinch.github.io/metabolyseR/reference/Analysis-class.html) S4 class now returns a warning and skips plotting if an error is encountered whilst trying to plot a heat map.

# metabolyseR 0.15.2

* Added the argument `refactor` to the method [`transformTICnorm()`](https://jasenfinch.github.io/metabolyseR/reference/transform.html) to enable the feature intensities of total ion count (TIC) normalised data to be refactored back to a range consistent with the original data by multiplying the normalised values by the median TIC.
Expand Down
31 changes: 21 additions & 10 deletions R/plotExplanatoryHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,28 @@ setMethod('plotExplanatoryHeatmap',
'should be of class RandomForest or Univariate'),
call. = FALSE)
}

x %>%
map(~plotExplanatoryHeatmap(
.x,
threshold = threshold,
title = response(.x),
distanceMeasure = distanceMeasure,
clusterMethod = clusterMethod,
featureNames = featureNames,
featureLimit = featureLimit
))
map(
~{
heat_map <- try(plotExplanatoryHeatmap(
.x,
threshold = threshold,
title = response(.x),
distanceMeasure = distanceMeasure,
clusterMethod = clusterMethod,
featureNames = featureNames,
featureLimit = featureLimit
))

if (!is(heat_map,'try-error')) {
return(heat_map)
} else {
warning('Errors encounted in plotting heatmap, skipping.',call. = FALSE)
}

}
)
}
)

Expand Down
5 changes: 4 additions & 1 deletion R/plotSupervisedRF.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ setMethod('plotSupervisedRF',
labelSize = labelSize) +
labs(
caption = str_c('Margin: ',
rf@metrics$.estimate[4] %>%
rf %>%
metrics() %>%
filter(.metric == 'margin') %>%
pull(.estimate) %>%
round(3)))

if (isTRUE(ROC) & rf@type == 'classification') {
Expand Down
29 changes: 29 additions & 0 deletions tests/testthat/test-plotExplanatoryHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,32 @@ test_that('plotExplanatoryHeatmap throws error when unsupervised random forest s
randomForest(cls = NULL)
expect_error(plotExplanatoryHeatmap(d))
})

test_that('plotExplanatoryHeatmap throws error when unsupervised random forest supplied',{
p <- analysisParameters(c('pre-treatment','modelling'))

parameters(p,'pre-treatment') <- preTreatmentParameters(
list(
keep = 'classes',
occupancyFilter = 'maximum',
transform = 'TICnorm'
)
)

changeParameter(p,'cls') <- 'day'
changeParameter(p,'classes') <- c('H')

p@modelling[[1]]$cls <- NULL
p@modelling[[1]] <- c(
list(
cls = NULL),
p@modelling[[1]]
)

analysis <- metabolyse(
metaboData::abr1$neg,
metaboData::abr1$fact,
p)

expect_warning(plotExplanatoryHeatmap(analysis))
})

0 comments on commit 2f1312d

Please sign in to comment.