Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
Binary file added CoDaSeq/R/.DS_Store
Binary file not shown.
35 changes: 19 additions & 16 deletions CoDaSeq/R/codaSeq.PCAplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
#' `load.sym` (default: `TRUE`).
#' @param plot.ellipses Character vector indicating whether or not to draw
#' confidence ellipses around sample *or* loading groups. Must be one of either
#' `"groups"` or `"loadings"`, or `NULL`.
#' `"groups"` or `"loadings"`, or `NULL` (default: `NULL`).
#' @param plot.density Logical value indicating whether or not to draw density
#' plots for the specified principal components above and beside the main
#' biplot.
#' biplot (default: `NULL`).
#' @param grp A list of groups where each element is a vector containing the
#' indices of group members (default: `NULL`).
#' @param grp.col A vector of the same length as `grp` containing colours for
Expand All @@ -40,7 +40,7 @@
#' each element of `grp.sym` paired with the corresponding element of
#' `grp`).
#' * A character vector equal to `"text"` (plots samples as text, with the
#' label set to `rownames(pcx$x)`).
#' labels set to `rownames(pcx$x)`).
#' @param grp.cex A numeric value indicating the relative size of the group
#' symbols or text to be plotted (default: `1`).
#' @param load.grp A list of loading groups where each element is a vector
Expand All @@ -57,26 +57,29 @@
#' each element of `load.sym` paired with the corresponding element of
#' `load.grp`).
#' * A character vector equal to `"text"` (plots variable loadings as text,
#' with the label set to `rownames(pcx$rotation)`).
#' with the labels set to `rownames(pcx$rotation)`).
#' @param load.cex A numeric value indicating the relative size of the
#' loading symbols or text to be plotted (default: `0.5`).
#' @param PC A numeric vector of length = 2 indicating which prinicpal
#' components should be plotted (default: `c(1,2)`)
#' @param plot.legend A character string equal to either `"groups"` or
#' `"loadings"`, or NULL, indicating whether to draw a legend for groups,
#' loadings or neither (default: `NULL`).
#' @param leg.position A character string equal to one of the following:
#' `"topleft"`, `"top"`, `"topright"`, `"right"`, `"bottomright"`, `"bottom"`,
#' `"bottomleft"`, `"left"`, or `"center"`. Cannot be called in conjunction
#' with `leg.xy` (default: `NULL`).
#' loadings or neither (default: `NULL`). If you wish to draw legends for
#' both groups and loadings, you can call `legend()` immediately after
#' `codaSeq.PCAplot()`, adjusting the `x` and `y` arguments manually
#' (start at zero and play around with the numbers).
#' @param leg.position A character vector indicating legend position presets,
#' equal to one of the following: `"topleft"`, `"top"`, `"topright"`,
#' `"right"`, `"bottomright"`, `"bottom"`, `"bottomleft"`, `"left"`, or
#' `"center"`. Cannot be called alongside with `leg.xy` (default: `NULL`).
#' @param leg.xy A numeric vector of length = 2, specifying the x and y
#' coordinates at which to draw the top-right corner of the legend box. Cannot
#' be called in conjunctionn with `leg.position` (default: `NULL`)
#' be called in conjunction with `leg.position` (default: `NULL`).
#' @param leg.cex A numeric value indicating the relative size of the legend
#' text (default: `0.55`).
#' @param leg.columns A numeric calue indicating the number of columns to split
#' legend items into (default: `1`)
#' @param title A character string containing the desired title of the biplot
#' @param title A character vector containing the desired title of the biplot
#' (default: `""`).
#'
#' @return Returns a plot showing samples and/or loadings as specified by the
Expand Down Expand Up @@ -146,7 +149,7 @@
#'
#' # Bayesian-multiplicative replacement of count-zeros
#' clr.input<-cmultRepl(t(ak_op),label = "0",
#' method = "CZM",output = "p-counts")
#' method = "CZM",, z.warning = 0.99)
#'
#' # CLR-transformation using codaSeq.clr
#' clr.data<-codaSeq.clr(t(clr.input), IQLR = FALSE,
Expand Down Expand Up @@ -388,8 +391,8 @@ codaSeq.PCAplot <- function(pcx, plot.groups=FALSE, plot.loadings=TRUE, plot.ell
if(plot.density=="groups"){
list.group<-list()
for(k in 1:length(grp)){
points.pc1<-pcx$x[,1][grp[[k]]]
points.pc2<-pcx$x[,2][grp[[k]]]
points.pc1<-pcx$x[,PC[1]][grp[[k]]]
points.pc2<-pcx$x[,PC[2]][grp[[k]]]
list.group[[names(grp)[k]]]<-as.data.frame(cbind(points.pc1,points.pc2))
}

Expand Down Expand Up @@ -433,8 +436,8 @@ codaSeq.PCAplot <- function(pcx, plot.groups=FALSE, plot.loadings=TRUE, plot.ell
} else if(plot.density=="loadings"){
list.loadings<-list()
for (k in 1:length(load.grp)) {
points.pc1<-pcx$rotation[,1][load.grp[[k]]]*scale.factor.1
points.pc2<-pcx$rotation[,2][load.grp[[k]]]*scale.factor.2
points.pc1<-pcx$rotation[,PC[1]][load.grp[[k]]]*scale.factor.1
points.pc2<-pcx$rotation[,PC[2]][load.grp[[k]]]*scale.factor.2
list.loadings[[names(load.grp)[k]]]<-as.data.frame(cbind(points.pc1,points.pc2))
}

Expand Down
2 changes: 1 addition & 1 deletion CoDaSeq/R/codaSeq.PCAvalues.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' data("ak_op") # feature table: 4347 OTU x 30 samples (15x ak, 15x op)
#'
#' # Bayesian-multiplicative replacement of count-zeros
#' clr.input<-cmultRepl(t(ak_op),label = "0",
#' clr.input<-cmultRepl(t(ak_op),label = "0", z.warning = 0.99,
#' method = "CZM",output = "p-counts")
#'
#' # CLR-transformation using codaSeq.clr
Expand Down
27 changes: 15 additions & 12 deletions CoDaSeq/man/codaSeq.PCAplot.rd
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ depending on \code{grp.sym} (default: \code{FALSE}).}

\item{plot.ellipses}{Character vector indicating whether or not to draw
confidence ellipses around sample \emph{or} loading groups. Must be one of either
\code{"groups"} or \code{"loadings"}, or \code{NULL}.}
\code{"groups"} or \code{"loadings"}, or \code{NULL} (default: \code{NULL}).}

\item{plot.density}{Logical value indicating whether or not to draw density
plots for the specified principal components above and beside the main
biplot.}
biplot (default: \code{NULL}).}

