Public methods
Method new()
Usage
trans_env$new(
  dataset = NULL,
  env_cols = NULL,
  add_data = NULL,
  character2numeric = TRUE,
  complete_na = FALSE
)
Arguments
- dataset
- the object of - microtableClass.
 
env_colsdefault NULL; a vector to select columns in sample_table, when the environmental data is in sample_table. 
Either numeric vector or character vector of colnames.
add_datadefault NULL; data.frame format; provide the environmental data frame individually.
character2numericdefault TRUE; whether transform the characters or factors to numeric attributes.
complete_nadefault FALSE; Whether fill the NA in the environmental data.
Returns
env_data in trans_env object.
Examples
data(dataset)
data(env_data_16S)
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S)
Method cal_rda()
Redundancy analysis (RDA) based on the rda function in vegan package.
Usage
trans_env$cal_rda(
  use_dbrda = TRUE,
  add_matrix = NULL,
  use_measure = NULL,
  feature_sel = FALSE,
  taxa_level = NULL,
  taxa_filter_thres = NULL
)
Arguments
- use_dbrda
- default TRUE; whether use db-RDA, if FALSE, use RDA. 
add_matrixdefault NULL; additional distance matrix provided, if you do not want to use the beta diversity matrix within the dataset.
use_measuredefault NULL; name of beta diversity matrix. If necessary and not provided, use the first beta diversity matrix.
feature_seldefault FALSE; whether perform the feature selection.
taxa_leveldefault NULL; If use RDA, provide the taxonomic rank.
taxa_filter_thresdefault NULL; If want to filter taxa, provide the relative abundance threshold.
Returns
res_rda, res_rda_R2, res_rda_terms and res_rda_axis in object.
Examples
\donttest{
t1$cal_rda(use_dbrda = TRUE, use_measure = "bray")
}
Method cal_rda_envsquare()
Fits each environmental vector onto the RDA ordination to obtain the contribution of each variable.
Usage
trans_env$cal_rda_envsquare(...)
Arguments
- ...
- the parameters passing to vegan::envfit function. 
Returns
res_rda_envsquare in object.
Examples
\donttest{
t1$cal_rda_envsquare()
}
Method trans_rda()
transform RDA result for the following plotting.
Usage
trans_env$trans_rda(
  show_taxa = 10,
  adjust_arrow_length = FALSE,
  min_perc_env = 1,
  max_perc_env = 100,
  min_perc_tax = 1,
  max_perc_tax = 100
)
Arguments
- show_taxa
- default 10; taxa number shown in the plot. 
adjust_arrow_lengthdefault FALSE; whether adjust the arrow length to be clear
min_perc_envdefault 1; minimum scale value for env arrow, relatively.
max_perc_envdefault 100; maximum scale value for env arrow, relatively.
min_perc_taxdefault 1; minimum scale value for tax arrow, relatively.
max_perc_taxdefault 100; maximum scale value for tax arrow, relatively.
Returns
res_rda_trans in object.
Examples
\donttest{
t1$trans_rda(adjust_arrow_length = TRUE, max_perc_env = 10)
}
Method plot_rda()
plot RDA result.
Usage
trans_env$plot_rda(
  plot_color = NULL,
  plot_shape = NULL,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  shape_values = c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14),
  taxa_text_color = "firebrick1",
  taxa_text_type = "italic"
)
Arguments
- plot_color
- default NULL; group used for color. 
plot_shapedefault NULL; group used for shape.
color_valuesdefault RColorBrewer::brewer.pal(8, "Dark2"); color pallete.
shape_valuesdefault see the function; vector used in the shape, see ggplot2 tutorial.
taxa_text_colordefault "firebrick1"; taxa text colors.
taxa_text_typedefault "italic"; taxa text style; better to use "italic" for Genus, use "normal" for others.
Returns
ggplot object.
Examples
\donttest{
t1$plot_rda(plot_color = "Group")
}
Method cal_mantel()
Mantel test between beta diversity matrix and environmental data.
Usage
trans_env$cal_mantel(
  select_env_data = NULL,
  partial_mantel = FALSE,
  add_matrix = NULL,
  use_measure = NULL,
  method = "pearson",
  ...
)
Arguments
- select_env_data
- default NULL; numeric or character vector to select columns in env_data; if not provided, automatically select the columns with numeric attributes. 
partial_manteldefault FALSE; whether use partial mantel test.
add_matrixdefault NULL; additional distance matrix provided, if you donot want to use the beta diversity matrix in the dataset.
use_measuredefault NULL; name of beta diversity matrix. If necessary and not provided, use the first beta diversity matrix.
methoddefault "pearson"; one of "pearson", "spearman" and "kendall"; correlation method.
...paremeters pass to mantel.
Returns
res_mantel in object.
Examples
\donttest{
t1$cal_mantel(use_measure = "bray")
}
Method cal_cor()
Calculating the correlations between taxa abundance and environmental variables.
Indeed, it can also be used for calculating other correlation between any two variables from two tables.
Usage
trans_env$cal_cor(
  use_data = c("Genus", "all", "other")[1],
  select_env_data = NULL,
  cor_method = c("pearson", "spearman", "kendall")[1],
  p_adjust_method = "fdr",
  p_adjust_type = c("Type", "Taxa", "Env")[3],
  add_abund_table = NULL,
  by_group = NULL,
  use_taxa_num = NULL,
  other_taxa = NULL,
  group_use = NULL,
  group_select = NULL,
  taxa_name_full = TRUE
)Arguments
- use_data
- default "Genus"; "Genus", "all" or "other"; "Genus" or other taxonomic name: use genus or other taxonomic abundance table in taxa_abund; 
"all": use all merged taxa abundance table; "other": provide additional taxa name with other_taxa parameter which is necessary. 
select_env_datadefault NULL; numeric or character vector to select columns in env_data; if not provided, automatically select the columns with numeric attributes.
cor_methoddefault "pearson"; "pearson", "spearman" or "kendall"; correlation method.
p_adjust_methoddefault "fdr"; p.adjust method.
p_adjust_typedefault "Env"; "Type", "Taxa" or "Env"; p.adjust type; Env: environmental data; Taxa: taxa data; Type: group used.
add_abund_tabledefault NULL; additional data table to be used. Samples must be rows.
by_groupdefault NULL; one column name or number in sample_table; calculate correlations for different groups separately.
use_taxa_numdefault NULL; integer; a number used to select high abundant taxa; only useful when use_data parameter is a taxonomic level, e.g. "Genus".
other_taxadefault NULL; provide additional taxa, see use_data parameter.
group_usedefault NULL; numeric or character vector to select one column in sample_table for selecting samples; together with group_select.
group_selectdefault NULL; the group name used; will retain samples within the group.
taxa_name_fulldefault TRUE; Whether retain the complete taxonomic name of taxa.
Returns
res_cor in object.
Examples
\donttest{
t2 <- trans_diff$new(dataset = dataset, method = "rf", group = "Group", rf_taxa_level = "Genus")
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S[, 4:11])
t1$cal_cor(use_data = "other", p_adjust_method = "fdr", other_taxa = t2$res_rf$Taxa[1:40])
}
Method plot_cor()
Plot correlation heatmap.
Usage
trans_env$plot_cor(
  color_vector = c("#00008B", "#102D9B", "#215AAC", "#3288BD", "#66C2A5", "#E6F598",
    "#FFFFBF", "#FED690", "#FDAE61", "#F46D43", "#D53E4F"),
  pheatmap = FALSE,
  ylab_type_italic = FALSE,
  keep_full_name = FALSE,
  keep_prefix = TRUE,
  plot_x_size = 9,
  mylabels_x = NULL,
  font_family = NULL,
  ...
)Arguments
- color_vector
- color pallete. 
pheatmapdefault FALSE; whether use heatmap with clustering plot.
ylab_type_italicdefault FALSE; whether use italic type for y lab text.
keep_full_namedefault FALSE; whether use the complete taxonomic name.
keep_prefixdefault TRUE; whether retain the taxonomic prefix.
plot_x_sizedefault 9; x axis text size.
mylabels_xdefault NULL; provide x axis text labels additionally; only available when pheatmap = TRUE.
font_familydefault NULL; font family used in ggplot2; only available when pheatmap = FALSE.
...paremeters pass to ggplot2::geom_tile or pheatmap, depending on the pheatmap = FALSE or TRUE.
Returns
plot.
Examples
\donttest{
t1$plot_cor(pheatmap = FALSE)
}
Method plot_scatterfit()
Scatter plot and add fitted line. The most important thing is to make sure that the input x and y
 have correponding sample orders. If one of x and y is a matrix, the other will be also transformed to matrix with Euclidean distance.
 Then, both of them are transformed to be vectors. If x or y is a vector with a single value, x or y will be
 assigned according to the column selection of the env_data inside.
