Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trans_env

Create trans_env object for the analysis of the effects of environmental factors on communities.


Description

This class is a wrapper for a series of operations associated with environmental measurements, including redundancy analysis, mantel test, correlation analysis and linear fitting based on An et al. (2019) <doi:10.1016/j.geoderma.2018.09.035>.

Methods

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 microtable Class.

env_cols

default NULL; either numeric vector or character vector to select columns in sample_table of your microtable object. This parameter should be used in the case that all the required environmental data is in sample_table of your microtable object. Otherwise, please use add_data parameter.

add_data

default NULL; data.frame format; provide the environmental data in the format data.frame; rownames should be sample names. This parameter should be used when the sample_table in your microtable object has no environmental data. Under this circumstance, the env_cols parameter can not be used because no data can be selected.

character2numeric

default TRUE; whether transform the characters or factors to numeric attributes.

complete_na

default FALSE; Whether fill the NA (missing value) in the environmental data; If TRUE, the function can run the interpolation with the mice package; to use this parameter, please first install mice package.

Returns

data_env in trans_env object.

Examples
data(dataset)
data(env_data_16S)
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S[, 4:11])

Method cal_diff()

Test the difference of environmental variable across groups.

Usage
trans_env$cal_diff(
  group = NULL,
  method = c("KW", "KW_dunn", "wilcox", "t.test", "anova")[1],
  measure = NULL,
  p_adjust_method = "fdr",
  anova_set = NULL,
  ...
)
Arguments
group

default NULL; a colname of sample_table used to compare values across groups.

method

default "KW"; see the following available options:

'KW'

KW: Kruskal-Wallis Rank Sum Test for all groups (>= 2)

'KW_dunn'

Dunn's Kruskal-Wallis Multiple Comparisons, see dunnTest function in FSA package

'wilcox'

Wilcoxon Rank Sum and Signed Rank Tests for all paired groups

't.test'

Student's t-Test for all paired groups

'anova'

Duncan's multiple range test for anova

measure

default NULL; a vector; if null, all variables will be calculated.

p_adjust_method

default "fdr"; p.adjust method; see method parameter of p.adjust function for available options.

anova_set

default NULL; specified group set for anova, such as 'block + N*P*K', see aov.

...

parameters passed to kruskal.test or wilcox.test function (method = "KW") or dunnTest function of FSA package (method = "KW_dunn") or agricolae::duncan.test (method = "anova").

Returns

res_diff in object. A data.frame generally. A list for anova when anova_set is assigned. In the data frame, 'Group' column means that the group has the maximum median or mean value across the test groups; For non-parametric methods, maximum median value; For t.test, maximum mean value.

Examples
\donttest{
t1$cal_diff(group = "Group", method = "KW")
t1$cal_diff(group = "Group", method = "KW_dunn")
t1$cal_diff(group = "Group", method = "anova")
}

Method cal_autocor()

Calculate the autocorrelations among environmental variables and plot the result.

Usage
trans_env$cal_autocor(
  group = NULL,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  alpha = 0.8,
  ...
)
Arguments
group

default NULL; a colname of sample_table; used to perform calculations for different groups.

color_values

default RColorBrewer::brewer.pal(8, "Dark2"); colors palette.

alpha

default 0.8; the alpha value to add transparency in colors; useful when group is not NULL.

...

default parameters passed to GGally::ggpairs.

Returns

ggmatrix.

Examples
\donttest{
t1$cal_autocor(method = "GGally")
}

Method cal_ordination()

Redundancy analysis (RDA) and Correspondence Analysis (CCA) based on the vegan package.

Usage
trans_env$cal_ordination(
  method = c("RDA", "dbRDA", "CCA")[1],
  feature_sel = FALSE,
  taxa_level = NULL,
  taxa_filter_thres = NULL,
  use_measure = NULL,
  add_matrix = NULL,
  ...
)
Arguments
method

default c("RDA", "dbRDA", "CCA")[1]; the ordination method.

