Plotting glycans with glycanr package

First we need to load the package.

# load glycanr package
library(glycanr)

Lets create a data.frame to simulate our glycan data.

set.seed(123)
n <- 200
X <- data.frame(ID=1:n, GP1=runif(n), GP2=rexp(n, 0.3),
                GP3=rgamma(n, 2), cc=factor(sample(1:2, n, replace=TRUE)))

Now we have data.frame X where GP represents glycans, ID represents e.g. sample IDs and cc represents Case/Control status.

head(X)

This data can now be plotted with glyco.plot function.

Basic usage is given as follows.

glyco.plot(X)

It plots boxplots for every column whose name starts with 'GP'. To change boxplots with violin plots (represents the density of a data) option violin should be used.

glyco.plot(X, violin=TRUE)

To separate boxplots (or violin plots) into different layers option collapse should be used.

glyco.plot(X, collapse=FALSE)

To plot log transformed data option log.transform should be used

glyco.plot(X, collapse=FALSE, log.transform=TRUE)

Grouping

If you want to see the difference between groups with boxplots (or violin plots) option group should be used. It takes a character string representing the name of the column on grouping should be done.

Grouping by cc variable can be done like this.

glyco.plot(X, collapse=FALSE, log.transform=TRUE, group="cc")

As it can be seen the default option is to also conduct a test in difference between groups (Mann-Whitney-Wilcoxon for 2 groups, Kruskal-Wallis for more groups) and print the obtained p-values. The printed values are corrected for multiple testing before printing. As the output you get original p-values and adjusted p-values together with the plot.

Method for multiple testing correction can be adjusted by parameter p.adjust.method.

glyco.plot(X, collapse=FALSE, log.transform=TRUE, group="cc", p.adjust.method="fdr")

Printing p-values in plots can be omitted with print.p.values parameter.

glyco.plot(X, collapse=FALSE, log.transform=TRUE, group="cc", p.adjust.method="fdr",
           print.p.values=FALSE)

When grouping, by default, all glycans are plotted. To plot only those that differ statistically significant parameter all should be used.

Choosing other columns

Function glyco.plot plots all columns whose name starts with GP. Since these plotting techniques can be used on other data as well there is the parameter glyco.names to choose which columns you want to use.

glyco.plot(X, collapse=FALSE, log.transform=TRUE, group="cc", p.adjust.method="fdr",
           print.p.values=FALSE, glyco.names=c("GP1", "GP2"))


Try the glycanr package in your browser

Any scripts or data that you put into this service are public.

glycanr documentation built on March 29, 2021, 5:07 p.m.