trans_diff: Create trans_diff object for the differential analysis on the...

Description Methods Examples

Description

This class is a wrapper for a series of differential abundance test and indicator analysis methods, including non-parametric test, LEfSe based on the Segata et al. (2011) <doi:10.1186/gb-2011-12-6-r60>, random forest, metastat based on White et al. (2009) <doi:10.1371/journal.pcbi.1000352> and the method in R package metagenomeSeq Paulson et al. (2013) <doi:10.1038/nmeth.2658>.

Methods

Public methods


Method new()

Usage
trans_diff$new(
  dataset = NULL,
  method = c("lefse", "rf", "metastat", "mseq")[1],
  group = NULL,
  lefse_subgroup = NULL,
  alpha = 0.05,
  lefse_min_subsam = 10,
  lefse_norm = 1e+06,
  nresam = 0.6667,
  boots = 30,
  rf_taxa_level = "all",
  rf_ntree = 1000,
  metastat_taxa_level = "Genus",
  group_choose_paired = NULL,
  mseq_adjustMethod = "fdr",
  mseq_count = 1
)
Arguments
dataset

the object of microtable Class.

method

default "lefse"; "lefse", "rf", "metastat" or "mseq". "lefse": Segata et al. (2011) <doi:10.1186/gb-2011-12-6-r60>; "rf" represents random forest; metastat: White et al. (2009) <doi:10.1371/journal.pcbi.1000352>; "mseq" represents the method in metagenomeSeq package.

group

default NULL; sample group used for main comparision.

lefse_subgroup

default NULL; sample sub group used for sub-comparision in lefse; Segata et al. (2011) <doi:10.1186/gb-2011-12-6-r60>.

alpha

default .05; significance threshold.

lefse_min_subsam

default 10; sample numbers required in the subgroup test.

lefse_norm

default 1000000; scale value in lefse.

nresam

default .6667; sample number ratio used in each bootstrap or LEfSe or random forest.

boots

default 30; bootstrap test number for lefse or rf.

rf_taxa_level

default "all"; use all taxonomic rank data, if want to test a specific rank, provide taxonomic rank name, such as "Genus".

rf_ntree

default 1000; see ntree in randomForest function of randomForest package.

metastat_taxa_level

default "Genus"; taxonomic rank level used in metastat test; White et al. (2009) <doi:10.1371/journal.pcbi.1000352>.

group_choose_paired

default NULL; a vector used for selecting the required groups for paired testing, only used for metastat or mseq.

mseq_adjustMethod

default "fdr"; Method to adjust p-values by. Default is "fdr". Options include "holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none".

mseq_count

default 1; Filter features to have at least 'counts' counts.; see the count parameter in MRcoefs function of metagenomeSeq package.

Returns

res_rf, res_lefse, res_abund, res_metastat, or res_mseq in trans_diff object, depending on the method.

Examples
\donttest{
data(dataset)
t1 <- trans_diff$new(dataset = dataset, method = "lefse", group = "Group")
}

Method plot_diff_abund()

Plotting the abundance of differential taxa.

Usage
trans_diff$plot_diff_abund(
  method = NULL,
  only_abund_plot = TRUE,
  use_number = 1:10,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  plot1_bar_color = "grey50",
  plot2_sig_color = "red",
  plot2_sig_size = 1.2,
  axis_text_y = 10,
  simplify_names = TRUE,
  keep_prefix = TRUE,
  group_order = NULL,
  plot2_barwidth = 0.9,
  add_significance = TRUE,
  use_se = TRUE
)
Arguments
method

default NULL; "rf" or "lefse"; automatically check the method in the result.

only_abund_plot

default TRUE; if true, return only abundance plot; if false, return both indicator plot and abundance plot

use_number

default 1:10; vector, the taxa numbers used in the plot, 1:n.

color_values

colors for presentation.

plot1_bar_color

default "grey30"; the color for the plot 1.

plot2_sig_color

default "red"; the color for the significance in plot 2.

plot2_sig_size

default 1.5; the size for the significance in plot 2.

axis_text_y

default 12; the size for the y axis text.

simplify_names

default TRUE; whether use the simplified taxonomic name.

keep_prefix

default TRUE; whether retain the taxonomic prefix.

group_order

default NULL; a vector to order the legend in plot.

plot2_barwidth

default .9; the bar width in plot 2.

add_significance

default TRUE; whether add the significance asterisk; only available when only_abund_plot FALSE.

use_se

default TRUE; whether use SE in plot 2, if FALSE, use SD.

Returns

ggplot.

Examples
\donttest{
t1$plot_diff_abund(use_number = 1:10)
}

Method plot_lefse_bar()

Bar plot for LDA score.