Usage
trans_env$plot_scatterfit(
  x = NULL,
  y = NULL,
  use_cor = TRUE,
  cor_method = "pearson",
  add_line = TRUE,
  use_se = TRUE,
  text_x_pos = NULL,
  text_y_pos = NULL,
  x_axis_title = "",
  y_axis_title = "",
  pvalue_trim = 4,
  cor_coef_trim = 3,
  lm_fir_trim = 2,
  lm_sec_trim = 2,
  lm_squ_trim = 2,
  ...
)
Arguments
- x
- default NULL; a single numeric or character value or a vector or a distance matrix used for the x axis.
If x is a single value, it will be used to select the column of env_data inside.
If x is a distance matrix, it will be transformed to be a vector. 
ydefault NULL; a single numeric or character value or a vector or a distance matrix used for the y axis.
If y is a single value, it will be used to select the column of env_data inside.
If y is a distance matrix, it will be transformed to be a vector.
use_cordefault TRUE; TRUE for correlation; FALSE for regression.
cor_methoddefault "pearson"; one of "pearson", "kendall" and "spearman".
add_linedefault TRUE; whether add the fitted line in the plot.
use_sedefault TRUE; Whether show the confidence interval for the fitting.
text_x_posdefault NULL; the central x axis position of the fitting text.
text_y_posdefault NULL; the central y axis position of the fitting text.
x_axis_titledefault ""; the title of x axis.
y_axis_titledefault ""; the title of y axis.
pvalue_trimdefault 4; trim the decimal places of p value.
cor_coef_trimdefault 3; trim the decimal places of correlation coefficient.
lm_fir_trimdefault 2; trim the decimal places of regression first coefficient.
lm_sec_trimdefault 2; trim the decimal places of regression second coefficient.
lm_squ_trimdefault 2; trim the decimal places of regression R square.
...the parameters passing to ggplot2::geom_point function.
Returns
plot.
Examples
\donttest{
t1$plot_scatterfit(x = 1, y = 2, alpha = .5)
}
Method print()
Print the trans_env object.
Usage
trans_env$print()
Method clone()
The objects of this class are cloneable with this method.
Usage
trans_env$clone(deep = FALSE)
Arguments
- deep
- Whether to make a deep clone.