Title: Realize the Trait Abundance Distribution
Version: 1.0.0
Description: This analytical framework is based on an analysis of the shape of the trait abundance distributions to better understand community assembly processes, and predict community dynamics under environmental changes. This framework mobilized a study of the relationship between the moments describing the shape of the distributions: the skewness and the kurtosis (SKR). The SKR allows the identification of commonalities in the shape of trait distributions across contrasting communities. Derived from the SKR, we developed mathematical parameters that summarise the complex pattern of distributions by assessing (i) the R², (ii) the Y-intercept, (iii) the slope, (iv) the functional stability of community (TADstab), and, (v) the distance from specific distribution families (i.e., the distance from the skew-uniform family a limit to the highest degree of evenness: TADeve).
License: BSD_3_clause + file LICENSE
URL: https://forgemia.inra.fr/urep/data_processing/tad
BugReports: https://forgemia.inra.fr/urep/data_processing/tad/-/issues
Encoding: UTF-8
RoxygenNote: 7.3.2
Depends: R (≥ 3.5)
Imports: doFuture, foreach, mblm (≥ 0.12), methods, stats
Suggests: Cairo, covr, dplyr, devtools, future (≥ 1.33), ggplot2 (≥ 3.5), ggpubr (≥ 0.6), knitr, Matrix (≥ 1.6), pkgdown, rlang, rmarkdown, roxygen2, testthat (≥ 3.0), tinytex
Collate: utils.R saving_and_loading_data.R graph.R tad.R data.R
Config/testthat/edition: 3
Config/testthat/parallel: true
Language: en-US
VignetteBuilder: knitr
LazyData: true
LazyDataCompression: bzip2
NeedsCompilation: no
Packaged: 2024-11-28 09:59:57 UTC; lain
Author: Nathan Rondeau [aut], Yoann Le Bagousse-Pinguet ORCID iD [aut], Raphael Martin ORCID iD [aut], Lain Pavot [aut, cre], Pierre Liancourt ORCID iD [aut], Nicolas Gross ORCID iD [aut], INRAe/UREP [cph]
Maintainer: Lain Pavot <lain.pavot@inrae.fr>
Repository: CRAN
Date/Publication: 2024-11-28 12:20:02 UTC

Example dataset containing some traits

Description

Example dataset containing some traits

Usage

AB

Format

AB

A data.frame with 102 columns and 96 rows:

Plot

Factor w/ 8 levels "4","6","11",..: 2 4 6 8 2 4 6 8 2 ...

Year

Factor w/ 12 levels "2010","2011",..: 1 1 1 1 2 2 2 2 3 3 ...

Treatment

Factor w/ 2 levels "Mown_NPK",..: 1 1 1 1 1 1 1 1 1 ...

Bloc

Factor w/ 2 levels "1","2": 1 1 2 2 1 1 2 2 1

SP1

num 0, 0.84, 0, 9.15, 0, ...

SP3

num 0, 0.84, 0, 0, 0, ...

...


The CONSTANTS constant

Description

Provides a set of constants to prevent typo and provide some defauts values to functions in the TAD. Among those constants are:

Usage

CONSTANTS

Format

An object of class list of length 6.


Example dataset of abundance_dataframe

Description

Example dataset of abundance_dataframe

Usage

abundance_dataframe

Format

'abundance_dataframe

A data.frame with 2016 rows and 99 columns:

number

int 0 0 0 0 0 0 0 0 0 0 ...

index1

num 0 0.84 0 9.15 0 ...

index2

num 0 0.84 0 0 0 ...

index3

num 0 0 0 0 0 0 0 0 0 0 ...

... Example output of get_abundance_df


skr ses genration/save/load

Description

skr ses genration/save/load

Usage

build_skr_ses(
  statistics_factor_name,
  significativity_threshold,
  stat_per_rand_file = NULL,
  skr_param = NULL,
  stat_skr_param_file = NULL,
  regenerate_ses_skr = FALSE,
  skew_uniform = FALSE
)

check_parameter_type

Description

