graph-outputs

The TAD package provides some Graph outputs functions


weights <- TAD::AB[, 5:102]
weights_factor <- TAD::AB[, c("Year", "Plot", "Treatment", "Bloc")]
trait_data <- log(TAD::trait[["SLA"]][seq_len(ncol(weights))])
aggregation_factor_name <- c("Year", "Bloc")
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
regenerate_stat_skr_df <- TRUE
randomization_number <- 100
seed <- 1312
significativity_threshold <- c(0.025, 0.975)
lin_mod <- "lm"
slope_distance <- TAD:::CONSTANTS$SKEW_UNIFORM_SLOPE_DISTANCE
intercept_distance <- TAD:::CONSTANTS$SKEW_UNIFORM_INTERCEPT_DISTANCE

future::plan(future::multisession)
results <- TAD::launch_analysis_tad(
  weights = weights,
  weights_factor = weights_factor,
  trait_data = trait_data,
  randomization_number = randomization_number,
  aggregation_factor_name = aggregation_factor_name,
  statistics_factor_name = statistics_factor_name,
  seed = seed,
  regenerate_abundance_df = TRUE,
  regenerate_weighted_moments_df = TRUE,
  regenerate_stat_per_obs_df = TRUE,
  regenerate_stat_per_rand_df = TRUE,
  regenerate_stat_skr_df = TRUE,
  significativity_threshold = significativity_threshold,
  lin_mod = lin_mod,
  slope_distance = slope_distance,
  intercept_distance = intercept_distance
)
future::plan(future::sequential)

moments_graph function


str(results$weighted_moments)
#> 'data.frame':    9696 obs. of  10 variables:
#>  $ Year        : Factor w/ 12 levels "2010","2011",..: 1 1 1 1 2 2 2 2 3 3 ...
#>  $ Plot        : Factor w/ 8 levels "4","6","11","13",..: 2 4 6 8 2 4 6 8 2 4 ...
#>  $ Treatment   : Factor w/ 2 levels "Mown_NPK","Mown_Unfertilized": 1 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 1 ...
#>  $ number      : int  0 0 0 0 0 0 0 0 0 0 ...
#>  $ mean        : num  3.19 3.22 3.24 3.2 3.2 ...
#>  $ variance    : num  0.0233 0.0362 0.0317 0.0515 0.0343 ...
#>  $ skewness    : num  1.082 1.157 1.911 0.116 1.108 ...
#>  $ kurtosis    : num  10.78 7.82 7.62 4.67 8.18 ...
#>  $ distance_law: num  7.75 4.62 2.11 2.8 5.09 ...
str(results$statistics_per_observation)
#> 'data.frame':    96 obs. of  20 variables:
#>  $ Year                             : Factor w/ 12 levels "2010","2011",..: 1 1 1 1 2 2 2 2 3 3 ...
#>  $ Plot                             : Factor w/ 8 levels "4","6","11","13",..: 2 4 6 8 2 4 6 8 2 4 ...
#>  $ Treatment                        : Factor w/ 2 levels "Mown_NPK","Mown_Unfertilized": 1 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 1 ...
#>  $ standardized_observedmean        : num  -0.939 -0.985 -0.632 -0.772 -0.78 ...
#>  $ standardized_min_quantilemean    : num  -2.14 -1.92 -1.94 -1.83 -1.74 ...
#>  $ standardized_max_quantilemean    : num  2.23 1.94 1.71 1.95 1.74 ...
#>  $ significancemean                 : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
#>  $ standardized_observedvariance    : num  -0.546 -0.397 -0.937 -0.241 -0.487 ...
#>  $ standardized_min_quantilevariance: num  -0.939 -1.052 -1.482 -1.36 -1.302 ...
#>  $ standardized_max_quantilevariance: num  2.03 2.33 2.04 2.32 2.5 ...
#>  $ significancevariance             : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
#>  $ standardized_observedskewness    : num  1.034 1.402 2.854 0.358 1.349 ...
#>  $ standardized_min_quantileskewness: num  -2.22 -2.39 -1.82 -2.04 -2.14 ...
#>  $ standardized_max_quantileskewness: num  2 1.84 1.74 1.87 1.89 ...
#>  $ significanceskewness             : logi  FALSE FALSE TRUE FALSE FALSE FALSE ...
#>  $ standardized_observedkurtosis    : num  1.723 0.966 2.092 1.052 2.439 ...
#>  $ standardized_min_quantilekurtosis: num  -0.928 -1.015 -0.778 -1.049 -0.99 ...
#>  $ standardized_max_quantilekurtosis: num  2.53 2.35 2.6 2.88 2.33 ...
#>  $ significancekurtosis             : logi  FALSE FALSE FALSE FALSE TRUE FALSE ...
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")
)
moments_graph