Usage
trans_diff$plot_lefse_bar(
  use_number = 1:10,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  LDA_score = NULL,
  simplify_names = TRUE,
  keep_prefix = TRUE,
  group_order = NULL,
  axis_text_y = 12,
  plot_vertical = TRUE,
  ...
)
Arguments
use_number

default 1:10; vector, the taxa numbers used in the plot, 1:n.

color_values

colors for presentation.

LDA_score

default NULL; numeric value as the threshold, such as 2, limited with use_number.

simplify_names

default TRUE; whether use the simplified taxonomic name.

keep_prefix

default TRUE; whether retain the taxonomic prefix.

group_order

default NULL; a vector to order the legend in plot.

axis_text_y

default 12; the size for the y axis text.

plot_vertical

default TRUE; whether use vertical bar plot or horizontal.

...

parameters pass to geom_bar

Returns

ggplot.

Examples
\donttest{
t1$plot_lefse_bar(LDA_score = 4)
}

Method plot_lefse_cladogram()

Plot the cladogram for LEfSe result similar with the python version. Codes are modified from microbiomeMarker

Usage
trans_diff$plot_lefse_cladogram(
  color = RColorBrewer::brewer.pal(8, "Dark2"),
  use_taxa_num = 200,
  filter_taxa = NULL,
  use_feature_num = NULL,
  group_order = NULL,
  clade_label_level = 4,
  select_show_labels = NULL,
  only_select_show = FALSE,
  sep = "|",
  branch_size = 0.2,
  alpha = 0.2,
  clade_label_size = 0.7,
  node_size_scale = 1,
  node_size_offset = 1,
  annotation_shape = 22,
  annotation_shape_size = 5
)
Arguments
color

default RColorBrewer::brewer.pal(8, "Dark2"); color used in the plot.

use_taxa_num

default 200; integer; The taxa number used in the background tree plot; select the taxa according to the mean abundance

filter_taxa

default NULL; The mean relative abundance used to filter the taxa with low abundance

use_feature_num

default NULL; integer; The feature number used in the plot; select the features according to the LDA score

group_order

default NULL; a vector to order the legend in plot.

clade_label_level

default 4; the taxonomic level for marking the label with letters, root is the largest

select_show_labels

default NULL; character vector; The features to show in the plot with full label names, not the letters

only_select_show

default FALSE; whether only use the the select features in the parameter select_show_labels

sep

default "|"; the seperate character in the taxonomic information

branch_size

default 0.2; numberic, size of branch

alpha

default 0.2; shading of the color

clade_label_size

default 0.7; size for the clade label

node_size_scale

default 1; scale for the node size

node_size_offset

default 1; offset for the node size

annotation_shape

default 22; shape used in the annotation legend

annotation_shape_size

default 5; size used in the annotation legend

Returns

ggplot.

Examples
\donttest{
t1$plot_lefse_cladogram(use_taxa_num = 100, use_feature_num = 30, select_show_labels = NULL)
}

Method plot_metastat()

Bar plot for metastat.

Usage
trans_diff$plot_metastat(
  use_number = 1:10,
  color_values = RColorBrewer::brewer.pal(8, "Dark2"),
  qvalue = 0.05,
  choose_group = 1
)
Arguments
use_number

default 1:10; vector, the taxa numbers used in the plot, 1:n.

color_values

colors for presentation.

qvalue

default .05; numeric value as the threshold of q value.

choose_group

default 1; which column in res_metastat_group_matrix will be used.

Returns

ggplot.

Examples
\donttest{
t1 <- trans_diff$new(dataset = dataset, method = "metastat", group = "Group")
t1$plot_metastat(use_number = 1:10, qvalue = 0.05, choose_group = 1)
}

Method print()

Print the trans_diff object.

Usage
trans_diff$print()

Method clone()

The objects of this class are cloneable with this method.

Usage
trans_diff$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
## ------------------------------------------------
## Method `trans_diff$new`
## ------------------------------------------------


data(dataset)
t1 <- trans_diff$new(dataset = dataset, method = "lefse", group = "Group")


## ------------------------------------------------
## Method `trans_diff$plot_diff_abund`
## ------------------------------------------------


t1$plot_diff_abund(use_number = 1:10)


## ------------------------------------------------
## Method `trans_diff$plot_lefse_bar`
## ------------------------------------------------


t1$plot_lefse_bar(LDA_score = 4)


## ------------------------------------------------
## Method `trans_diff$plot_lefse_cladogram`
## ------------------------------------------------


t1$plot_lefse_cladogram(use_taxa_num = 100, use_feature_num = 30, select_show_labels = NULL)


## ------------------------------------------------
## Method `trans_diff$plot_metastat`
## ------------------------------------------------


t1 <- trans_diff$new(dataset = dataset, method = "metastat", group = "Group")
t1$plot_metastat(use_number = 1:10, qvalue = 0.05, choose_group = 1)

microeco documentation built on May 30, 2021, 5:06 p.m.