check_parameter_type

Usage

check_parameter_type(value, expected, or_null = FALSE)

check_parameter_value

Description

check_parameter_value

Usage

check_parameter_value(value, checker, expected_description, fmt = NULL)

parameters checkings

Description

Checks all parameters of the TAD and raises errors if parameters' values are incoherent.

Usage

check_parameters(
  weights = NULL,
  weights_factor = NULL,
  trait_data = NULL,
  randomization_number = NULL,
  aggregation_factor_name = NULL,
  statistics_factor_name = NULL,
  seed = NULL,
  abundance_file = NULL,
  weighted_moments_file = NULL,
  stat_per_obs_file = NULL,
  stat_per_rand_file = NULL,
  stat_skr_param_file = NULL,
  regenerate_abundance_df = NULL,
  regenerate_weighted_moments_df = NULL,
  regenerate_stat_per_obs_df = NULL,
  regenerate_stat_per_rand_df = NULL,
  significativity_threshold = NULL,
  lin_mod = NULL,
  slope_distance = NULL,
  intercept_distance = NULL,
  csv_tsv_load_parameters = NULL
)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

weights_factor

the dataframe which contains the different factor linked to the weights

trait_data

a vector of the data linked to the different factor

randomization_number

the number of random abundance matrix to generate

aggregation_factor_name

vector of factor name for the generation of random matrix

statistics_factor_name

vector of factor name for the computation of statistics for each generated matrix

seed

the seed of the pseudo random number generator

abundance_file

the path and name of the RDS file to load/save the dataframe which contains the observed data and the generated matrix

weighted_moments_file

the path and name of the RDS file to load/save the dataframe which contains the calculated moments

stat_per_obs_file

the path and name of the RDS file to load/save the dataframe which contains the statistics for each observed row regarding the random ones

stat_per_rand_file

the path and name of the RDS file to load/save the dataframe which contains the statistics for each random matrix generated

stat_skr_param_file

default=NULL You can provide the output to write the SKR statistics results to.

regenerate_abundance_df

boolean to specify if the abundance dataframe is computed again

regenerate_weighted_moments_df

boolean to specify if the weighted moments dataframe is computed again

regenerate_stat_per_obs_df

boolean to specify if the statistics per observation dataframe is computed again

regenerate_stat_per_rand_df

boolean to specify if the statistics per random matrix dataframe is computed again

significativity_threshold

the significance threshold to consider that the observed value is in the randomized value

lin_mod

Indicates the type of linear model to use for (SKR): choose "lm" or "mblm"

slope_distance

slope of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

intercept_distance

intercept of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

csv_tsv_load_parameters

a list of parameters for each data structure we want to load. Each element must be named after the data structure we want to load.


input filter

Description

input filter

Usage

filter_na_empty(abundance_df, weights, weights_factor, trait_data)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

weights_factor

the dataframe which contains the different factor linked to the weights

trait_data

a vector of the data linked to the different factor


Example dataset of filtred results just after abundances generation

Description

Example dataset of filtred results just after abundances generation

Usage

filtered_abundances

Format

An object of class list of length 4.


Generate random matrix

Description

Generate and save random matrix

Usage

generate_random_matrix(
  weights,
  aggregation_factor = NULL,
  randomization_number,
  seed = NULL
)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

aggregation_factor

the dataframe of factor to take into account for the randomization

randomization_number

the number of random abundance matrix to generate

seed

the seed of the pseudo random number generator

Value

a data.frame of randomization_number observations

Examples

aggregation_factor_name <- c("Year", "Bloc")
weights_factor = TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")]
aggregation_factor <- as.data.frame(
  weights_factor[, aggregation_factor_name]
)
random_matrix <- TAD::generate_random_matrix(
  weights = TAD::AB[, 5:102],
  aggregation_factor = aggregation_factor,
  randomization_number = 100,
  seed = 1312
)
head(random_matrix)

stats per random generation

Description

stats per random generation

Usage

generate_stat_per_rand(
  weights,
  statistics_factor_name,
  weights_factor,
  weighted_moments,
  randomization_number,
  abundance_df,
  lin_mod
)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