skr_graph function

str(results$weighted_moments)
#> 'data.frame':    9696 obs. of  10 variables:
#>  $ Year        : Factor w/ 12 levels "2010","2011",..: 1 1 1 1 2 2 2 2 3 3 ...
#>  $ Plot        : Factor w/ 8 levels "4","6","11","13",..: 2 4 6 8 2 4 6 8 2 4 ...
#>  $ Treatment   : Factor w/ 2 levels "Mown_NPK","Mown_Unfertilized": 1 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 1 ...
#>  $ number      : int  0 0 0 0 0 0 0 0 0 0 ...
#>  $ mean        : num  3.19 3.22 3.24 3.2 3.2 ...
#>  $ variance    : num  0.0233 0.0362 0.0317 0.0515 0.0343 ...
#>  $ skewness    : num  1.082 1.157 1.911 0.116 1.108 ...
#>  $ kurtosis    : num  10.78 7.82 7.62 4.67 8.18 ...
#>  $ distance_law: num  7.75 4.62 2.11 2.8 5.09 ...
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"),
  slope_distance = slope_distance,
  intercept_distance = intercept_distance
)
skr_graph
#> Warning: Removed 5 rows containing non-finite outside the scale range
#> (`stat_smooth()`).
#> Warning: Removed 5 rows containing missing values or values outside the scale range
#> (`geom_point()`).

skr_param_graph function

str(results$ses_skr)
#> 'data.frame':    2 obs. of  13 variables:
#>  $ slope_ses       : num  -1.71 -1.7
#>  $ slope_signi     : logi  TRUE TRUE
#>  $ intercept_ses   : num  7.9253 -0.0909
#>  $ intercept_signi : logi  TRUE FALSE
#>  $ rsquare_ses     : num  -1.21 -1.13
#>  $ rsquare_signi   : logi  FALSE FALSE
#>  $ tad_stab_ses    : num  2.3 -2.13
#>  $ tad_stab_signi  : logi  TRUE TRUE
#>  $ tad_eve_ses     : num  4.21 -2.17
#>  $ tad_eve_signi   : logi  TRUE TRUE
#>  $ cv_tad_eve_ses  : num  -1.03 -1.61
#>  $ cv_tad_eve_signi: logi  FALSE TRUE
#>  $ Treatment       : chr  "Mown_NPK" "Mown_Unfertilized"
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
)
skr_param_graph
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).

SKR graph when skew-non-uniform distribution


results <- TAD::launch_analysis_tad(
  weights = weights,
  weights_factor = weights_factor,
  trait_data = trait_data,
  randomization_number = randomization_number,
  aggregation_factor_name = aggregation_factor_name,
  statistics_factor_name = statistics_factor_name,
  seed = seed,
  regenerate_abundance_df = TRUE,
  regenerate_weighted_moments_df = TRUE,
  regenerate_stat_per_obs_df = TRUE,
  regenerate_stat_per_rand_df = TRUE,
  regenerate_stat_skr_df = TRUE,
  significativity_threshold = significativity_threshold,
  lin_mod = lin_mod,
  slope_distance = slope_distance,
  intercept_distance = (intercept_distance <- 1.90)
)
str(results$ses_skr)
#> 'data.frame':    2 obs. of  13 variables:
#>  $ slope_ses                  : num  -1.71 -1.7
#>  $ slope_signi                : logi  TRUE TRUE
#>  $ intercept_ses              : num  7.9253 -0.0909
#>  $ intercept_signi            : logi  TRUE FALSE
#>  $ rsquare_ses                : num  -1.21 -1.13
#>  $ rsquare_signi              : logi  FALSE FALSE
#>  $ tad_stab_ses               : num  2.3 -2.13
#>  $ tad_stab_signi             : logi  TRUE TRUE
#>  $ distance_to_family_ses     : num  4.17 -2.18
#>  $ distance_to_family_signi   : logi  TRUE TRUE
#>  $ cv_distance_to_family_ses  : num  -1.05 -1.6
#>  $ cv_distance_to_family_signi: logi  FALSE TRUE
#>  $ Treatment                  : chr  "Mown_NPK" "Mown_Unfertilized"
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 = 1,
  intercept_distance = intercept_distance
)
skr_param_graph
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).
#> Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).

Output PNG, JPEG or SVG graphs

Here is a simple code to generate all graphs based on their name:


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 = "./moments_graph.png",
  do_return = FALSE
)
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 = "./skr_graph.png",
  slope_distance = 1,
  intercept_distance = 1.86,
  do_return = FALSE
)
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 = 1,
  intercept_distance = 1.86,
  save_skr_param_graph = "./skr_param_graph.png",
  do_return = FALSE
)