feature_sel

default FALSE; whether perform the feature selection based on forward selection method.

taxa_level

default NULL; If use RDA or CCA, provide the taxonomic rank, such as "Phylum" or "Genus"; If use otu_table; please input "OTU".

taxa_filter_thres

default NULL; If want to filter taxa, provide the relative abundance threshold.

use_measure

default NULL; a name of beta diversity matrix; only useful when parameter method = "dbRDA"; If not provided, use the first beta diversity matrix automatically.

add_matrix

default NULL; additional distance matrix provided, when the user does not want to use the beta diversity matrix within the dataset; only available when method = "dbRDA".

...

paremeters pass to dbrda or rda or cca function according to the input of method.

Returns

res_ordination, res_ordination_R2, res_ordination_terms and res_ordination_axis in object.

Examples
\donttest{
t1$cal_ordination(method = "dbRDA", use_measure = "bray")
t1$cal_ordination(method = "RDA", taxa_level = "Genus")
t1$cal_ordination(method = "CCA", taxa_level = "Genus")
}

Method cal_ordination_envsquare()

Fits each environmental vector onto the ordination to obtain the contribution of each variable.

Usage
trans_env$cal_ordination_envsquare(...)
Arguments
...

the parameters passing to vegan::envfit function.

Returns

res_ordination_envsquare in object.

Examples
\donttest{
t1$cal_ordination_envsquare()
}

Method trans_ordination()

transform ordination result for the following plotting.

Usage
trans_env$trans_ordination(
  show_taxa = 10,
  adjust_arrow_length = FALSE,
  min_perc_env = 0.1,
  max_perc_env = 0.8,
  min_perc_tax = 0.1,
  max_perc_tax = 0.8
)
Arguments
show_taxa

default 10; taxa number shown in the plot.

adjust_arrow_length

default FALSE; whether adjust the arrow length to be clearer.

min_perc_env

default 0.1; used for scaling up the minimum of env arrow; multiply by the maximum distance between samples and origin.

max_perc_env

default 0.8; used for scaling up the maximum of env arrow; multiply by the maximum distance between samples and origin.

min_perc_tax

default 0.1; used for scaling up the minimum of tax arrow; multiply by the maximum distance between samples and origin.

max_perc_tax

default 0.8; used for scaling up the maximum of tax arrow; multiply by the maximum distance between samples and origin.

Returns

res_ordination_trans in object.

Examples
\donttest{
t1$trans_ordination(adjust_arrow_length = TRUE, min_perc_env = 0.1, max_perc_env = 1)
}

Method plot_ordination()

plot ordination result.

Usage
trans_env$plot_ordination(
  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),
  env_text_color = "black",
  env_arrow_color = "grey30",
  taxa_text_color = "firebrick1",
  taxa_arrow_color = "firebrick1",
  env_text_size = 3.7,
  taxa_text_size = 3,
  taxa_text_italic = TRUE,
  plot_type = "point",
  point_size = 3,
  point_alpha = 0.8,
  centroid_segment_alpha = 0.6,
  centroid_segment_size = 1,
  centroid_segment_linetype = 3,
  ellipse_chull_fill = TRUE,
  ellipse_chull_alpha = 0.1,
  ellipse_level = 0.9,
  ellipse_type = "t",
  add_sample_label = NULL,
  env_nudge_x = NULL,
  env_nudge_y = NULL,
  taxa_nudge_x = NULL,
  taxa_nudge_y = NULL,
  ...
)
Arguments
plot_color

default NULL; a colname of sample_table to assign colors to different groups in plot.

plot_shape

default NULL; a colname of sample_table to assign shapes to different groups in plot.

color_values

default RColorBrewer::brewer.pal(8, "Dark2"); color pallete for different groups.

shape_values

default c(16, 17, 7, 8, 15, 18, 11, 10, 12, 13, 9, 3, 4, 0, 1, 2, 14); a vector for point shape types of groups, see ggplot2 tutorial.