statistics_factor_name

vector of factor name for the computation of statistics for each generated matrix

weights_factor

the dataframe which contains the different factor linked to the weights

randomization_number

the number of random abundance matrix to generate

lin_mod

Indicates the type of linear model to use for (SKR): choose "lm" or "mblm"


abundance generation

Description

abundance generation

Usage

get_abundance_df(
  weights,
  weights_factor,
  randomization_number,
  abundance_file,
  regenerate_abundance_df,
  aggregation_factor_name,
  seed
)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

weights_factor

the dataframe which contains the different factor linked to the weights

randomization_number

the number of random abundance matrix to generate

abundance_file

the path and name of the RDS file to load/save the dataframe which contains the observed data and the generated matrix

regenerate_abundance_df

boolean to specify if the abundance dataframe is computed again

aggregation_factor_name

vector of factor name for the generation of random matrix

seed

the seed of the pseudo random number generator


stats per random genration/save/load

Description

stats per random genration/save/load

Usage

get_stat_per_rand(
  weights,
  stat_per_rand_file,
  regenerate_stat_per_rand_df,
  statistics_factor_name,
  weights_factor,
  randomization_number,
  weighted_moments,
  abundance_df,
  lin_mod
)

weighted moments generation

Description

weighted moments generation

Usage

get_weighted_mnts(
  weights_factor,
  trait_data,
  weighted_moments_file,
  regenerate_weighted_moments_df,
  abundance_df,
  randomization_number,
  slope_distance,
  intercept_distance,
  factor_names = NULL
)

Arguments

weights_factor

the dataframe which contains the different factor linked to the weights

trait_data

a vector of the data linked to the different factor

weighted_moments_file

the path and name of the RDS file to load/save the dataframe which contains the calculated moments

regenerate_weighted_moments_df

boolean to specify if the weighted moments dataframe is computed again

randomization_number

the number of random abundance matrix to generate

slope_distance

slope of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

intercept_distance

intercept of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)


Launch the analysis

Description

Launch distribution analysis

Usage

launch_analysis_tad(
  weights,
  weights_factor,
  trait_data,
  randomization_number,
  aggregation_factor_name = NULL,
  statistics_factor_name = NULL,
  seed = NULL,
  abundance_file = NULL,
  weighted_moments_file = NULL,
  stat_per_obs_file = NULL,
  stat_per_rand_file = NULL,
  stat_skr_param_file = NULL,
  regenerate_abundance_df = FALSE,
  regenerate_weighted_moments_df = FALSE,
  regenerate_stat_per_obs_df = FALSE,
  regenerate_stat_per_rand_df = FALSE,
  regenerate_stat_skr_df = FALSE,
  significativity_threshold = CONSTANTS$DEFAULT_SIGNIFICATIVITY_THRESHOLD,
  lin_mod = CONSTANTS$DEFAULT_LIN_MOD,
  slope_distance = CONSTANTS$DEFAULT_SLOPE_DISTANCE,
  intercept_distance = CONSTANTS$DEFAULT_INTERCEPT_DISTANCE,
  csv_tsv_load_parameters = list()
)

Arguments

weights

the dataframe of weights, one row correspond to a series of observation

weights_factor

the dataframe which contains the different factor linked to the weights

trait_data

a vector of the data linked to the different factor

randomization_number

the number of random abundance matrix to generate

aggregation_factor_name

vector of factor name for the generation of random matrix

statistics_factor_name

vector of factor name for the computation of statistics for each generated matrix

seed

the seed of the pseudo random number generator

abundance_file

the path and name of the RDS file to load/save the dataframe which contains the observed data and the generated matrix

weighted_moments_file

the path and name of the RDS file to load/save the dataframe which contains the calculated moments

stat_per_obs_file

the path and name of the RDS file to load/save the dataframe which contains the statistics for each observed row regarding the random ones

stat_per_rand_file

the path and name of the RDS file to load/save the dataframe which contains the statistics for each random matrix generated

