makebargraphrawggplot2: ggplot2-based cummulative stacked bargraphs for plotting...

Description Usage Arguments Value Examples

View source: R/makebargraphrawggplot2.R

Description

This function uses a taxonomy file (i.e. an RDP naive bayesian fixed-rank asignment detail) and a shared file to create 100 Only the top-n OTUs (in relative abundance) among all samples are displayed. All other OTUs are summed into a part of the graph designated as "other". The resulting object contains information about the composition of "other".

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
makebargraphrawggplot2(
  tax,
  shared,
  topn = 8,
  taxlevel = c("Regnum", "Phylum", "Classis", "Ordo", "Familia", "Genus", "Species"),
  shared.abs = T,
  tax.prob = F,
  tresh = 85,
  samples,
  viridfill = FALSE,
  plot = TRUE,
  ...
)

Arguments

tax

is a taxonomy file, raw.

shared

is a shared (OTU-by-sample) file, filtered per sample group.

topn

is the top number of taxa selected to display (maximum 11, default 8)

taxlevel

is either one of "Regnum", "Phylum", "Classis", "Ordo", "Familia", "Genus"

shared.abs

is a logical showing wether the shared file already consists out of direct Illumina counts, or is really the raw csv from Ramiro (default TRUE)

tax.prob

shows whether the taxonomy file contains probabilites (default FALSE)

tresh

is a threshold for the probability taxonomy duplicate matching (to be implemented, default 85)

samples

is an optional string for the title of the generated bargraph (e.g. "MOB","OLAND","Fecal samples", defualt empty)

viridfill

whether or not a discrete viridis fill pallette should be used (defaults to FALSE)

plot

states wether or not to print the plot within the function (default TRUE)

...

optional arguments passed on to ggplot call

Value

a list of 3 objects: ggplotdf (the underlying data for the ggplot), othertax (an abundance-sorted dataframe of the OTUs summarized in "other"), ggplotobj (the generated ggplot2 object)

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
## Short example
# make sure library(CMETNGS) is loaded
shareddataset <- system.file("extdata","large_shared_file.shared",
                              package = "CMETNGS",mustWork = TRUE)
taxonomydataset <- system.file("extdata","large_OTU_basedtax.taxonomy",
                              package = "CMETNGS",mustWork = TRUE)

shared <- data.table::fread(input = shareddataset,
header = TRUE)
taxonomy <- data.table::fread(input = taxonomydataset)
shared <- as.data.frame(shared)
desgroups <- shared$Group
shared.x <- shared[,4:ncol(shared)]
rownames(shared.x) <- desgroups
shared.t <- as.data.frame(t(shared.x)) # transpose: OTUs in rows, samples in columns
shared.t.ns <- shared.t[which(rowSums(shared.t)!=1),] # remove absolute singletons
sharedns <- data.frame(label=rep(0.03,ncol(shared.t.ns)),
                      Group=colnames(shared.t.ns),
                      numOtus=nrow(shared.t.ns),t(shared.t.ns))
taxonomy.spl <- CMETNGS::preformattax(taxonomy)
taxonomy.np <- taxonomy.spl %>% dplyr::select(-dplyr::contains("Prob"))
taxonomy.np.ns <- taxonomy.np[which(rownames(taxonomy.np) %in%
rownames(shared.t.ns)),]
barplot.genus <- makebargraphrawggplot2(tax=taxonomy.np.ns,shared=shared.t.ns,
topn=8,taxlevel="Genus",shared.abs=TRUE,
tax.prob=FALSE,samples="testsample",
plot=TRUE)

CMET-UGent/CMETNGS documentation built on Dec. 12, 2020, 8:22 a.m.