env_text_color

default "black"; environmental variable text color.

env_arrow_color

default "grey30"; environmental variable arrow color.

taxa_text_color

default "firebrick1"; taxa text color.

taxa_arrow_color

default "firebrick1"; taxa arrow color.

env_text_size

default 3.7; environmental variable text size.

taxa_text_size

default 3; taxa text size.

taxa_text_italic

default TRUE; "italic"; whether use "italic" style for the taxa text in the plot.

plot_type

default "point"; one or more elements of "point", "ellipse", "chull" and "centroid".

'point'

add point

'ellipse'

add confidence ellipse for points of each group

'chull'

add convex hull for points of each group

'centroid'

add centroid line of each group

point_size

default 3; point size in plot when "point" is in plot_type.

point_alpha

default .8; point transparency in plot when "point" is in plot_type.

centroid_segment_alpha

default 0.6; segment transparency in plot when "centroid" is in plot_type.

centroid_segment_size

default 1; segment size in plot when "centroid" is in plot_type.

centroid_segment_linetype

default 3; an integer; the line type related with centroid in plot when "centroid" is in plot_type.

ellipse_chull_fill

default TRUE; whether fill colors to the area of ellipse or chull.

ellipse_chull_alpha

default 0.1; color transparency in the ellipse or convex hull depending on whether "ellipse" or "centroid" is in plot_type.

ellipse_level

default .9; confidence level of ellipse when "ellipse" is in plot_type.

ellipse_type

default "t"; ellipse type when "ellipse" is in plot_type; see type in stat_ellipse.

add_sample_label

default NULL; the column name in sample table, if provided, show the point name in plot.

env_nudge_x

default NULL; numeric vector to adjust the env text x axis position; passed to nudge_x parameter of geom_text_repel function of ggrepel package; default NULL represents automatic adjustment; the length must be same with the row number of object$res_ordination_trans$df_arrows. For example, if there are 5 env variables, env_nudge_x should be something like c(0.1, 0, -0.2, 0, 0). Note that this parameter and env_nudge_y is generally used when the automatic text adjustment is not very well.

env_nudge_y

default NULL; numeric vector to adjust the env text y axis position; passed to nudge_y parameter of ggrepel::geom_text_repel function; default NULL represents automatic adjustment; the length must be same with the row number of object$res_ordination_trans$df_arrows. For example, if there are 5 env variables, env_nudge_y should be something like c(0.1, 0, -0.2, 0, 0).

taxa_nudge_x

default NULL; numeric vector to adjust the taxa text x axis position; passed to nudge_x parameter of ggrepel::geom_text_repel function; default NULL represents automatic adjustment; the length must be same with the row number of object$res_ordination_trans$df_arrows_spe. For example, if 3 taxa are shown, taxa_nudge_x should be something like c(0.3, -0.2, 0).

taxa_nudge_y

default NULL; numeric vector to adjust the taxa text y axis position; passed to nudge_y parameter of ggrepel::geom_text_repel function; default NULL represents automatic adjustment; the length must be same with the row number of object$res_ordination_trans$df_arrows_spe. For example, if 3 taxa are shown, taxa_nudge_y should be something like c(-0.2, 0, 0.4).

...

paremeters pass to geom_point for controlling sample points.

Returns

ggplot object.

Examples
\donttest{
t1$cal_ordination(method = "RDA")
t1$trans_ordination(adjust_arrow_length = TRUE, max_perc_env = 1.5)
t1$plot_ordination(plot_color = "Group")
t1$plot_ordination(plot_color = "Group", plot_shape = "Group", plot_type = c("point", "ellipse"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "chull"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "centroid"), 
	  centroid_segment_linetype = 1)
t1$plot_ordination(plot_color = "Group", env_nudge_x = c(0.4, 0, 0, 0, 0, -0.2, 0, 0), 
	  env_nudge_y = c(0.6, 0, 0.2, 0.5, 0, 0.1, 0, 0.2))
}

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",
  p_adjust_method = "fdr",
  ...
)
Arguments
select_env_data