stat_skr_param_file

default=NULL You can provide the output to write the SKR statistics results to.

regenerate_abundance_df

boolean to specify if the abundance dataframe is computed again

regenerate_weighted_moments_df

boolean to specify if the weighted moments dataframe is computed again

regenerate_stat_per_obs_df

boolean to specify if the statistics per observation dataframe is computed again

regenerate_stat_per_rand_df

boolean to specify if the statistics per random matrix dataframe is computed again

regenerate_stat_skr_df

boolean to specify if the stats SKR dataframe is computed again

significativity_threshold

the significance threshold to consider that the observed value is in the randomized value

lin_mod

Indicates the type of linear model to use for (SKR): choose "lm" or "mblm"

slope_distance

slope of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

intercept_distance

intercept of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

csv_tsv_load_parameters

a list of parameters for each data structure we want to load. Each element must be named after the data structure we want to load.

Value

A list of the 9 following named elements:

Examples


  output_path <- file.path(tempdir(), "outputs")
  dir.create(output_path)
  results <- TAD::launch_analysis_tad(
    weights = TAD::AB[, 5:102],
    weights_factor = TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")],
    trait_data = log(TAD::trait[["SLA"]]),
    aggregation_factor_name = c("Year", "Bloc"),
    statistics_factor_name = (statistics_factor_name <- c("Treatment")),
    regenerate_abundance_df = TRUE,
    regenerate_weighted_moments_df = TRUE,
    regenerate_stat_per_obs_df = TRUE,
    regenerate_stat_per_rand_df = TRUE,
    weighted_moments_file = file.path(output_path, "weighted_moments.csv"),
    stat_per_obs_file = file.path(output_path, "stat_per_obs.csv"),
    stat_per_rand_file = file.path(output_path, "stat_per_rand.csv"),
    stat_skr_param_file = file.path(output_path, "stat_skr_param.csv"),
    randomization_number = 20,
    seed = 1312,
    significativity_threshold = c(0.05, 0.95),
    lin_mod = "lm",
    slope_distance = (
      slope_distance <- TAD::CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE
    ),
    intercept_distance = (
      intercept_distance <- TAD::CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE
    )
  )
  moments_graph <- TAD::moments_graph(
    moments_df = results$weighted_moments,
    statistics_per_observation = results$statistics_per_observation,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    output_path = file.path(output_path, "moments_graph.jpeg"),
    dpi = 100
  )
  skr_graph <- TAD::skr_graph(
    moments_df = results$weighted_moments,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    output_path = file.path(output_path, "skr_graph.jpeg"),
    slope_distance = slope_distance,
    intercept_distance = intercept_distance,
    dpi = 100
  )
  skr_param_graph <- TAD::skr_param_graph(
    skr_param = results$ses_skr,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    slope_distance = slope_distance,
    intercept_distance = intercept_distance,
    save_skr_param_graph = file.path(output_path, "skr_param_graph.jpeg"),
    dpi = 100
  )

  unlink(output_path, recursive = TRUE, force = TRUE)


load_abundance_dataframe

Description

load_abundance_dataframe

Usage

load_abundance_dataframe(path, ...)

Arguments

path

the path to the file to load

...

a set of parameters provided to load_depending_on_format may contain some operations to apply to format/cast CSV or TSV data which are almost typeless by default

Value

an abundance dataframe, with the column number caster into integers and rownames casted into integers.


load_depending_on_format

Description

load_depending_on_format

Usage

load_depending_on_format(path, env_attr = NULL, ...)

Arguments

path

the path of the file to load

env_attr

the name of the object to load

...

only used in case of CSV loading - passed to load_tad_table see load_tad_table$... for more informations


load_package

Description

load_package

Usage

load_package(package_name)

load_stat_skr_param

Description

load_stat_skr_param

Usage

load_stat_skr_param(path, ...)

Arguments

path

the path to the file to load

...

a set of parameters provided to load_depending_on_format may contain some operations to apply to format/cast CSV or TSV data which are almost typeless by default