\item{grp}{A list of groups where each element is a vector containing the
indices of group members (default: \code{NULL}).}
Expand All @@ -48,7 +48,7 @@ specified values to set the \code{pch} argument on a per-group basis, with
each element of \code{grp.sym} paired with the corresponding element of
\code{grp}).
\item A character vector equal to \code{"text"} (plots samples as text, with the
label set to \code{rownames(pcx$x)}).
labels set to \code{rownames(pcx$x)}).
}}

\item{grp.cex}{A numeric value indicating the relative size of the group
Expand All @@ -71,7 +71,7 @@ specified values to set the \code{pch} argument on a per-group basis, with
each element of \code{load.sym} paired with the corresponding element of
\code{load.grp}).
\item A character vector equal to \code{"text"} (plots variable loadings as text,
with the label set to \code{rownames(pcx$rotation)}).
with the labels set to \code{rownames(pcx$rotation)}).
}}

\item{load.cex}{A numeric value indicating the relative size of the
Expand All @@ -82,24 +82,27 @@ components should be plotted (default: \code{c(1,2)})}

\item{plot.legend}{A character string equal to either \code{"groups"} or
\code{"loadings"}, or NULL, indicating whether to draw a legend for groups,
loadings or neither (default: \code{NULL}).}
loadings or neither (default: \code{NULL}). If you wish to draw legends for
both groups and loadings, you can call \code{legend()} immediately after
\code{codaSeq.PCAplot()}, adjusting the \code{x} and \code{y} arguments manually
(start at zero and play around with the numbers).}