default NULL; numeric or character vector to select columns in data_env; if not provided, automatically select the columns with numeric attributes.

partial_mantel

default FALSE; whether use partial mantel test; If TRUE, use other measurements as the zdis.

add_matrix

default NULL; additional distance matrix provided, if you donot want to use the beta diversity matrix in the dataset.

use_measure

default NULL; name of beta diversity matrix. If necessary and not provided, use the first beta diversity matrix.

method

default "pearson"; one of "pearson", "spearman" and "kendall"; correlation method; see method parameter in mantel function of vegan package.

p_adjust_method

default "fdr"; p.adjust method; see method parameter of p.adjust function for available options.

...

paremeters pass to mantel of vegan package.

Returns

res_mantel in object.

Examples
\donttest{
t1$cal_mantel(use_measure = "bray")
t1$cal_mantel(partial_mantel = TRUE, use_measure = "bray")
}

Method cal_cor()

Calculating the correlations between taxa abundance and environmental variables. Actually, 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_data

default NULL; numeric or character vector to select columns in data_env; if not provided, automatically select the columns with numeric attributes.

cor_method

default "pearson"; "pearson", "spearman" or "kendall"; correlation method.

p_adjust_method

default "fdr"; p.adjust method; see method parameter of p.adjust function for available options.

p_adjust_type

default "Env"; "Type", "Taxa" or "Env"; p.adjust type; Env: environmental data; Taxa: taxa data; Type: group used.

add_abund_table

default NULL; additional data table to be used. Samples must be rows.

by_group

default NULL; one column name or number in sample_table; calculate correlations for different groups separately.

use_taxa_num

default NULL; integer; a number used to select high abundant taxa; only useful when use_data parameter is a taxonomic level, e.g., "Genus".

other_taxa

default NULL; character vector containing a series of taxa names; used when use_data = "other"; the provided names should be standard full names used to select taxa from all the tables in taxa_abund list of the microtable object; please see the example.

group_use

default NULL; numeric or character vector to select one column in sample_table for selecting samples; together with group_select.

group_select

default NULL; the group name used; remain samples within the group.

taxa_name_full

default TRUE; Whether use 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_diff$Taxa[1:40])
}

Method plot_cor()

Plot correlation heatmap.

Usage
trans_env$plot_cor(
  color_vector = c("#053061", "white", "#A50026"),
  color_palette = NULL,
  pheatmap = FALSE,
  filter_feature = NULL,
  ylab_type_italic = FALSE,
  keep_full_name = FALSE,
  keep_prefix = TRUE,
  text_y_order = NULL,
  text_x_order = NULL,
  font_family = NULL,
  cluster_ggplot = "none",
  cluster_height_rows = 0.2,
  cluster_height_cols = 0.2,
  text_y_position = "right",
  mylabels_x = NULL,
  ...
)
Arguments
color_vector

default c("#053061", "white", "#A50026"); colors with only three values representing low, middle and high value.

color_palette

default NULL; a customized palette with more color values; if provided, use it instead of color_vector.

pheatmap

default FALSE; whether use pheatmap package to plot the heatmap.

filter_feature

default NULL; character vector; used to filter features that only have significance labels in the filter_feature vector. For example, filter_feature = "" can be used to filter features that only have "", no any "*".

ylab_type_italic

default FALSE; whether use italic type for y lab text.

keep_full_name

default FALSE; whether use the complete taxonomic name.

keep_prefix

default TRUE; whether retain the taxonomic prefix.

text_y_order

default NULL; character vector; provide customized text order for y axis; shown in the plot from the top down.

text_x_order

default NULL; character vector; provide customized text order for x axis.

font_family

default NULL; font family used in ggplot2; only available when pheatmap = FALSE.

cluster_ggplot