Value

a stats SKR parameters dataframe with distance_to_family_ses and cv_distance_to_family_ses casted into doubles and with rownames casted into integers.


load_statistics_per_obs

Description

load_statistics_per_obs

Usage

load_statistics_per_obs(path, ...)

Arguments

path

the path to the file to load

...

a set of parameters provided to load_depending_on_format may contain some operations to apply to format/cast CSV or TSV data which are almost typeless by default

Value

a stats par observations dataframe with rownames casted into integers.


load_statistics_per_random

Description

load_statistics_per_random

Usage

load_statistics_per_random(path, ...)

Arguments

path

the path to the file to load

...

a set of parameters provided to load_depending_on_format may contain some operations to apply to format/cast CSV or TSV data which are almost typeless by default

Value

a stats per randon dataframe with distance_to_family and cv_distance_to_family casted into doubles and with rownames casted into integers.


load_tad_table

Description

load_tad_table

Usage

load_tad_table(
  path,
  sep,
  table_name = NULL,
  factor_names = NULL,
  character_names = NULL,
  ...
)

Arguments

path

the path to the file to load

sep

the separator used for this csv/tsv file

table_name

the name of the object to load

factor_names

provide the name of factor columns. A as.factor function will be applied to the provided columns.

character_names

provide the name of character columns. A as.character function will be applied to the provided columns.

...

a set of functions to apply to the result's attribute. if a = as.numeric in ..., then result$a <- as.numeric(result$a) any other function than as.numeric can be used


load_weighted_moments

Description

load_weighted_moments

Usage

load_weighted_moments(path, ...)

Arguments

path

the path to the file to load

...

a set of parameters provided to load_depending_on_format may contain some operations to apply to format/cast CSV or TSV data which are almost typeless by default

Value

a weighted moments dataframe with the column number caster into integers and rownames casted into integers.


moments_graph

Description

Graph of the distributions' moments (mean, variance, skewness and kurtosis) compared to null model

Usage

moments_graph(
  moments_df,
  statistics_per_observation,
  statistics_factor_name,
  statistics_factor_name_breaks = NULL,
  statistics_factor_name_col = NULL,
  output_path = NULL,
  dpi = 600
)

Arguments

moments_df

Moments data frame (mean, variance, skewness, kurtosis)

statistics_per_observation

SES of the Moments data frame and significance compared to null model

statistics_factor_name

column of data use for colors discrimination

statistics_factor_name_breaks

vector of factor levels of the statistics_factor_name, same dimension than statistics_factor_name_col

statistics_factor_name_col

vector of colors, same dimension than statistics_factor_name_breaks

output_path

The path to save the graph

dpi

The dpi number to use when we generate png/jpg graph

Value

A graph instance

Examples




  results <- TAD::launch_analysis_tad(
    weights = TAD::AB[, 5:102],
    weights_factor = TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")],
    trait_data = log(TAD::trait[["SLA"]]),
    aggregation_factor_name = c("Year", "Bloc"),
    statistics_factor_name = (statistics_factor_name <- c("Treatment")),
    randomization_number = 100
  )

  # if you want to display the graph
  graph <- TAD::moments_graph(
    moments_df = results$weighted_moments,
    statistics_per_observation = results$statistics_per_observation,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159")
  )

  plot(graph)

  # if you want to save the graph as a file
  # either jpg, jpeg, png or svg are
  output_path <- file.path(tempdir(), "outputs")
  dir.create(output_path)
  TAD::moments_graph(
    moments_df = results$weighted_moments,
    statistics_per_observation = results$statistics_per_observation,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    output_path = file.path(output_path, "moment_graph.png")
  )

  unlink(output_path, recursive = TRUE, force = TRUE)




Compare a value to random values

Description

Compute different statistics (standardized by the distribution of random values).

Usage

null_model_distribution_stats(
  observed_value,
  random_values,
  significance_threshold = c(0.05, 0.95),
  remove_nas = TRUE
)

Arguments

observed_value

the observed value

random_values

the random Values

significance_threshold