\item{leg.position}{A character string equal to one of the following:
\code{"topleft"}, \code{"top"}, \code{"topright"}, \code{"right"}, \code{"bottomright"}, \code{"bottom"},
\code{"bottomleft"}, \code{"left"}, or \code{"center"}. Cannot be called in conjunction
with \code{leg.xy} (default: \code{NULL}).}
\item{leg.position}{A character vector indicating legend position presets,
equal to one of the following: \code{"topleft"}, \code{"top"}, \code{"topright"},
\code{"right"}, \code{"bottomright"}, \code{"bottom"}, \code{"bottomleft"}, \code{"left"}, or
\code{"center"}. Cannot be called alongside with \code{leg.xy} (default: \code{NULL}).}

\item{leg.xy}{A numeric vector of length = 2, specifying the x and y
coordinates at which to draw the top-right corner of the legend box. Cannot
be called in conjunctionn with \code{leg.position} (default: \code{NULL})}
be called in conjunction with \code{leg.position} (default: \code{NULL}).}

\item{leg.cex}{A numeric value indicating the relative size of the legend
text (default: \code{0.55}).}

\item{leg.columns}{A numeric calue indicating the number of columns to split
legend items into (default: \code{1})}

\item{title}{A character string containing the desired title of the biplot
\item{title}{A character vector containing the desired title of the biplot
(default: \code{""}).}
}
\value{
Expand Down Expand Up @@ -152,7 +155,7 @@ symbols<-c(rep(17,13),rep(16,13),11)

# Bayesian-multiplicative replacement of count-zeros
clr.input<-cmultRepl(t(ak_op),label = "0",
method = "CZM",output = "p-counts")
method = "CZM",, z.warning = 0.99)

# CLR-transformation using codaSeq.clr
clr.data<-codaSeq.clr(t(clr.input), IQLR = FALSE,
Expand Down
14 changes: 7 additions & 7 deletions CoDaSeq/vignettes/CoDaSeq_vignette.Rnw
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ We now replace 0 counts in the dataset with imputed values using the Count Zero
# from the zCompositions package
# the table is transposed t() to make the samples by row
# all further analyses have this orientation
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)

# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
Expand All @@ -101,7 +101,7 @@ par(mfrow=c(3,4))

label="ALL"
f <- codaSeq.filter(ak_op, min.reads=1000, samples.by.row=FALSE, min.count=1)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand All @@ -110,7 +110,7 @@ codaSeq.PCAplot(f.pcx, title=label, plot.groups=TRUE, grp.col=rbcol,

label="min.count=100"
f <- codaSeq.filter(ak_op, min.reads=1000, min.count=10, samples.by.row=FALSE)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand All @@ -119,7 +119,7 @@ codaSeq.PCAplot(f.pcx, title=label, plot.groups=TRUE, grp.col=rbcol,

label="min.prop=0.01"
f <- codaSeq.filter(ak_op, min.reads=1000, min.prop=0.01, samples.by.row=FALSE)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand All @@ -128,7 +128,7 @@ codaSeq.PCAplot(f.pcx, title=label, plot.groups=TRUE, grp.col=rbcol,

label="max.prop=0.01"
f <- codaSeq.filter(ak_op, min.reads=1000, min.prop=0.001, max.prop=0.01, samples.by.row=FALSE)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand All @@ -137,7 +137,7 @@ codaSeq.PCAplot(f.pcx, title=label, plot.groups=TRUE, grp.col=rbcol,

label="var.filt=TRUE"
f <- codaSeq.filter(ak_op, min.reads=1000, var.filt=TRUE, samples.by.row=FALSE)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand All @@ -146,7 +146,7 @@ codaSeq.PCAplot(f.pcx, title=label, plot.groups=TRUE, grp.col=rbcol,

label="min.occurrence=0.5"
f <- codaSeq.filter(ak_op, min.reads=1000, min.occurrence=0.5, samples.by.row=FALSE)
f.n0 <- cmultRepl(t(f), label=0, method="CZM")
f.n0 <- cmultRepl(t(f), label=0, method="CZM", z.warning = 0.99)
# perform the centered log-ratio transformation
f.clr <- codaSeq.clr(f.n0, samples.by.row=TRUE)
f.pcx <- prcomp(f.clr)
Expand Down