Skip to content

Commit

Permalink
Reexport pca() from dimensio
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Nov 17, 2023
1 parent 5763dea commit 3f2e39c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 13 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ S3method(mean,CompositionMatrix)
S3method(plot,CompositionMatrix)
S3method(plot,LogRatio)
S3method(plot,OutlierIndex)
export(pca)
export(remove_NA)
export(remove_zero)
export(replace_NA)
Expand Down Expand Up @@ -67,6 +68,7 @@ importFrom(arkhe,remove_NA)
importFrom(arkhe,remove_zero)
importFrom(arkhe,replace_NA)
importFrom(arkhe,replace_zero)
importFrom(dimensio,pca)
importFrom(grDevices,hcl.colors)
importFrom(methods,"as<-")
importFrom(methods,"slot<-")
Expand Down
2 changes: 1 addition & 1 deletion R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ setGeneric(
#' @author N. Frerebeau
#' @docType methods
#' @family multivariate analysis
#' @name pca
#' @name pca_coda
#' @rdname pca
NULL

Expand Down
4 changes: 2 additions & 2 deletions R/pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NULL
setMethod(
f = "pca",
signature = c("CompositionMatrix"),
definition = function(object, center = TRUE, scale = TRUE, rank = NULL,
definition = function(object, center = TRUE, scale = FALSE, rank = NULL,
sup_row = NULL, sup_col = NULL,
weight_row = NULL, weight_col = NULL) {
stop("You should not do that! Transform your data first.", call. = FALSE)
Expand All @@ -21,7 +21,7 @@ setMethod(
setMethod(
f = "pca",
signature = c("LogRatio"),
definition = function(object, center = TRUE, scale = TRUE, rank = NULL,
definition = function(object, center = TRUE, scale = FALSE, rank = NULL,
sup_row = NULL, sup_col = NULL,
weight_row = NULL, weight_col = NULL) {
z <- methods::callNextMethod()
Expand Down
4 changes: 4 additions & 0 deletions R/reexport.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ arkhe::remove_NA
#' @importFrom arkhe remove_zero
#' @export
arkhe::remove_zero

#' @importFrom dimensio pca
#' @export
dimensio::pca
8 changes: 4 additions & 4 deletions man/pca.Rd

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

3 changes: 3 additions & 0 deletions man/reexports.Rd

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

6 changes: 4 additions & 2 deletions man/subset.Rd

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

18 changes: 14 additions & 4 deletions vignettes/nexus.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ barplot(coda, order = "Ca")
## Principle Component Analysis

```{r ceramics-pca, fig.width=7, fig.height=7, out.width='50%', fig.show='hold'}
library(dimensio)
## CLR
clr <- transform_clr(coda)
## PCA
library(dimensio)
clr_pca <- pca(clr, scale = FALSE)
viz_individuals(clr_pca, highlight = get_groups(coda), pch = 16,
Expand All @@ -200,15 +200,25 @@ viz_variables(clr_pca)
## MANOVA

```{r ceramics-manova}
fit <- manova(transform_ilr(coda) ~ get_groups(coda))
## ILR
ilr <- transform_ilr(coda)
## MANOVA
fit <- manova(ilr ~ get_groups(ilr))
summary(fit)
```

The MANOVA results suggest that there are statistically significant differences between groups.

## Discriminant Analysis

```{r ceramics-lda, fig.width=7, fig.height=7, out.width='100%'}
discr <- MASS::lda(transform_ilr(coda), grouping = get_groups(coda))
## LDA
discr <- MASS::lda(ilr, grouping = get_groups(ilr))
plot(discr)
## Back transform results
transform_inverse(discr$means, origin = ilr)
```

# References

0 comments on commit 3f2e39c

Please sign in to comment.