the array of values used to compute the quantile (c(0.025, 0.975) by default)

remove_nas

boolean - tells weither to remoe NAs or not

Value

a list corresponding to :

Examples


null_model_distribution_stats(
  observed_value = 2,
  random_values = c(1, 4, 5, 6, 8),
  significance_threshold = c(0.025, 0.975)
)


save_abundance_dataframe

Description

This function provides a secured way to save abundance_dataframe dataframe. The more generic functionprovided by TAD save_depending_on_format expects saves object using their name, but saves nothing if the provided name is not correct, or mya even save an unwanted object. This function provides a way to verify the object you want to save, and so, it is more secured.

Usage

save_abundance_dataframe(path, object = NULL)

Arguments

path

the path of the file to load

object

the object to save

Value

NULL - called for side effects


save_depending_on_format

Description

Saves data in TSV, CSV, RDA or RDS, depending on the file's extension. CSV and TSVs are saved the same way: with double quotes (ascii character 34, or 0x22 " ), EOL is a newline (ascii character 10, or 0x0A), NAs are saved as "NA", decimal point are latin point (ascii character 46, or 0x2E . ), row names and colnames are added and the encoding is UTF-8. The only thing that changes is the separator: A comma (ascii character 44, or 0x2C , ) for CSV files and a tabulation (ascii character 9, or 0x09) for TSV files.

Usage

save_depending_on_format(file, var_name, compress = "bzip2")

Arguments

file

the path of the file to save

var_name

the name of the object to save

compress

compression algo for rds/rda, defaults to bzip2

Value

NULL - called for side effects


observations genration/save/load

Description

observations genration/save/load

Usage

save_obs_df(
  weights_factor,
  stat_per_obs_file,
  regenerate_stat_per_obs_df,
  weighted_moments,
  randomization_number,
  significativity_threshold
)

Arguments

weights_factor

the dataframe which contains the different factor linked to the weights

stat_per_obs_file

the path and name of the RDS file to load/save the dataframe which contains the statistics for each observed row regarding the random ones

regenerate_stat_per_obs_df

boolean to specify if the statistics per observation dataframe is computed again

randomization_number

the number of random abundance matrix to generate

significativity_threshold

the significance threshold to consider that the observed value is in the randomized value


save_stat_skr_param

Description

This function provides a secured way to save stat_skr_param dataframe. The more generic functionprovided by TAD save_depending_on_format expects saves object using their name, but saves nothing if the provided name is not correct, or mya even save an unwanted object. This function provides a way to verify the object you want to save, and so, it is more secured.

Usage

save_stat_skr_param(path, object = NULL)

Arguments

path

the path of the file to load

object

the object to save

Value

NULL - called for side effects


save_statistics_per_obs

Description

This function provides a secured way to save statistics_per_obs dataframe. The more generic functionprovided by TAD save_depending_on_format expects saves object using their name, but saves nothing if the provided name is not correct, or mya even save an unwanted object. This function provides a way to verify the object you want to save, and so, it is more secured.

Usage

save_statistics_per_obs(path, object = NULL)

Arguments

path

the path of the file to load

object

the object to save

Value

NULL - called for side effects


save_statistics_per_random

Description

This function provides a secured way to save statistics_per_random dataframe. The more generic functionprovided by TAD save_depending_on_format expects saves object using their name, but saves nothing if the provided name is not correct, or mya even save an unwanted object. This function provides a way to verify the object you want to save, and so, it is more secured.

Usage

save_statistics_per_random(path, object = NULL)

Arguments

path

the path of the file to load

object

the object to save

Value

NULL - called for side effects


save_weighted_moments

Description

This function provides a secured way to save weighted_moments dataframe. The more generic functionprovided by TAD save_depending_on_format expects saves object using their name, but saves nothing if the provided name is not correct, or mya even save an unwanted object. This function provides a way to verify the object you want to save, and so, it is more secured.

Usage

save_weighted_moments(path, object = NULL)

Arguments

path

the path of the file to load

object

the object to save

Value

NULL - called for side effects


