Commit a50115d3 by Eric Coissac

Chonges to complain with R CRAN check

parent 11f8457c
......@@ -3,13 +3,14 @@ Type: Package
Title: What the Package Does (Title Case)
Version: 0.1.0
Author: Eric Coissac, Christelle Gonindard-Melodelima
Maintainer: The package maintainer <yourself@somewhere.net>
Maintainer: The package maintainer <eric.coissac@metabarcoding.org>
Description: More about what it does (maybe more than one line)
Use four spaces when indenting paragraphs within the Description.
License: CECILL 2.1
License: CECILL-2.1
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
Depends: R (>= 3.1.0)
Imports: MASS,
permute,
expm,
......@@ -22,7 +23,8 @@ Imports: MASS,
Suggests: knitr,
rmarkdown,
roxygen2,
vegan
vegan,
testthat
RdMacros: Rdpack
VignetteBuilder: knitr
Collate:
......
......@@ -10,7 +10,6 @@ S3method(as.list,procmod.frame)
S3method(as.procmod.frame,array)
S3method(as.procmod.frame,list)
S3method(as.procmod.frame,matrix)
S3method(as.procmod.frame,pm)
S3method(as.procmod.frame,procmod.frame)
S3method(dim,procmod.frame)
S3method(names,procmod.corls)
......@@ -41,4 +40,6 @@ export(varls)
import(MASS)
import(doParallel)
import(foreach)
import(permute)
import(stats)
importFrom(Rdpack,reprompt)
#' @include covls.R
#'
#' @import permute
#' @author Christelle Gonindard-Melodelima
#' @author Eric Coissac
NULL
......@@ -57,8 +57,8 @@ NULL
#' by the function \code{\link[permute]{how}}, or the number of
#' permutations required.
#' @param p.adjust.method the multiple test correction method used
#' to adjust p values. \code{\link[stats]{p.adjust.method}}
#' belongsone of the folowing values: \code{"holm"},
#' to adjust p values. \code{p.adjust.method}
#' belongs one of the folowing values: \code{"holm"},
#' \code{"hochberg"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}.
#' The default is,set to \code{"holm"}.
......@@ -67,6 +67,8 @@ NULL
#' \insertRef{Jackson:95:00}{ProcMod}
#' }
#'
#' @seealso \code{\link[stats]{p.adjust}}
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
......
......@@ -3,6 +3,7 @@
#' @include multivariate.R
#' @import doParallel
#' @import foreach
#' @import stats
#'
#' @author Christelle Gonindard-Melodelima
#' @author Eric Coissac
......@@ -95,7 +96,7 @@ registerDoParallel(1)
#' is estimated and the raw procrustean covariances are
#' estimated.
#' @param p.adjust.method the multiple test correction method used
#' to adjust p values. \code{\link[stats]{p.adjust.method}}
#' to adjust p values. \code{p.adjust.method}
#' belongsone of the folowing values: \code{"holm"},
#' \code{"hochberg"}, \code{"hommel"}, \code{"bonferroni"},
#' \code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}.
......@@ -136,6 +137,8 @@ registerDoParallel(1)
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#'
#' @seealso \code{\link[stats]{p.adjust}}
#'
#' @rdname varls
#' @name varls
#' @aliases varls
......@@ -296,6 +299,12 @@ corls.partial <- function(..., nrand = 100) {
#' Print procrustean variance / covariance matrix.
#'
#' @param x a \code{procmod.varls}
#' object
#' @param ... other parameters passed to other functions
#'
#' @seealso \code{\link[ProcMod]{varls}}
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
......@@ -327,6 +336,12 @@ names.procmod.varls <- function(x) {
#' Print procrustean correlation matrix.
#'
#' @param x a \code{procmod.corls}
#' object
#' @param ... other parameters passed to other functions
#'
#' @seealso \code{\link[ProcMod]{corls}}
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
......
......@@ -179,6 +179,11 @@ pca <- function(data, scale = FALSE) {
#' Inspired from the algorithm described in stackoverflow
#' \url{https://stackoverflow.com/questions/43639063/double-centering-in-r}
#'
#' @param m a \code{numeric} matrix
#'
#' @return a \code{numeric} matrix centred by rows
#' and columns
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
......@@ -247,6 +252,8 @@ is.orthogonal <- function(x) {
#' @param scale a \code{logical} value indicating if the dimensions must be scaled
#' to force for every column that \code{sd=1}. \code{FALSE} by default.
#'
#' @param ... other parameters specific to some implementation
#'
#' @return a numeric matrix with at most \code{n-1} dimensions, with
#' \code{n} the number pf observations. This matrix defines the
#' coordinates of each point in the orthogonal space.
......@@ -260,50 +267,50 @@ ortho <- function(data, ...) {
#' @rdname ortho
#' @export
ortho.dist <- function(x, tol = 1e-7) {
if (ProcMod::is.euclid(x, tol = tol)) {
return(ProcMod::pcoa(x))
ortho.dist <- function(data, tol = 1e-7, ...) {
if (ProcMod::is.euclid(data, tol = tol)) {
return(ProcMod::pcoa(data))
}
ProcMod::nmds(x)
ProcMod::nmds(data)
}
#' @rdname ortho
#' @export
ortho.matrix <- function(x, scale = FALSE) {
pca(x, scale = scale)
ortho.matrix <- function(data, scale = FALSE, ...) {
pca(data, scale = scale)
}
#' @rdname ortho
#' @export
ortho.data.frame <- function(x, scale = FALSE) {
if (!is.null(attributes(x)$is.dist) &&
attributes(x)$is.dist == TRUE) {
return(ortho(as.dist(as.matrix(x))))
ortho.data.frame <- function(data, scale = FALSE, ...) {
if (!is.null(attributes(data)$is.dist) &&
attributes(data)$is.dist == TRUE) {
return(ortho(as.dist(as.matrix(data))))
}
pca(as.matrix(x), scale = scale)
pca(as.matrix(data), scale = scale)
}
#' @rdname ortho
#' @export
ortho.procmod.frame <- function(x) {
if (is.orthogonal(x)) {
return(x)
ortho.procmod.frame <- function(data, ...) {
if (is.orthogonal(data)) {
return(data)
}
n <- ncol(x)
n <- ncol(data)
p <- vector(mode = "character", length = n)
for (i in seq_len(n)) {
xt <- ortho(x[[i]])
xt <- ortho(data[[i]])
p[i] <- attributes(xt)$projected
x[[i]] <- xt
data[[i]] <- xt
}
names(p) <- names(x)
attributes(x)$projected <- p
names(p) <- names(data)
attributes(data)$projected <- p
x
data
}
#' @docType package
#' @importFrom Rdpack reprompt
NULL
#' DNA metabarcoding Australia South-North Gradient
#'
#' This data set of five \code{data.frame}
#' is a simplified version of a full data set
#' describing biodiversity changes along a South-North
#' gradient on the Australian East Coast, from Sidney to
#' North Cap. The gradient is constituted of 21 locations.
#'
#' \describe{
#' \item{bacteria}{is a 21 x 2150 \code{data.frame} describing bacterial
#' community at each one of the 21 locations.
#' Each number is the relative frequency of a molecular operational
#' taxonomy unit (MOTU) at a site after data cleaning and
#' averaging of 135 pontual measures.}
#'
#' \item{bacteria}{is a 21 x 1393 \code{data.frame} describing eukariote
#' community at each one of the 21 locations.
#' Each number is the relative frequency of a molecular operational
#' taxonomy unit (MOTU) at a site after data cleaning and
#' averaging of 135 pontual measures.}
#'
#' \item{climat}{is a 21 x 6 \code{data.frame} describing climatic conditions
#' at each site using worldclim descriptors (https://www.worldclim.org).
#' \describe{
#' \item{Aspect}{}
#' \item{TempSeasonality}{}
#' \item{MaxMonTemp}{Max Temperature of Warmest Month}
#' \item{MeanMonTempRange}{}
#' \item{AnnMeanTemp}{}
#' \item{Isothemality}{Mean Diurnal Range / Temperature Annual Range, with
#' \describe{
#' \item{Mean Diurnal Range}{Mean of monthly (max temp - min temp)}
#' \item{Temperature Annual Range}{Max Temperature of Warmest Month - Min Temperature of Coldest Month}
#' }
#' }}}
#'
#' \item{soil}{s a 21 x 6 \code{data.frame} describing soil chemistery
#' at each site.
#' Each variable is reduced and centered
#' \describe{
#' \item{KLg}{Logarithm of the potassium concentration}
#' \item{pH}{Soil Ph}
#' \item{AlLg}{Logarithm of the aluminium concentration}
#' \item{FeLg}{Logarithm of the iron concentration}
#' \item{PLg}{Logarithm of the phosphorus concentration}
#' \item{SLg}{Logarithm of the sulphur concentration}
#' \item{CaLg}{Logarithm of the calcium concentration}
#' \item{MgLg}{Logarithm of the magnesium concentration}
#' \item{MnLg}{Logarithm of the manganese concentration}
#' \item{CNratio}{carbon / nitrogen concentration ratio}
#' \item{CLg}{Logarithm of the carbon concentration}
#' \item{NLg}{Logarithm of the nitrogen concentration}
#' }}
#'
#' \item{geography}{}
#' }
#'
#' @docType data
#' @usage data(eukaryotes)
#' @keywords datasets
#' @format five data.frame of 21 rows
#' @rdname australia
#' @author Christelle Gonindard-Melodelima
#' @author Eric Coissac
"eukaryotes"
#' @docType data
#' @usage data(bacteria)
#' @rdname australia
"bacteria"
#' @docType data
#' @usage data(climat)
#' @rdname australia
"climat"
#' @docType data
#' @usage data(soil)
#' @rdname australia
"soil"
#' @docType data
#' @usage data(geography)
#' @rdname australia
"geography"
......@@ -20,14 +20,13 @@ NULL
#' @author Christelle Gonindard-Melodelima <christelle.gonindard@metabarcoding.org>
#' @rdname internal.rep_matrix
#'
.rep_matrix <- function(x, nrow) {
N <- nrow(x)
if ((nrow %% N != 0L)) {
stop(sprintf(
"The size of the longest object (%d) is not a multiple of the size of the shortest (%d)",
nrows, N
nrow, N
),
domain = NA
)
......@@ -48,6 +47,9 @@ NULL
#' @param x The data to coerce
#' @param nrows an interger value specifying the number of row
#' of the returned matrix
#' @param contrasts see the \code{contrasts.arg} argument
#' of the \code{\link[ProcMod]{procmod.frame}}
#' constructor.
#'
#' @return a new numeric matrix with correct size.
#' @note Internal function do not use.
......@@ -176,6 +178,31 @@ NULL
#' (\code{attr(d,"Size")}). A \code{procmod.frame} can simultaneously
#' contain both types of data, numeric and distance matrix.
#'
#' @param ... a set of objects to aggregate into a
#' \code{procmod.frame}. These objects can be
#' numeric matrices, or dist objects. Every objects
#' must have the same number of row.
#'
#' @param row.names a character vector containing names associated
#' to each row.
#'
#' @param check.rows a logical value. When set to \code{TRUE}, its
#' default value, the number of row of every elements of the
#' \code{procmod.frame} are tested for equality. Otherwise no
#' check is done.
#'
#' @param reorder.rows a logical value. When set to \code{TRUE}, its
#' default value, every elements of the
#' \code{procmod.frame} are reordered according to the \code{row.names}
#' order. Otherwise nothing is done.
#'
#' @param contrasts.arg A list, whose entries are values
#' (numeric matrices or character strings naming functions)
#' to be used as replacement values for the contrasts
#' replacement function and whose names are the names
#' of columns of data containing factors.
#'
#' @return a \code{procmod.frame} instance.
#'
#' @examples
#' library(vegan)
......@@ -202,9 +229,8 @@ NULL
#' @export
procmod.frame <- function(...,
row.names = NULL,
check.rows = FALSE,
check.names = TRUE,
reorder.rows = FALSE,
check.rows = TRUE,
reorder.rows = TRUE,
contrasts.arg = NULL) {
has.row.names <- !missing(row.names)
......@@ -226,7 +252,7 @@ procmod.frame <- function(...,
names(value) <- varnames
types <- character(n)
# types <- character(n)
for (i in seq_len(n)) {
contrasts <- contrasts.arg[varnames[i]]
......@@ -277,7 +303,14 @@ procmod.frame <- function(...,
#'
#' Check if an object is a ProcMod Frame.
#'
#' @rdname procmod.frame
#' @param x a R \code{object to test}
#'
#' @return a \code{logical} value equals to
#' \code{TRUE} if \code{x} is a \code{procmod.frame},
#' \code{FALSE} otherwise.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
is.procmod.frame <- function(x) {
inherits(x, "procmod.frame")
......@@ -286,35 +319,35 @@ is.procmod.frame <- function(x) {
#'
#' Coerce to a ProcMod Frame.
#'
#' @rdname procmod.frame
#' Conversion methods are proposed for \code{list},
#' \code{matrix} and \code{array}.
#'
#' @param data a R object to coerce.
#' @param ... supplementary parameters used in some
#' implementation of that method
#' @return a \code{procmod.frame} object
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
as.procmod.frame <- function(data, ...) {
UseMethod("as.procmod.frame", data)
}
#' Coerce to a ProcMod Frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @rdname as.procmod.frame
#' @export
as.procmod.frame.list <- function(data, ...) {
data <- c(data, list(...))
do.call(procmod.frame, data)
}
#' Coerce to a ProcMod Frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @rdname as.procmod.frame
#' @export
as.procmod.frame.procmod.frame <- function(data, ...) {
data
}
#' Coerce to a ProcMod Frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @rdname as.procmod.frame
#' @export
as.procmod.frame.array <- function(data, ...) {
di <- dim(data)
......@@ -334,19 +367,13 @@ as.procmod.frame.array <- function(data, ...) {
do.call(procmod.frame, l)
}
#' Coerce to a ProcMod Frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @export
as.procmod.frame.pm <- function(data, ...) {
vars.procmod(terms(data), data$model)
}
# #' @rdname procmod.frame
# #' @export
# as.procmod.frame.pm <- function(data, ...) {
# vars.procmod(terms(data), data$model)
# }
#' Coerce to a ProcMod Frame.
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
#' @rdname as.procmod.frame
#' @export
as.procmod.frame.matrix <- function(data, ...) {
l <- vector(mode = "list", length = ncol(data))
......@@ -361,7 +388,10 @@ as.procmod.frame.matrix <- function(data, ...) {
as.procmod.frame(l)
}
#' Dimensions of a Matrix Frame.
#' Dimensions of a ProcMod Frame.
#'
#' @param x a \code{\link[ProcMod]{procmod.frame}}
#' object
#'
#' @author Eric Coissac
#' @author Christelle Gonindard-Melodelima
......
#' @include internals.R
#'
#' @title ProcMod
#' @name procmod
#' @description blabla
#' @author Christelle Gonindard-Melodelima
#' @author Eric Coissac
......
#'
NULL
#' Simulate n points of dimension p.
#'
#' Points are simulated by drawing values of each dimension from a normal
......
......@@ -74,6 +74,16 @@ mc.soil <- read.table("data-raw/MicroCurvulatum/SOIL_CHEM.txt",
mc.soil <- as.matrix(mc.soil[row.names(mc.bacteria),5:10])
mc.geography <- read.table("data-raw/MicroCurvulatum/Coord_geo.txt",
row.names = 1,
header = 1,
na.strings = "NA"
)
mc.geography <- as.matrix(mc.geography[substr(row.names(mc.bacteria),
1,
nchar(row.names(mc.bacteria))-1),])
MicroCurvulatum = ProcMod::procmod.frame(bacteria = mc.bacteria,
fungi = mc.fungi,
plants = mc.plants,
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/procmod_frame.R
\name{as.procmod.frame.matrix}
\alias{as.procmod.frame.matrix}
\title{Coerce to a ProcMod Frame.}
\usage{
\method{as.procmod.frame}{matrix}(data, ...)
}
\description{
Coerce to a ProcMod Frame.
}
\author{
Eric Coissac
Christelle Gonindard-Melodelima
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/procmod_frame.R
\name{as.procmod.frame.pm}
\alias{as.procmod.frame.pm}
\title{Coerce to a ProcMod Frame.}
\usage{
\method{as.procmod.frame}{pm}(data, ...)
}
\description{
Coerce to a ProcMod Frame.
}
\author{
Eric Coissac
Christelle Gonindard-Melodelima
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/procmod_frame.R
\name{as.procmod.frame.procmod.frame}
\alias{as.procmod.frame.procmod.frame}
\title{Coerce to a ProcMod Frame.}
\usage{
\method{as.procmod.frame}{procmod.frame}(data, ...)
}
\description{
Coerce to a ProcMod Frame.
}
\author{
Eric Coissac
Christelle Gonindard-Melodelima
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/procmod.R
\docType{data}
\name{eukaryotes}
\alias{eukaryotes}
\alias{bacteria}
\alias{climat}
\alias{soil}
\alias{geography}
\title{DNA metabarcoding Australia South-North Gradient}
\format{five data.frame of 21 rows}
\usage{
data(eukaryotes)
data(bacteria)
data(climat)
data(soil)
data(geography)
}
\description{
This data set of five \code{data.frame}
is a simplified version of a full data set
describing biodiversity changes along a South-North
gradient on the Australian East Coast, from Sidney to
North Cap. The gradient is constituted of 21 locations.
}
\details{
\describe{
\item{bacteria}{is a 21 x 2150 \code{data.frame} describing bacterial
community at each one of the 21 locations.
Each number is the relative frequency of a molecular operational
taxonomy unit (MOTU) at a site after data cleaning and
averaging of 135 pontual measures.}
\item{bacteria}{is a 21 x 1393 \code{data.frame} describing eukariote
community at each one of the 21 locations.
Each number is the relative frequency of a molecular operational
taxonomy unit (MOTU) at a site after data cleaning and
averaging of 135 pontual measures.}
\item{climat}{is a 21 x 6 \code{data.frame} describing climatic conditions
at each site using worldclim descriptors (https://www.worldclim.org).
\describe{
\item{Aspect}{}
\item{TempSeasonality}{}
\item{MaxMonTemp}{Max Temperature of Warmest Month}
\item{MeanMonTempRange}{}
\item{AnnMeanTemp}{}
\item{Isothemality}{Mean Diurnal Range / Temperature Annual Range, with
\describe{
\item{Mean Diurnal Range}{Mean of monthly (max temp - min temp)}
\item{Temperature Annual Range}{Max Temperature of Warmest Month - Min Temperature of Coldest Month}
}
}}}
\item{soil}{s a 21 x 6 \code{data.frame} describing soil chemistery
at each site.
Each variable is reduced and centered
\describe{
\item{KLg}{Logarithm of the potassium concentration}
\item{pH}{Soil Ph}
\item{AlLg}{Logarithm of the aluminium concentration}
\item{FeLg}{Logarithm of the iron concentration}
\item{PLg}{Logarithm of the phosphorus concentration}
\item{SLg}{Logarithm of the sulphur concentration}
\item{CaLg}{Logarithm of the calcium concentration}
\item{MgLg}{Logarithm of the magnesium concentration}
\item{MnLg}{Logarithm of the manganese concentration}
\item{CNratio}{carbon / nitrogen concentration ratio}
\item{CLg}{Logarithm of the carbon concentration}
\item{NLg}{Logarithm of the nitrogen concentration}
}}
\item{geography}{}
}
}
\author{
Christelle Gonindard-Melodelima
Eric Coissac
}
\keyword{datasets}
......@@ -6,6 +6,13 @@
\usage{
bicenter(m)
}
\arguments{
\item{m}{a \code{numeric} matrix}
}
\value{
a \code{numeric} matrix centred by rows
and columns
}
\description{
colSums and rowSums of the returned matrix are all equal to zero.
}
......
......@@ -16,8 +16,8 @@ by the function \code{\link[permute]{how}}, or the number of
permutations required.}
\item{p.adjust.method}{the multiple test correction method used
to adjust p values. \code{\link[stats]{p.adjust.method}}
belongsone of the folowing values: \code{"holm"},
to adjust p values. \code{p.adjust.method}
belongs one of the folowing values: \code{"holm"},
\code{"hochberg"}, \code{"hommel"}, \code{"bonferroni"},
\code{"BH"}, \code{"BY"}, \code{"fdr"}, \code{"none"}.
The default is,set to \code{"holm"}.}
......@@ -31,6 +31,9 @@ procustean rotation (see \code{\link[ade4]{procuste.rtest}}).
\insertRef{Jackson:95:00}{ProcMod}
}
}
\seealso{
\code{\link[stats]{p.adjust}}
}
\author{
Eric Coissac
......
......@@ -2,12 +2,16 @@
% Please edit documentation in R/procmod_frame.R
\name{dim.procmod.frame}
\alias{dim.procmod.frame}
\title{Dimensions of a Matrix Frame.}
\title{Dimensions of a ProcMod Frame.}
\usage{
\method{dim}{procmod.frame}(x)
}
\arguments{
\item{x}{a \code{\link[ProcMod]{procmod.frame}}
object}
}
\description{
Dimensions of a Matrix Frame.
Dimensions of a ProcMod Frame.
}
\author{
Eric Coissac
......
......@@ -11,6 +11,10 @@
\item{nrows}{an interger value specifying the number of row
of the returned matrix}
\item{contrasts}{see the \code{contrasts.arg} argument
of the \code{\link[ProcMod]{procmod.frame}}
constructor.}
}
\value{
a new numeric matrix with correct size.
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/procmod_frame.R
\name{as.procmod.frame.array}
\alias{as.procmod.frame.array}
\title{Coerce to a ProcMod Frame.}
\name{is.procmod.frame}
\alias{is.procmod.frame}
\title{Check if an object is a ProcMod Frame.}
\usage{
\method{as.procmod.frame}{array}(data, ...)
is.procmod.frame(x)
}
\arguments{
\item{x}{a R \code{object to test}}
}
\value{
a \code{logical} value equals to
\code{TRUE} if \code{x} is a \code{procmod.frame},
\code{FALSE} otherwise.
}
\description{
Coerce to a ProcMod Frame.
Check if an object is a ProcMod Frame.
}
\author{
Eric Coissac
......
......@@ -10,17 +10,19 @@
\usage{
ortho(data, ...)
\method{ortho}{dist}(x, tol = 1e-07)
\method{ortho}{dist}(data, tol = 1e-07, ...)
\method{ortho}{matrix}(x, scale = FALSE)
\method{ortho}{matrix}(data, scale = FALSE, ...)