default "none"; add clustering dendrogram for ggplot2 based heatmap; available options: "none", "row", "col" or "both". "none": no any clustering used; "row": add clustering for rows; "col": add clustering for columns; "both": add clustering for both rows and columns. Only available when pheatmap = FALSE.

cluster_height_rows

default 0.2, the dendrogram plot height for rows; available when cluster_ggplot != "none".

cluster_height_cols

default 0.2, the dendrogram plot height for columns; available cluster_ggplot != "none".

text_y_position

default "right"; "left" or "right"; the y axis text position; ggplot2 based heatmap.

mylabels_x

default NULL; provide x axis text labels additionally; only available when pheatmap = TRUE.

...

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 data_env inside.

Usage
trans_env$plot_scatterfit(
  x = NULL,
  y = NULL,
  group = NULL,
  group_order = NULL,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  shape_values = NULL,
  type = c("cor", "lm")[1],
  cor_method = "pearson",
  label_sep = ";",
  label.x.npc = "left",
  label.y.npc = "top",
  label.x = NULL,
  label.y = NULL,
  x_axis_title = "",
  y_axis_title = "",
  point_size = 5,
  point_alpha = 0.6,
  line_size = 0.8,
  line_alpha = 1,
  line_color = "black",
  line_se = TRUE,
  line_se_color = "grey70",
  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 data_env inside. If x is a distance matrix, it will be transformed to be a vector.

y

default 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 data_env inside. If y is a distance matrix, it will be transformed to be a vector.

group

default NULL; a character vector; if length is 1, must be a colname of dataset$sample_table; Otherwise, group should be a vector with same length of x/y (for vector) or ncol of x/y (for matrix).

group_order

default NULL; a vector to order groups, i.e. reorder the legend and colors in plot when group is not NULL; If group_order is NULL and group is provided, the function can first check whether the group column of dataset$sample_table is factor. If provided, overlook the levels in the group of dataset$sample_table.

color_values

default RColorBrewer::brewer.pal(8, "Dark2"); color pallete for different groups.

shape_values

default NULL; a numeric vector for point shape types of groups when group is not NULL, see ggplot2 tutorial.

type

default c("cor", "lm")[1]; "cor": correlation; "lm" for regression.

cor_method

default "pearson"; one of "pearson", "kendall" and "spearman"; correlation method.

label_sep

default ";"; the separator string between different label parts.

label.x.npc

default "left"; can be numeric or character vector of the same length as the number of groups and/or panels. If too short they will be recycled.

numeric

value should be between 0 and 1. Coordinates to be used for positioning the label, expressed in "normalized parent coordinates"

character

allowed values include: i) one of c('right', 'left', 'center', 'centre', 'middle') for x-axis; ii) and one of c( 'bottom', 'top', 'center', 'centre', 'middle') for y-axis.

label.y.npc

default "top"; same usage with label.x.npc; see also label.y.npc parameter of stat_cor of ggpubr package.

label.x

default NULL; x axis absolute position for adding the statictic label.

label.y

default NULL; x axis absolute position for adding the statictic label.

x_axis_title

default ""; the title of x axis.

y_axis_title

default ""; the title of y axis.

point_size

default 5; point size value.

point_alpha

default 0.6; alpha value for the point color transparency.

line_size

default 0.8; line size value.

line_alpha

default 1; alpha value for the line color transparency.

line_color

default "black"; fitted line color only useful when group = NULL.

line_se

default TRUE; Whether show the confidence interval for the fitting.

line_se_color

default "grey70"; the color to fill the confidence interval when line_se = TRUE.

pvalue_trim

default 4; trim the decimal places of p value.

cor_coef_trim

default 3; trim the decimal places of correlation coefficient.

lm_fir_trim

default 2; trim the decimal places of regression first coefficient.

lm_sec_trim

default 2; trim the decimal places of regression second coefficient.

lm_squ_trim

default 2; trim the decimal places of regression R square.

...

other arguments to pass to geom_text or geom_label.

Returns

plot.