skr_custom_uniform_names

Description

skr_custom_uniform_names

Usage

skr_custom_uniform_names(skr)

skr_graph

Description

Graph of the SKR, compared to null model

Usage

skr_graph(
  moments_df,
  statistics_factor_name,
  statistics_factor_name_breaks = NULL,
  statistics_factor_name_col = NULL,
  slope_distance = CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE,
  intercept_distance = CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE,
  output_path = NULL,
  dpi = 600
)

Arguments

moments_df

moments data frame (mean, variance, skewness, kurtosis)

statistics_factor_name

column of data use for colors discrimination

statistics_factor_name_breaks

vector of factor levels of the statistics_factor_name, same dimension than statistics_factor_name_col

statistics_factor_name_col

vector of colors, same dimension than statistics_factor_name_breaks

slope_distance

slope of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform)

intercept_distance

intercept of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform)

output_path

The path to save the graph

dpi

The dpi number to use when we generate png/jpg graph

Value

A graph instance

Examples




results <- TAD::launch_analysis_tad(
  weights = TAD::AB[, 5:102],
  weights_factor = TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")],
  trait_data = log(TAD::trait[["SLA"]]),
  aggregation_factor_name = c("Year", "Bloc"),
  statistics_factor_name = (statistics_factor_name <- c("Treatment")),
  randomization_number = 100,
  slope_distance = (
    slope_distance <- TAD::CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE
  ),
  intercept_distance = (
    intercept_distance <- TAD::CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE
  )
)

graph <- TAD::skr_graph(
  moments_df = results$weighted_moments,
  statistics_factor_name = statistics_factor_name,
  statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
  statistics_factor_name_col = c("#1A85FF", "#D41159"),
  slope_distance = slope_distance,
  intercept_distance = intercept_distance
)

plot(graph)

output_path <- file.path(tempdir(), "outputs")
dir.create(output_path)
TAD::skr_graph(
  moments_df = results$weighted_moments,
  statistics_factor_name = statistics_factor_name,
  statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
  statistics_factor_name_col = c("#1A85FF", "#D41159"),
  slope_distance = slope_distance,
  intercept_distance = intercept_distance,
  dpi = 200,
  output_path = file.path(output_path, "moment_graph.png")
)

unlink(output_path, recursive = TRUE, force = TRUE)




skr_param_graph

Description

Graph of the parameters computed from the SKR, compared to null model

Usage

skr_param_graph(
  skr_param,
  statistics_factor_name,
  statistics_factor_name_breaks = NULL,
  statistics_factor_name_col = NULL,
  slope_distance = CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE,
  intercept_distance = CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE,
  save_skr_param_graph = NULL,
  dpi = 600
)

Arguments

skr_param

SES of SKR parameters data frame (SES and Significance)

statistics_factor_name

column of data use for colors discrimination

statistics_factor_name_breaks

vector of factor levels of the statistics_factor_name, same dimension than statistics_factor_name_col

statistics_factor_name_col

vector of colors, same dimension than statistics_factor_name_breaks

slope_distance

slope of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

intercept_distance

intercept of the theoretical distribution law (default: slope = 1 intercept = 1.86 skew-uniform distribution family)

save_skr_param_graph

The path to save the graph

dpi

The dpi number to use when we generate png/jpg graph

Value

A graph instance

Examples




  results <- TAD::launch_analysis_tad(
    weights = TAD::AB[, 5:102],
    weights_factor = TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")],
    trait_data = log(TAD::trait[["SLA"]]),
    aggregation_factor_name = c("Year", "Bloc"),
    statistics_factor_name = (statistics_factor_name <- c("Treatment")),
    randomization_number = 100,
    slope_distance = (
      slope_distance <- TAD::CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE
    ),
    intercept_distance = (
      intercept_distance <- TAD::CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE
    )
  )

  # if you want to display the graph
  graph <- TAD::skr_param_graph(
    skr_param = results$ses_skr,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    slope_distance = slope_distance,
    intercept_distance = intercept_distance
  )

  plot(graph)

  output_path <- file.path(tempdir(), "outputs")
  dir.create(output_path)

  # if you want to save the graph as a file
  # either jpg, jpeg, png or svg are
  TAD::skr_param_graph(
    skr_param = results$ses_skr,
    statistics_factor_name = statistics_factor_name,
    statistics_factor_name_breaks = c("Mown_Unfertilized", "Mown_NPK"),
    statistics_factor_name_col = c("#1A85FF", "#D41159"),
    slope_distance = slope_distance,
    intercept_distance = intercept_distance,
    save_skr_param_graph = file.path(output_path, "skr_param_graph.jpeg"),
    dpi = 300
  )

  unlink(output_path, recursive = TRUE, force = TRUE)




Example dataset of skr_ses

Description

Example dataset of skr_ses

Usage

skr_ses_dataframe

Format

skr_ses

A data.frame - todo = describe the df content: Example output of skr_ses


skr_standard_uniform_names

Description

skr_standard_uniform_names

Usage

skr_standard_uniform_names(skr)

Example dataset of stat_per_obs_dataframe

Description

Example dataset of stat_per_obs_dataframe

Usage

stat_per_obs_dataframe

Format

stat_per_obs_dataframe

A data.frame - it contains the provided factors, and the following rows - each has 96 obs:

standardized_observedmean

num -0.847 -0.888 ...

standardized_min_quantilemean

num -1.95 -1.58 ...

standardized_max_quantilemean

num 1.49 1.18 ...

significancemean

logi FALSE FALSE ...

standardized_observedvariance

num -0.635 -0.746 ...

standardized_min_quantilevariance

num -0.844 -1.183 ...

standardized_max_quantilevariance

num 1.07 2.23 ...

significancevariance

logi FALSE FALSE ...

standardized_observedskewness

num 0.904 1.458 ...

standardized_min_quantileskewness

num -1.21 -1.56 ...

standardized_max_quantileskewness

num 1.23 1.43 ...

significanceskewness

logi FALSE TRUE ...

standardized_observedkurtosis

num 1.61 3.17 ...

standardized_min_quantilekurtosis

num -0.654 -1.436 ...

standardized_max_quantilekurtosis

num 0.996 1.717 ...

significancekurtosis

logi TRUE TRUE ...

Example output of get_stat_per_rand


Example dataset of stat_per_rand_dataframe

Description

Example dataset of stat_per_rand_dataframe

Usage

stat_per_rand_dataframe

Format

stat_per_rand_dataframe

A data.frame - of 8 columns and 42 rows.

number

int 0 0 1 1 2 2 3 3 4 4 ...

Treatment

Factor w/ 2 levels

slope

num 0.826 0.832 1.406 ...

intercept

num 4.54 2.72 2.46 ...

rsquare

num 0.201 0.216 ...

tad_stab

num 1.856 0.49 ...

distance_to_family

num 3.063 ...

cv_distance_to_family

num 144 ...

Example output of stat_per_rand_dataframe


Example dataset containing some traits

Description

Example dataset containing some traits

Usage

trait

Format

trait

A data.frame with two columns and 98 rows:

Species

chr sp1, sp2, ...

SLA

num 15.4, 32, 32.5, ...


Example dataset of weighted_moments_dataframe

Description

Example dataset of weighted_moments_dataframe

Usage

weighted_moments_dataframe

Format

weighted_moments_dataframe

A data.frame - todo = describe the df content: Example output of weighted_moments_dataframe


Compute the weighted mean, variance, skewness and kurtosis

Description

Compute the weighted mean, variance, skewness and kurtosis of data with given weights

Usage

weighted_mvsk(data, weights)

Arguments

data

the data

weights

the vector or matrix of weights corresponding to the data (each row corresponding to an iteration of data)

Value

the list of weighted mean, variance, skewness and kurtosis of the data

Examples


weighted_mvsk(
  data = c(1, 2, 3),
  weights = matrix(data = c(1, 1, 1, 2, 1, 3), nrow = 2, ncol = 3)
)