Examples
\donttest{
t1$plot_scatterfit(x = 1, y = 2, type = "cor")
t1$plot_scatterfit(x = 1, y = 2, type = "lm", point_alpha = .3)
t1$plot_scatterfit(x = "pH", y = "TOC", type = "lm", group = "Group", line_se = FALSE)
t1$plot_scatterfit(x = 
	 dataset$beta_diversity$bray[rownames(t1$data_env), rownames(t1$data_env)], y = "pH")
}

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.

Examples

## ------------------------------------------------
## Method `trans_env$new`
## ------------------------------------------------

data(dataset)
data(env_data_16S)
t1 <- trans_env$new(dataset = dataset, add_data = env_data_16S[, 4:11])

## ------------------------------------------------
## Method `trans_env$cal_diff`
## ------------------------------------------------


t1$cal_diff(group = "Group", method = "KW")
t1$cal_diff(group = "Group", method = "KW_dunn")
t1$cal_diff(group = "Group", method = "anova")


## ------------------------------------------------
## Method `trans_env$cal_autocor`
## ------------------------------------------------


t1$cal_autocor(method = "GGally")


## ------------------------------------------------
## Method `trans_env$cal_ordination`
## ------------------------------------------------


t1$cal_ordination(method = "dbRDA", use_measure = "bray")
t1$cal_ordination(method = "RDA", taxa_level = "Genus")
t1$cal_ordination(method = "CCA", taxa_level = "Genus")


## ------------------------------------------------
## Method `trans_env$cal_ordination_envsquare`
## ------------------------------------------------


t1$cal_ordination_envsquare()


## ------------------------------------------------
## Method `trans_env$trans_ordination`
## ------------------------------------------------


t1$trans_ordination(adjust_arrow_length = TRUE, min_perc_env = 0.1, max_perc_env = 1)


## ------------------------------------------------
## Method `trans_env$plot_ordination`
## ------------------------------------------------


t1$cal_ordination(method = "RDA")
t1$trans_ordination(adjust_arrow_length = TRUE, max_perc_env = 1.5)
t1$plot_ordination(plot_color = "Group")
t1$plot_ordination(plot_color = "Group", plot_shape = "Group", plot_type = c("point", "ellipse"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "chull"))
t1$plot_ordination(plot_color = "Group", plot_type = c("point", "centroid"), 
	  centroid_segment_linetype = 1)
t1$plot_ordination(plot_color = "Group", env_nudge_x = c(0.4, 0, 0, 0, 0, -0.2, 0, 0), 
	  env_nudge_y = c(0.6, 0, 0.2, 0.5, 0, 0.1, 0, 0.2))


## ------------------------------------------------
## Method `trans_env$cal_mantel`
## ------------------------------------------------


t1$cal_mantel(use_measure = "bray")
t1$cal_mantel(partial_mantel = TRUE, use_measure = "bray")


## ------------------------------------------------
## Method `trans_env$cal_cor`
## ------------------------------------------------


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_diff$Taxa[1:40])


## ------------------------------------------------
## Method `trans_env$plot_cor`
## ------------------------------------------------


t1$plot_cor(pheatmap = FALSE)


## ------------------------------------------------
## Method `trans_env$plot_scatterfit`
## ------------------------------------------------


t1$plot_scatterfit(x = 1, y = 2, type = "cor")
t1$plot_scatterfit(x = 1, y = 2, type = "lm", point_alpha = .3)
t1$plot_scatterfit(x = "pH", y = "TOC", type = "lm", group = "Group", line_se = FALSE)
t1$plot_scatterfit(x = 
	 dataset$beta_diversity$bray[rownames(t1$data_env), rownames(t1$data_env)], y = "pH")

microeco

Microbial Community Ecology Data Analysis

v0.10.0
GPL-3
Authors
Chi Liu [aut, cre], Felipe R. P. Mansoldo [ctb], Umer Zeeshan Ijaz [ctb], Chenhao Li [ctb], Yang Cao [ctb], Minjie Yao [ctb], Xiangzhen Li [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.