diff --git a/DESCRIPTION b/DESCRIPTION index 9371463..ac4de10 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Depends: R (>= 3.3.2) License: What license is it under? Encoding: UTF-8 LazyData: true -RoxygenNote: 6.0.1.9000 +RoxygenNote: 7.2.3 Suggests: knitr, rmarkdown, Cairo, diff --git a/NAMESPACE b/NAMESPACE index a3175d0..321064a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,18 +8,29 @@ S3method(flagSamples,sampleDataset) S3method(getAttr,sampleDataset) S3method(inferAncestry,default) S3method(inferAncestry,sampleDataset) +S3method(outlierPlots,default) +S3method(outlierPlots,sampleDataset) S3method(print,sampleDataset) +S3method(sampleQcPlot,default) S3method(sampleQcPlot,sampleDataset) S3method(save,sampleDataset) S3method(setAttr,sampleDataset) S3method(sort,sampleDataset) +export(GeomSplitViolin) export(PCplots) export(calZscore) export(flagSamples) +export(geom_split_violin) export(getAttr) export(hasAttr) export(inferAncestry) +export(multiplot) +export(multiplotWithSharedLegend) +export(outlierPlots) +export(runQcExplorer) export(sampleDataset) export(sampleQcPlot) export(save) +export(scatter) export(setAttr) +importFrom(ggplot2,Geom) diff --git a/R/S3Method.R b/R/S3Method.R index f62fc35..cee71e4 100644 --- a/R/S3Method.R +++ b/R/S3Method.R @@ -1,10 +1,15 @@ #' Save an sds to a specific format #' -#' Save an sds to tsv, RDS or excel format +#' @description Save an sds to tsv, RDS or excel format #' -#' @param sds +#' @param sds sample dataset +#' @param ... Additional arguments to be passed. #' #' @export +#' @seealso{\link{sort.sampleDataset}} +#' @seealso{\link{save.sampleDataset}} +#' @seealso{\link{dim.sampleDataset}} +#' @seealso{\link{print.sampleDataset}} save <-function(sds, ...) UseMethod('save') @@ -36,7 +41,7 @@ save.sampleDataset <- function(sds, RDS = NULL, tsv = NULL, xls = NULL) { #' #' @param sds sample dataset #' @param by sort by which category -#' @return an sample dataset sds with updated index +#' @return A sample dataset `sds` with updated index. #' #' @export @@ -49,15 +54,18 @@ sort.sampleDataset <- function(sds, by) { #' Show dimensions of sample dataset sds #' -#' @param sds sample data set sds +#' @param sds Sample dataset `sds`. #' @return a vector of rows and columns of the data frame of sample data set #' #' @export - dim.sampleDataset <- function(sds){ dim(sds$df) } +#' Print information about the sample dataset `sds`. +#' +#' @param sds Sample dataset `sds`. +#' #' @export print.sampleDataset <- function(sds) { cat("\nClass: SampleDataset\n", diff --git a/R/calZscore.R b/R/calZscore.R index e17c093..6a9bd77 100644 --- a/R/calZscore.R +++ b/R/calZscore.R @@ -1,11 +1,18 @@ #' Calculate z-score of a vector or QC metrics of a SampleDataset #' -#' @description Calculate z-score of a vector or QC metrics of a SampleDataset, -#' see details in calZscore.default and calZscore.sampleDataset -#' @return The form of the value returned by predict depends on the class of -#' its argument. See the documentation of the particular methods for -#' details of what is produced by that method. +#' @description +#' Calculate z-score of a vector or QC metrics of a SampleDataset. +#' +#' @param ... Additional arguments to be passed. +#' +#' @return +#' The form of the value returned by predict depends on the class of +#' its argument. See the documentation of the particular methods for +#' details of what is produced by that method. +#' #' @export +#' @seealso{\link{calZscore.default}} +#' @seealso{\link{calZscore.sampleDataset}} calZscore <- function(...) UseMethod("calZscore") @@ -14,7 +21,7 @@ calZscore <- function(...) UseMethod("calZscore") #' @description Calculate z-scores of a vector #' @param x a vector of values or a sample dataset object #' @param mad binary, whether use Median Absolute Deviation to calculate the -#' standard deviation +#' standard deviation.Default is TRUE. #' @return a vector of z-scores #' @export @@ -30,15 +37,13 @@ calZscore.default <- function(x, mad = T) { #' Calculate z-scores of QC metrics of a SampleDataset #' -#' @param object a sampleDataset object -#' @param strat optional, logical, variable or vector of attributes the sample -#' will be stratified by -#' @param mad optional, binary, whether use Median Absolute Deviation to -#' calculate z-score or not, default is True -#' @param qcMetrics optional, a vector of names of qc metrics to compute zscore -#' @param maxVcfZ optional, logical, calculate to report maximun Vcf Zscore -#' @return sampleDataset object, with additional attributes: zscoreBy, zscore -#' and maximumVcfZscore +#' @param object a sampleDataset object. +#' @param strat optional, logical, variable, or vector of attributes the sample +#' will be stratified by. +#' @param qcMetrics optional, a vector of names of QC metrics to compute z-score. +#' @param mad optional, binary, whether to use Median Absolute Deviation to +#' calculate z-score or not, default is TRUE. +#' @param maxVcfZ optional, logical, calculate to report maximum Vcf Z-score. #' @export calZscore.sampleDataset <- function ( diff --git a/R/flagSamples.R b/R/flagSamples.R index 374f158..1e900f4 100644 --- a/R/flagSamples.R +++ b/R/flagSamples.R @@ -2,6 +2,8 @@ #' #' Flag a sample from a data frame or a sampleDataset #' @export +#' @seealso{\link{flagSamples.default}} +#' @seealso{\link{flagSamples.sampleDataset}} flagSamples <- function(...) UseMethod('flagSamples') @@ -21,6 +23,8 @@ flagSamples <- function(...) UseMethod('flagSamples') #' #' @return Return a data frame #' @export +#' @seealso{\link{flagSamples}} +#' @seealso{\link{flagSamples.sampleDataset}} flagSamples.default <- function (df, column, cutoff, greater) { column = as.character(column) @@ -55,6 +59,8 @@ flagSamples.default <- function (df, column, cutoff, greater) { #' based on z-score if not specified. Default value is NULL. #' @return an updated sample dataset sds with flags added. #' @export +#' @seealso{\link{flagSamples.default}} +#' @seealso{\link{flagSamples}} flagSamples.sampleDataset <- function(sds, cutoffs, zscore = NULL){ # conditions diff --git a/R/getAttr.R b/R/getAttr.R index 210d5e7..86e5c15 100644 --- a/R/getAttr.R +++ b/R/getAttr.R @@ -1,7 +1,13 @@ #' Get attributes of an sds #' -#' @param sds sample dataset sds +#' @param sds sample dataset +#' @param attribute name of attribute to return +#' @param showID whether to display sample IDs or not in the output data frame +#' +#' @return a data frame that contains values of specific attribute #' @export +#' +#' @seealso{\link{getAttr.sampleDataset}} getAttr <- function (sds, ...) UseMethod('getAttr', sds) @@ -9,10 +15,9 @@ getAttr <- function (sds, ...) UseMethod('getAttr', sds) #' #' @param sds sample data set #' @param attribute name of attribute to return -#' @param showID whether to display sample IDs or not in the output data fram -#' @param return a data frame that contains values of specific attribute +#' @param showID whether to display sample IDs or not in the output data frame #' -#' @return data frame +#' @return a data frame that contains values of specific attribute #' @export getAttr.sampleDataset <- function(sds, attribute, showID = F) { diff --git a/R/inferAncestry.R b/R/inferAncestry.R index 92a14cb..1bc41f6 100644 --- a/R/inferAncestry.R +++ b/R/inferAncestry.R @@ -1,18 +1,34 @@ #' Predict sample ancestry from genotype Principle Components #' #' Principle Components of genotypes with k nearest neighbours. -#' @return Updated sample Dataset sds with inferredAncestry tag +#' +#' @param ... Additional parameters for future expansion. +#' @return Updated sample Dataset sds with inferredAncestry tag. #' @export +#' +#' @examples +#' # Usage of inferAncestry +#' sds <- inferAncestry.sampleDataset(sds, trainSet, knownAncestry, nPC = 3, k = 5) +#' @seealso{\link{inferAncestry.sampleDataset}} +#' @seealso{\link{inferAncestry.default}} inferAncestry <- function(...) UseMethod('inferAncestry') -#' Infer anestry with KNN +#' Infer ancestry with KNN +#' +#' @param testSet Matrix used for test. +#' @param trainSet Matrix for training PCs. +#' @param ancestry Ancestries corresponding to the training PCs. +#' @param k Number of nearest neighbors to use in this classification. #' -#' @param testSet matrix used for test -#' @param trainSet matrix for training PCs -#' @param ancestry ancestries correspond to the training PCs -#' @param k Number of nearest neighbour to use in this classfication +#' @return A vector of inferred ancestries. #' @export +#' +#' @examples +#' # Usage of inferAncestry.default +#' inferredAncestry <- inferAncestry.default(testSet, trainSet, ancestry, k = 5) +#' @seealso{\link{inferAncestry.sampleDataset}} +#' @seealso{\link{inferAncestry}} inferAncestry.default <- function(testSet, trainSet, ancestry, k = 5) { inferredAncestry = class::knn(train = trainSet, test = testSet, cl = ancestry, k = k) @@ -21,12 +37,20 @@ inferAncestry.default <- function(testSet, trainSet, ancestry, k = 5) { #' Infer sample ancestry #' -#' @param sds Sample Dataset sds for Ancestry predition -#' @param trainSet data frame with genotype PCs for each sample with known ancestry -#' @param knownAncestry a vector with known ancestry for each sample in same order of trainSet -#' @param nPC Use first n PCs to predict ancestry +#' @param sds Sample Dataset sds for ancestry prediction. +#' @param trainSet Data frame with genotype PCs for each sample with known ancestry. +#' @param knownAncestry A vector with known ancestry for each sample in the same order as trainSet. +#' @param nPC Use the first n PCs to predict ancestry. #' +#' @return Updated sample Dataset sds with inferredAncestry tag. #' @export +#' +#' @examples +#' # Usage of inferAncestry.sampleDataset +#' sds <- inferAncestry.sampleDataset(sds, trainSet, knownAncestry, nPC = 3, k = 5) +#' +#' @seealso{\link{inferAncestry}} +#' @seealso{\link{inferAncestry.default}} inferAncestry.sampleDataset <- function( sds, trainSet, knownAncestry, nPC = 3, k = 5 diff --git a/R/plot.R b/R/plot.R index 94dafc3..667501b 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1,18 +1,32 @@ #' Generate scatter plot of QC metrics according to samples #' -#' @param sds sample dataset sds +#' @param sds sample dataset `sds` #' @param ... other arguments #' +#' @seealso{\link{sampleQcPlot.default}} +#' @seealso{\link{sampleQcPlot.sampleDataset}} #' @export #' sampleQcPlot <- function (sds, ...) UseMethod('sampleQcPlot') #' Generate scatter plot of QC metrics #' -#' @param sds sample dataset sds -#' @param annot which annot to visualize -#' @param pca whether perform pca plot +#' This function generates a scatter plot of QC metrics based on the specified parameters. #' +#' @param data Sample dataset `data`. +#' @param primaryID Primary ID used for each sample. +#' @param qcMetric QC metric to visualize. +#' @param annot Annotation variable to stratify by (optional). +#' @param outliers Samples to highlight as outliers (optional). +#' @param legend Logical, whether to show the legend (default is TRUE). +#' @param main Title of the plot (default is 'QC'). +#' @param geom Type of plot: 'scatter', 'violin', or 'hist' (default is 'scatter'). +#' +#' @return A scatter plot of QC metrics. +#' +#' @seealso{\link{sampleQcPlot}} +#' @seealso{\link{sampleQcPlot.default}} +#' @export sampleQcPlot.default <- function( data, primaryID, qcMetric, annot = NULL, outliers = NULL, legend = T, @@ -45,7 +59,7 @@ sampleQcPlot.default <- function( #' Generate a panel of sample QC plots across a list of qcMetrics #' -#' @param sds SampleDataset sds +#' @param sds SampleDataset `sds` #' @param annot optional, a character string of sample annot to stratify by #' @param qcMetrics a character string or a vector includes QC metrics to #' explore; if unspecified, all QC metrics in the SDS will @@ -56,7 +70,11 @@ sampleQcPlot.default <- function( #' @param legend whether to include a legend or not #' @param position position of the legend #' @param sort whether to sort by annot when ploting -#' @return a list of grob sdss +#' @return a list of grob sds +#' +#' @seealso{\link{sampleQcPlot}} +#' @seealso{\link{sampleQcPlot.sampleDataset}} +#' #' @export sampleQcPlot.sampleDataset <- function( @@ -91,13 +109,52 @@ sampleQcPlot.sampleDataset <- function( #' Produce outlier plot #' +#' @param tab Input table with data. +#' @param qcMetrics Metrics to plot. +#' @param strat Factor by which to stratify the dots. +#' @param main Title of the plot. +#' @param outliers List of outliers. +#' @param primaryID Identifier for samples (if available). +#' @param type Type of plot ('violin' or 'density'). +#' +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} +#' +#' @export + outlierPlots <- function(...) UseMethod('outlierPlots') -#' @param tab input table with -#' @param qcMetrics which metrics to plot -#' @param strat by which factor to stratify the dots -#' @param main title of the -#' @return +#' Generate outlier plots for a dataset +#' +#' @param tab Input table with data. +#' @param qcMetrics Metrics to plot. +#' @param strat Factor by which to stratify the dots. +#' @param main Title of the plot. +#' @param outliers List of outliers. +#' @param primaryID Identifier for samples (if available). +#' @param type Type of plot ('violin' or 'density'). +#' +#' @return A list of outlier plots. +#' +#' @examples +#' \dontrun{ +#' # Example usage: +#' outlierPlots.default(tab, qcMetrics = "Metric1", strat = "Group", main = "Outlier Plot") +#' } +#' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} +#' @export outlierPlots.default <- function(tab, qcMetrics, strat, main, outliers, primaryID=NULL, type='violin'){ @@ -129,7 +186,27 @@ outlierPlots.default <- function(tab, qcMetrics, strat, main, outliers, #' Produce outlier plots for a sampleDataset #' -#' @return A pdf with all plots +#' @param sds A sample dataset object. +#' @param title Title for the PDF file. +#' @param width Width of the PDF. +#' @param height Height of the PDF. +#' +#' @return A PDF file containing outlier plots. +#' +#' @examples +#' \dontrun{ +#' # Example usage: +#' outlierPlots.sampleDataset(sds, title = "Outlier_Plots", width = 15, height = 6) +#' } +#' +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} +#' @export outlierPlots.sampleDataset <- function( sds, title, width=15, height=6 @@ -161,12 +238,24 @@ outlierPlots.sampleDataset <- function( dev.off() } -#' Generate PC plot of an SampleDataset sds +#' Generate PC plot of a SampleDataset #' -#' @param sds sample data set -#' @param showPlot whether to show plot +#' This function generates principal component (PC) plots based on the specified SampleDataset. #' -#' @return a list of ggplot sdss +#' @param sds SampleDataset object containing PC and inferredAncestry attributes. +#' @param showPlot Logical, whether to display the plots (default is TRUE). +#' @param cor Logical, whether to calculate correlation between PCs (default is FALSE). +#' @param outliers Samples to highlight as outliers (optional). +#' +#' @return A list of ggplot objects representing PC plots. +#' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} #' #' @export @@ -189,12 +278,33 @@ PCplots <- function (sds, showPlot=T, cor=F, outliers=NULL) { return(plt) } -#' generate multi panel plots +#' Generate multi-panel plots +#' +#' This function creates a multi-panel plot from a list of ggplot2 objects. #' -#' @param plotlist a list of plot -#' @param file +#' @param ... ggplot2 objects +#' @param plotlist a list of ggplot2 objects +#' @param file output file name (optional) #' @param ncols number of columns in the plot +#' @param layout matrix specifying the layout of panels +#' +#' @return The multi-panel plot +#' +#' @examples +#' \dontrun{ +#' # Example usage: +#' multiplot(plot1, plot2, ncols = 2) +#' } #' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} +#' +#' @export multiplot <- function(..., plotlist=NULL, file=NULL, ncols=1, layout=NULL) { # This function is modified from multiplot of Cookbook of R @@ -249,6 +359,15 @@ multiplot <- function(..., plotlist=NULL, file=NULL, ncols=1, layout=NULL) { #' @param main main title of the plot #' @param legend binary, whether to plot legend or not #' @param primaryID the primary ID used to +#' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' @seealso{\link{geom_split_violin}} +#' #' @export #' scatter <- function( @@ -287,7 +406,16 @@ scatter <- function( #' @param position Position of the legend, between "bottom" and "right" #' @param show whether show the plot or not #' -#' @return a grid graphical sds (grob) +#' @return a grid graphical `sds` (grob) +#' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{geom_split_violin}} +#' #' @export #' multiplotWithSharedLegend <- function( @@ -324,6 +452,8 @@ multiplotWithSharedLegend <- function( return(combined) } +#' @importFrom ggplot2 Geom +#' @export GeomSplitViolin <- ggplot2::ggproto( "GeomSplitViolin", ggplot2::GeomViolin, @@ -356,7 +486,32 @@ GeomSplitViolin <- ggplot2::ggproto( } }) +#' Create a split violin plot +#' +#' @param mapping Aesthetic mappings +#' @param data The data to be displayed in this layer +#' @param stat The statistical transformation to use on the data for this layer +#' @param position Position adjustment +#' @param ... Other arguments passed to the layer +#' @param draw_quantiles Quantiles to be drawn +#' @param trim Should the data be trimmed? +#' @param scale Area or count for width of violin +#' @param na.rm Should missing values be removed? +#' @param show.legend Should this layer be included in the legends? +#' @param inherit.aes Should inherit aesthetics from the parent plot? +#' +#' @return A ggplot2 layer for a split violin plot +#' +#' @seealso{\link{outlierPlots}} +#' @seealso{\link{outlierPlots.default}} +#' @seealso{\link{outlierPlots.sampleDataset}} +#' @seealso{\link{PCplots}} +#' @seealso{\link{multiplot}} +#' @seealso{\link{scatter}} +#' @seealso{\link{multiplotWithSharedLegend}} +#' #' @export + geom_split_violin <- function ( mapping = NULL, data = NULL, stat = "ydensity", position = "identity", ..., draw_quantiles = NULL, trim = TRUE, scale = "area", na.rm = FALSE, diff --git a/R/sampleDataset.R b/R/sampleDataset.R index 425ab8b..9d49e0f 100644 --- a/R/sampleDataset.R +++ b/R/sampleDataset.R @@ -30,10 +30,9 @@ #' @param annotInput a tsv file or data.frame that contains sample annot, #' when df was defined, this item could be a vector containing #' names of anntations. +#' @param primaryID ID used for each sample #' @param bamQcInput a tsv file data frame that contains BAM QC metrics. -#' #' @param vcfQcInput a tsv file or a data frame that contains VCF QC metrics -#' @param primaryID ID used for each sample #' @param stratify a scalar or vector containing annot to stratify against #' @param df optional, an R dataframe that contains all sample level data, #' including QC metrics and sample annot. When df is provided, diff --git a/R/setAttr.R b/R/setAttr.R index f7200e7..3a35831 100644 --- a/R/setAttr.R +++ b/R/setAttr.R @@ -1,21 +1,27 @@ -#' Update a Sample Data Set +#' Update a Sample Dataset #' -#' Update entries of sample data set, such as the df, bamQcMetr, vcfQcMetr +#' @description +#' Update entries of a sample dataset, such as the df, bamQcMetr, vcfQcMetr. #' -#' @param sds sample dataset sds -#' @param ... other arguments +#' @param sds A sample dataset object +#' @param attributes character vector specifying the attributes to add or update in the sample Dataset +#' @param data data.frame, content to add to the dataframe +#' @param primaryID primary key of input data frame +#' @param overwrite logical, indicating whether to overwrite existing attributes if they already exist #' -#' @return sds +#' @return An updated sample dataset +#' @seealso{\link{setAttr.sampleDataset}} #' @export -#' + setAttr <- function (sds, ...) UseMethod('setAttr', sds) #' Set attributes of a sample dataset #' #' @param sds sampleDataset -#' @param attributes which entry to add to sample Dataset +#' @param attributes character vector specifying the attributes to add or update in the sample Dataset #' @param data data.frame, content to add to the dataframe -#' @param by primary key of input data frame +#' @param primaryID primary key of input data frame +#' @param overwrite logical, indicating whether to overwrite existing attributes if they already exist #' #' @return updated sampleDataset sds #' @export diff --git a/man/PCplots.Rd b/man/PCplots.Rd index e1b193d..3b6f934 100644 --- a/man/PCplots.Rd +++ b/man/PCplots.Rd @@ -2,10 +2,37 @@ % Please edit documentation in R/plot.R \name{PCplots} \alias{PCplots} -\title{Generate PC plot of an SampleDataset Object} +\title{Generate PC plot of a SampleDataset} \usage{ -PCplots(object, showPlot = T) +PCplots(sds, showPlot = T, cor = F, outliers = NULL) +} +\arguments{ +\item{sds}{SampleDataset object containing PC and inferredAncestry attributes.} + +\item{showPlot}{Logical, whether to display the plots (default is TRUE).} + +\item{cor}{Logical, whether to calculate correlation between PCs (default is FALSE).} + +\item{outliers}{Samples to highlight as outliers (optional).} +} +\value{ +A list of ggplot objects representing PC plots. } \description{ -Generate PC plot of an SampleDataset Object +This function generates principal component (PC) plots based on the specified SampleDataset. +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} } diff --git a/man/calZscore.Rd b/man/calZscore.Rd index ee76292..225666f 100644 --- a/man/calZscore.Rd +++ b/man/calZscore.Rd @@ -6,9 +6,19 @@ \usage{ calZscore(...) } +\arguments{ +\item{...}{Additional arguments to be passed.} +} \value{ -The form of the value returned by predict depends on the class of its argument. See the documentation of the particular methods for details of what is produced by that method. +The form of the value returned by predict depends on the class of +its argument. See the documentation of the particular methods for +details of what is produced by that method. } \description{ -Calculate z-score of a vector or QC metrics of a SampleDataset, see details in calZscore.default and calZscore.sampleDataset +Calculate z-score of a vector or QC metrics of a SampleDataset. +} +\seealso{ +{\link{calZscore.default}} + +{\link{calZscore.sampleDataset}} } diff --git a/man/calZscore.default.Rd b/man/calZscore.default.Rd index 8414a93..e0c5ecc 100644 --- a/man/calZscore.default.Rd +++ b/man/calZscore.default.Rd @@ -9,7 +9,8 @@ \arguments{ \item{x}{a vector of values or a sample dataset object} -\item{mad}{binary, whether use Median Absolute Deviation to calculate the standard deviation} +\item{mad}{binary, whether use Median Absolute Deviation to calculate the +standard deviation.Default is TRUE.} } \value{ a vector of z-scores diff --git a/man/calZscore.sampleDataset.Rd b/man/calZscore.sampleDataset.Rd index 331c714..1fb5f8b 100644 --- a/man/calZscore.sampleDataset.Rd +++ b/man/calZscore.sampleDataset.Rd @@ -4,20 +4,20 @@ \alias{calZscore.sampleDataset} \title{Calculate z-scores of QC metrics of a SampleDataset} \usage{ -\method{calZscore}{sampleDataset}(object, strat = NULL, qcMetrics = NULL, - mad = T) +\method{calZscore}{sampleDataset}(object, strat = NULL, qcMetrics = NULL, mad = T, maxVcfZ = F) } \arguments{ -\item{object}{a sample data set} +\item{object}{a sampleDataset object.} -\item{strat}{variable or vector of attributes the sample will be stratified by} +\item{strat}{optional, logical, variable, or vector of attributes the sample +will be stratified by.} -\item{qcMetrics}{optional, which QC metrics should be stratified on.} +\item{qcMetrics}{optional, a vector of names of QC metrics to compute z-score.} -\item{mad}{defaultwhether use Median Absolute Deviation to calculate z-score.} -} -\value{ -sampleDataset object +\item{mad}{optional, binary, whether to use Median Absolute Deviation to +calculate z-score or not, default is TRUE.} + +\item{maxVcfZ}{optional, logical, calculate to report maximum Vcf Z-score.} } \description{ Calculate z-scores of QC metrics of a SampleDataset diff --git a/man/dim.sampleDataset.Rd b/man/dim.sampleDataset.Rd index 610fd89..ab9232c 100644 --- a/man/dim.sampleDataset.Rd +++ b/man/dim.sampleDataset.Rd @@ -2,16 +2,16 @@ % Please edit documentation in R/S3Method.R \name{dim.sampleDataset} \alias{dim.sampleDataset} -\title{Show dimensions of sample dataset object} +\title{Show dimensions of sample dataset sds} \usage{ -\method{dim}{sampleDataset}(object) +\method{dim}{sampleDataset}(sds) } \arguments{ -\item{object}{sample data set object} +\item{sds}{Sample dataset `sds`.} } \value{ a vector of rows and columns of the data frame of sample data set } \description{ -Show dimensions of sample dataset object +Show dimensions of sample dataset sds } diff --git a/man/dot-bamQcMetr.Rd b/man/dot-bamQcMetr.Rd deleted file mode 100644 index 64cc7fb..0000000 --- a/man/dot-bamQcMetr.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/utils.R -\name{.bamQcMetr} -\alias{.bamQcMetr} -\title{default bam QC parameters from picard tools} -\usage{ -.bamQcMetr() -} -\value{ -a vector of QC metrics names -} -\description{ -default bam QC parameters from picard tools -} diff --git a/man/dot-calMaxVcfZ.Rd b/man/dot-calMaxVcfZ.Rd new file mode 100644 index 0000000..fb13d6f --- /dev/null +++ b/man/dot-calMaxVcfZ.Rd @@ -0,0 +1,13 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calZscore.R +\name{.calMaxVcfZ} +\alias{.calMaxVcfZ} +\title{Calculate maximum vcf z-score and update the object with a maxVcfzscore +column} +\usage{ +.calMaxVcfZ(object, qcMetrics) +} +\description{ +Calculate maximum vcf z-score and update the object with a maxVcfzscore +column +} diff --git a/man/dot-multiplotWithSharedLegend.Rd b/man/dot-multiplotWithSharedLegend.Rd deleted file mode 100644 index db24114..0000000 --- a/man/dot-multiplotWithSharedLegend.Rd +++ /dev/null @@ -1,16 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\name{.multiplotWithSharedLegend} -\alias{.multiplotWithSharedLegend} -\title{Generate multiple plots with shared figure legend} -\usage{ -.multiplotWithSharedLegend(plots, ncols = 5, position = c("bottom", - "right"), show = T) -} -\description{ -:param plots a list of grob objects -:param nrows number of rows -} -\details{ -:Returns a grid graphical object (grob) -} diff --git a/man/dot-scatter.Rd b/man/dot-scatter.Rd deleted file mode 100644 index d00b5fb..0000000 --- a/man/dot-scatter.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\name{.scatter} -\alias{.scatter} -\title{Produce a scatter plot from a data frame} -\usage{ -.scatter(data, x, y, strat, xlab = NULL, ylab = NULL, outliers = NULL, - main = NULL, legend = T, primaryID = NULL) -} -\description{ -param data a data.frame -param strat by which column to stratify -param outliers a vector of outliers -} diff --git a/man/dot-toSameLength.Rd b/man/dot-toSameLength.Rd new file mode 100644 index 0000000..6da1451 --- /dev/null +++ b/man/dot-toSameLength.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{.toSameLength} +\alias{.toSameLength} +\title{Normalize elements of a vector to similar size} +\usage{ +.toSameLength(vec) +} +\description{ +Normalize elements of a vector to similar size +} diff --git a/man/dot-zscoreColNames.Rd b/man/dot-zscoreColNames.Rd new file mode 100644 index 0000000..2df6fb8 --- /dev/null +++ b/man/dot-zscoreColNames.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calZscore.R +\name{.zscoreColNames} +\alias{.zscoreColNames} +\title{Get z-score column names} +\usage{ +.zscoreColNames(qcMetrics) +} +\description{ +Get z-score column names +} diff --git a/man/flagSamples.Rd b/man/flagSamples.Rd index 3914b36..830719b 100644 --- a/man/flagSamples.Rd +++ b/man/flagSamples.Rd @@ -9,3 +9,8 @@ flagSamples(...) \description{ Flag a sample from a data frame or a sampleDataset } +\seealso{ +{\link{flagSamples.default}} + +{\link{flagSamples.sampleDataset}} +} diff --git a/man/flagSamples.default.Rd b/man/flagSamples.default.Rd index 674f086..0411429 100644 --- a/man/flagSamples.default.Rd +++ b/man/flagSamples.default.Rd @@ -2,16 +2,33 @@ % Please edit documentation in R/flagSamples.R \name{flagSamples.default} \alias{flagSamples.default} -\title{Flag a sample from a data frame} +\title{Flag rows of a data.frame based on values of a column} \usage{ -\method{flagSamples}{default}(df, stat, cutoff, greater = TRUE, abs = F) +\method{flagSamples}{default}(df, column, cutoff, greater) } \arguments{ \item{df}{a data frame contained summary statistics} + +\item{column}{character, column of a data frame} + +\item{cutoff}{numberic,} + +\item{greater}{logical, whether to flag rows that are greater or equal to +the cutoff} + +\item{abs}{} } \value{ Return a data frame } \description{ -Flag a sample from a data frame +Compare values in a column of data.frame, and add a +flaggedReason column in the data + +Caveat: this function is not able to define greater or equal +} +\seealso{ +{\link{flagSamples}} + +{\link{flagSamples.sampleDataset}} } diff --git a/man/flagSamples.sampleDataset.Rd b/man/flagSamples.sampleDataset.Rd index 00b226f..3aa0a0a 100644 --- a/man/flagSamples.sampleDataset.Rd +++ b/man/flagSamples.sampleDataset.Rd @@ -2,20 +2,28 @@ % Please edit documentation in R/flagSamples.R \name{flagSamples.sampleDataset} \alias{flagSamples.sampleDataset} -\title{Flag a sample from a sample data set} +\title{Flag a sample from a sampleDataset} \usage{ -\method{flagSamples}{sampleDataset}(object, cutoffs, zscore = NULL) +\method{flagSamples}{sampleDataset}(sds, cutoffs, zscore = NULL) } \arguments{ -\item{object}{sample data set} +\item{sds}{a sampleDataset sds} -\item{cutoffs}{a data frame that contains three columns, including "qcMetrics", "value" and "greater"} +\item{cutoffs}{a data.frame that specifies cutoff values for qcMetrics. +Contains three columns, including "qcMetrics", "value" +and "greater"} -\item{zscore}{zscore cutoff used} +\item{zscore}{a scalar value that zscore cutoff used, will not flag samples +based on z-score if not specified. Default value is NULL.} } \value{ -an updated sample dataset object with flags added. +an updated sample dataset sds with flags added. } \description{ -Flag a sample from a sample data set +Flag a sample from a sampleDataset +} +\seealso{ +{\link{flagSamples.default}} + +{\link{flagSamples}} } diff --git a/man/geom_split_violin.Rd b/man/geom_split_violin.Rd new file mode 100644 index 0000000..ae82694 --- /dev/null +++ b/man/geom_split_violin.Rd @@ -0,0 +1,64 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{geom_split_violin} +\alias{geom_split_violin} +\title{Create a split violin plot} +\usage{ +geom_split_violin( + mapping = NULL, + data = NULL, + stat = "ydensity", + position = "identity", + ..., + draw_quantiles = NULL, + trim = TRUE, + scale = "area", + na.rm = FALSE, + show.legend = NA, + inherit.aes = TRUE +) +} +\arguments{ +\item{mapping}{Aesthetic mappings} + +\item{data}{The data to be displayed in this layer} + +\item{stat}{The statistical transformation to use on the data for this layer} + +\item{position}{Position adjustment} + +\item{...}{Other arguments passed to the layer} + +\item{draw_quantiles}{Quantiles to be drawn} + +\item{trim}{Should the data be trimmed?} + +\item{scale}{Area or count for width of violin} + +\item{na.rm}{Should missing values be removed?} + +\item{show.legend}{Should this layer be included in the legends?} + +\item{inherit.aes}{Should inherit aesthetics from the parent plot?} +} +\value{ +A ggplot2 layer for a split violin plot +} +\description{ +Create a split violin plot +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} +} diff --git a/man/getAttr.Rd b/man/getAttr.Rd index c594190..19a3d67 100644 --- a/man/getAttr.Rd +++ b/man/getAttr.Rd @@ -2,13 +2,23 @@ % Please edit documentation in R/getAttr.R \name{getAttr} \alias{getAttr} -\title{Get attributes of an object} +\title{Get attributes of an sds} \usage{ -getAttr(object, ...) +getAttr(sds, ...) } \arguments{ -\item{object}{sample dataset object} +\item{sds}{sample dataset} + +\item{attribute}{name of attribute to return} + +\item{showID}{whether to display sample IDs or not in the output data frame} +} +\value{ +a data frame that contains values of specific attribute } \description{ -Get attributes of an object +Get attributes of an sds +} +\seealso{ +{\link{getAttr.sampleDataset}} } diff --git a/man/getAttr.sampleDataset.Rd b/man/getAttr.sampleDataset.Rd index 6933a55..42f52f9 100644 --- a/man/getAttr.sampleDataset.Rd +++ b/man/getAttr.sampleDataset.Rd @@ -4,19 +4,17 @@ \alias{getAttr.sampleDataset} \title{Get attributes of a SampleDataset} \usage{ -\method{getAttr}{sampleDataset}(object, attribute, showID = F) +\method{getAttr}{sampleDataset}(sds, attribute, showID = F) } \arguments{ -\item{object}{sample data set} +\item{sds}{sample data set} \item{attribute}{name of attribute to return} -\item{showID}{whether to display sample IDs or not in the output data fram} - -\item{return}{a data frame that contains values of specific attribute} +\item{showID}{whether to display sample IDs or not in the output data frame} } \value{ -data frame +a data frame that contains values of specific attribute } \description{ Get attributes of a SampleDataset diff --git a/man/hasAttr.Rd b/man/hasAttr.Rd index c428cac..dbad741 100644 --- a/man/hasAttr.Rd +++ b/man/hasAttr.Rd @@ -4,10 +4,10 @@ \alias{hasAttr} \title{Check whether the sampleDataset has attributes provided} \usage{ -hasAttr(object, attr) +hasAttr(sds, attr) } \arguments{ -\item{object}{a sampleDataset object} +\item{sds}{a sampleDataset sds} \item{attr}{attributes} } diff --git a/man/inferAncestry.Rd b/man/inferAncestry.Rd index 7f6b556..c372f09 100644 --- a/man/inferAncestry.Rd +++ b/man/inferAncestry.Rd @@ -6,9 +6,21 @@ \usage{ inferAncestry(...) } +\arguments{ +\item{...}{Additional parameters for future expansion.} +} \value{ -Updated sample Dataset object with inferredAncestry tag +Updated sample Dataset sds with inferredAncestry tag. } \description{ Principle Components of genotypes with k nearest neighbours. } +\examples{ +# Usage of inferAncestry +sds <- inferAncestry.sampleDataset(sds, trainSet, knownAncestry, nPC = 3, k = 5) +} +\seealso{ +{\link{inferAncestry.sampleDataset}} + +{\link{inferAncestry.default}} +} diff --git a/man/inferAncestry.default.Rd b/man/inferAncestry.default.Rd index b86a7bf..72879bb 100644 --- a/man/inferAncestry.default.Rd +++ b/man/inferAncestry.default.Rd @@ -2,19 +2,31 @@ % Please edit documentation in R/inferAncestry.R \name{inferAncestry.default} \alias{inferAncestry.default} -\title{Infer anestry with KNN} +\title{Infer ancestry with KNN} \usage{ \method{inferAncestry}{default}(testSet, trainSet, ancestry, k = 5) } \arguments{ -\item{testSet}{matrix used for test} +\item{testSet}{Matrix used for test.} -\item{trainSet}{matrix for training PCs} +\item{trainSet}{Matrix for training PCs.} -\item{ancestry}{ancestries correspond to the training PCs} +\item{ancestry}{Ancestries corresponding to the training PCs.} -\item{k}{Number of nearest neighbour to use in this classfication} +\item{k}{Number of nearest neighbors to use in this classification.} +} +\value{ +A vector of inferred ancestries. } \description{ -Infer anestry with KNN +Infer ancestry with KNN +} +\examples{ +# Usage of inferAncestry.default +inferredAncestry <- inferAncestry.default(testSet, trainSet, ancestry, k = 5) +} +\seealso{ +{\link{inferAncestry.sampleDataset}} + +{\link{inferAncestry}} } diff --git a/man/inferAncestry.sampleDataset.Rd b/man/inferAncestry.sampleDataset.Rd index 41dd0e6..dc32aaa 100644 --- a/man/inferAncestry.sampleDataset.Rd +++ b/man/inferAncestry.sampleDataset.Rd @@ -4,18 +4,30 @@ \alias{inferAncestry.sampleDataset} \title{Infer sample ancestry} \usage{ -\method{inferAncestry}{sampleDataset}(object, trainSet, knownAncestry, - nPC = 3, k = 5) +\method{inferAncestry}{sampleDataset}(sds, trainSet, knownAncestry, nPC = 3, k = 5) } \arguments{ -\item{object}{Sample Dataset object for Ancestry predition} +\item{sds}{Sample Dataset sds for ancestry prediction.} -\item{trainSet}{data frame with genotype PCs for each sample with known ancestry} +\item{trainSet}{Data frame with genotype PCs for each sample with known ancestry.} -\item{knownAncestry}{a vector with known ancestry for each sample in same order of trainSet} +\item{knownAncestry}{A vector with known ancestry for each sample in the same order as trainSet.} -\item{nPC}{Use first n PCs to predict ancestry} +\item{nPC}{Use the first n PCs to predict ancestry.} +} +\value{ +Updated sample Dataset sds with inferredAncestry tag. } \description{ Infer sample ancestry } +\examples{ +# Usage of inferAncestry.sampleDataset +sds <- inferAncestry.sampleDataset(sds, trainSet, knownAncestry, nPC = 3, k = 5) + +} +\seealso{ +{\link{inferAncestry}} + +{\link{inferAncestry.default}} +} diff --git a/man/load_examples.Rd b/man/load_examples.Rd new file mode 100644 index 0000000..942401b --- /dev/null +++ b/man/load_examples.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/examples.R +\name{load_examples} +\alias{load_examples} +\title{Load example data} +\usage{ +load_examples() +} +\description{ +Load example data +} diff --git a/man/multiplot.Rd b/man/multiplot.Rd new file mode 100644 index 0000000..fa6fd8e --- /dev/null +++ b/man/multiplot.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{multiplot} +\alias{multiplot} +\title{Generate multi-panel plots} +\usage{ +multiplot(..., plotlist = NULL, file = NULL, ncols = 1, layout = NULL) +} +\arguments{ +\item{...}{ggplot2 objects} + +\item{plotlist}{a list of ggplot2 objects} + +\item{file}{output file name (optional)} + +\item{ncols}{number of columns in the plot} + +\item{layout}{matrix specifying the layout of panels} +} +\value{ +The multi-panel plot +} +\description{ +This function creates a multi-panel plot from a list of ggplot2 objects. +} +\examples{ +\dontrun{ +# Example usage: +multiplot(plot1, plot2, ncols = 2) +} + +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} +} diff --git a/man/multiplotWithSharedLegend.Rd b/man/multiplotWithSharedLegend.Rd new file mode 100644 index 0000000..1c712c3 --- /dev/null +++ b/man/multiplotWithSharedLegend.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{multiplotWithSharedLegend} +\alias{multiplotWithSharedLegend} +\title{Generate multiple plots with shared figure legend} +\usage{ +multiplotWithSharedLegend( + plots, + ncols = 5, + position = c("bottom", "right"), + show = T +) +} +\arguments{ +\item{plots}{a list of grob sdss} + +\item{ncols}{number of rows} + +\item{position}{Position of the legend, between "bottom" and "right"} + +\item{show}{whether show the plot or not} +} +\value{ +a grid graphical `sds` (grob) +} +\description{ +Generate multiple plots with shared figure legend +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{geom_split_violin}} +} diff --git a/man/outlierPlots.Rd b/man/outlierPlots.Rd new file mode 100644 index 0000000..6ec83d1 --- /dev/null +++ b/man/outlierPlots.Rd @@ -0,0 +1,41 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{outlierPlots} +\alias{outlierPlots} +\title{Produce outlier plot} +\usage{ +outlierPlots(...) +} +\arguments{ +\item{tab}{Input table with data.} + +\item{qcMetrics}{Metrics to plot.} + +\item{strat}{Factor by which to stratify the dots.} + +\item{main}{Title of the plot.} + +\item{outliers}{List of outliers.} + +\item{primaryID}{Identifier for samples (if available).} + +\item{type}{Type of plot ('violin' or 'density').} +} +\description{ +Produce outlier plot +} +\seealso{ +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} +} diff --git a/man/outlierPlots.default.Rd b/man/outlierPlots.default.Rd new file mode 100644 index 0000000..8d19781 --- /dev/null +++ b/man/outlierPlots.default.Rd @@ -0,0 +1,59 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{outlierPlots.default} +\alias{outlierPlots.default} +\title{Generate outlier plots for a dataset} +\usage{ +\method{outlierPlots}{default}( + tab, + qcMetrics, + strat, + main, + outliers, + primaryID = NULL, + type = "violin" +) +} +\arguments{ +\item{tab}{Input table with data.} + +\item{qcMetrics}{Metrics to plot.} + +\item{strat}{Factor by which to stratify the dots.} + +\item{main}{Title of the plot.} + +\item{outliers}{List of outliers.} + +\item{primaryID}{Identifier for samples (if available).} + +\item{type}{Type of plot ('violin' or 'density').} +} +\value{ +A list of outlier plots. +} +\description{ +Generate outlier plots for a dataset +} +\examples{ +\dontrun{ +# Example usage: +outlierPlots.default(tab, qcMetrics = "Metric1", strat = "Group", main = "Outlier Plot") +} + +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} +} diff --git a/man/outlierPlots.sampleDataset.Rd b/man/outlierPlots.sampleDataset.Rd new file mode 100644 index 0000000..20b4e6a --- /dev/null +++ b/man/outlierPlots.sampleDataset.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{outlierPlots.sampleDataset} +\alias{outlierPlots.sampleDataset} +\title{Produce outlier plots for a sampleDataset} +\usage{ +\method{outlierPlots}{sampleDataset}(sds, title, width = 15, height = 6) +} +\arguments{ +\item{sds}{A sample dataset object.} + +\item{title}{Title for the PDF file.} + +\item{width}{Width of the PDF.} + +\item{height}{Height of the PDF.} +} +\value{ +A PDF file containing outlier plots. +} +\description{ +Produce outlier plots for a sampleDataset +} +\examples{ +\dontrun{ +# Example usage: +outlierPlots.sampleDataset(sds, title = "Outlier_Plots", width = 15, height = 6) +} + +} +\seealso{ +{\link{outlierPlots.default}} + +{\link{outlierPlots}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{scatter}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} +} diff --git a/man/print.sampleDataset.Rd b/man/print.sampleDataset.Rd new file mode 100644 index 0000000..f2d1e53 --- /dev/null +++ b/man/print.sampleDataset.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/S3Method.R +\name{print.sampleDataset} +\alias{print.sampleDataset} +\title{Print information about the sample dataset `sds`.} +\usage{ +\method{print}{sampleDataset}(sds) +} +\arguments{ +\item{sds}{Sample dataset `sds`.} +} +\description{ +Print information about the sample dataset `sds`. +} diff --git a/man/sampleDataset.Rd b/man/sampleDataset.Rd index 9e2d63e..169acfb 100644 --- a/man/sampleDataset.Rd +++ b/man/sampleDataset.Rd @@ -4,24 +4,43 @@ \alias{sampleDataset} \title{Sample dataset object} \usage{ -sampleDataset(bamQcMetr = NULL, vcfQcMetr = NULL, annotations, - primaryID = NULL, df = NULL) +sampleDataset( + annotInput, + primaryID, + bamQcInput = NULL, + vcfQcInput = NULL, + stratify = NULL, + df = NULL +) } \arguments{ -\item{bamQcMetr}{a data frame that contains BAM level QC metrics} +\item{annotInput}{a tsv file or data.frame that contains sample annot, +when df was defined, this item could be a vector containing +names of anntations.} -\item{vcfQcMetr}{a data frame that contains VCF level QC metrics} +\item{primaryID}{ID used for each sample} -\item{annotations}{a data frame that contains annotations of the samples.} +\item{bamQcInput}{a tsv file data frame that contains BAM QC metrics.} -\item{df}{optional, an R dataframe that contains all sample level data, including QC metrics and -sample annotations. When df is provided, bamQcMetr, vcfQcMetr and annotations should -be vectors with names of corresponding fields.} +\item{vcfQcInput}{a tsv file or a data frame that contains VCF QC metrics} + +\item{stratify}{a scalar or vector containing annot to stratify against} + +\item{df}{optional, an R dataframe that contains all sample level data, +including QC metrics and sample annot. When df is provided, +bamQcMetr, vcfQcMetr and annot should be vectors with names +of corresponding fields.} } \value{ an sampleDataset object. } \description{ -Create a sample dataset object that contains all information needed to perform a sample -quality control. The Dataset object is a list with one dataframe and +Construct an Sample Dataset object +A Sample Data Set object contains several attributes, including a data frame, +which contains all the data for samples and several other attributes that +contains metadata, such as qcMetrics, bamQcMetr, vcfQcMetr and PrimaryID. +To check attributes of your current SDS +Create a sample dataset object that contains all information needed to +perform a sample quality control. The Dataset object is a list with one +dataframe. } diff --git a/man/sampleQcPlot.Rd b/man/sampleQcPlot.Rd index c677ada..230c41f 100644 --- a/man/sampleQcPlot.Rd +++ b/man/sampleQcPlot.Rd @@ -4,13 +4,18 @@ \alias{sampleQcPlot} \title{Generate scatter plot of QC metrics according to samples} \usage{ -sampleQcPlot(object, ...) +sampleQcPlot(sds, ...) } \arguments{ -\item{object}{sample dataset object} +\item{sds}{sample dataset `sds`} \item{...}{other arguments} } \description{ Generate scatter plot of QC metrics according to samples } +\seealso{ +{\link{sampleQcPlot.default}} + +{\link{sampleQcPlot.sampleDataset}} +} diff --git a/man/sampleQcPlot.default.Rd b/man/sampleQcPlot.default.Rd index 401287b..0ff900e 100644 --- a/man/sampleQcPlot.default.Rd +++ b/man/sampleQcPlot.default.Rd @@ -4,17 +4,42 @@ \alias{sampleQcPlot.default} \title{Generate scatter plot of QC metrics} \usage{ -\method{sampleQcPlot}{default}(data, primaryID, qcMetric, annotation = NULL, - geom = c("scatter", "violin", "hist"), outliers = NULL, legend = T, - main = "QC") +\method{sampleQcPlot}{default}( + data, + primaryID, + qcMetric, + annot = NULL, + outliers = NULL, + legend = T, + main = "QC", + geom = c("scatter", "violin", "hist") +) } \arguments{ -\item{annotation}{which annotation to visualize} +\item{data}{Sample dataset `data`.} -\item{object}{sample dataset object} +\item{primaryID}{Primary ID used for each sample.} -\item{pca}{whether perform pca plot} +\item{qcMetric}{QC metric to visualize.} + +\item{annot}{Annotation variable to stratify by (optional).} + +\item{outliers}{Samples to highlight as outliers (optional).} + +\item{legend}{Logical, whether to show the legend (default is TRUE).} + +\item{main}{Title of the plot (default is 'QC').} + +\item{geom}{Type of plot: 'scatter', 'violin', or 'hist' (default is 'scatter').} +} +\value{ +A scatter plot of QC metrics. } \description{ -Generate scatter plot of QC metrics +This function generates a scatter plot of QC metrics based on the specified parameters. +} +\seealso{ +{\link{sampleQcPlot}} + +{\link{sampleQcPlot.default}} } diff --git a/man/sampleQcPlot.sampleDataset.Rd b/man/sampleQcPlot.sampleDataset.Rd index 1486c86..7725a80 100644 --- a/man/sampleQcPlot.sampleDataset.Rd +++ b/man/sampleQcPlot.sampleDataset.Rd @@ -4,16 +4,31 @@ \alias{sampleQcPlot.sampleDataset} \title{Generate a panel of sample QC plots across a list of qcMetrics} \usage{ -\method{sampleQcPlot}{sampleDataset}(object, qcMetrics, annotation = NULL, - geom = c("scatter", "violin", "hist"), outliers = NULL, legend = T, - main = "QC", position = c("right", "bottom"), ncols = 5, show = TRUE) +\method{sampleQcPlot}{sampleDataset}( + sds, + annot, + qcMetrics = sds$qcMetrics, + geom = c("scatter", "violin", "hist"), + outliers = NULL, + legend = T, + main = "QC", + position = c("right", "bottom"), + ncols = 5, + show = FALSE, + sort = TRUE +) } \arguments{ -\item{object}{SampleDataset object} +\item{sds}{SampleDataset `sds`} -\item{qcMetrics}{a character string or a vector includes QC metrics to explore; if unspecified, all QC metrics in the SDS will be used.} +\item{annot}{optional, a character string of sample annot to stratify by} -\item{geom}{a character string indicating which visualization pattern to be used. One of strings 'scatter', 'violin' or 'hist' can be used.} +\item{qcMetrics}{a character string or a vector includes QC metrics to +explore; if unspecified, all QC metrics in the SDS will +be used.} + +\item{geom}{a character string indicating which visualization pattern to be +used. One of strings 'scatter', 'violin' or 'hist' can be used.} \item{outliers}{a vector of IDs of outliers to show on the figure} @@ -21,11 +36,16 @@ \item{position}{position of the legend} -\item{annotations}{a character string of sample annotation to stratify by} +\item{sort}{whether to sort by annot when ploting} } \value{ -a list of grob objects +a list of grob sds } \description{ Generate a panel of sample QC plots across a list of qcMetrics } +\seealso{ +{\link{sampleQcPlot}} + +{\link{sampleQcPlot.sampleDataset}} +} diff --git a/man/save.Rd b/man/save.Rd index ba6ca71..a97d8d7 100644 --- a/man/save.Rd +++ b/man/save.Rd @@ -2,13 +2,24 @@ % Please edit documentation in R/S3Method.R \name{save} \alias{save} -\title{Save an object to a specific format} +\title{Save an sds to a specific format} \usage{ -save(object, ...) +save(sds, ...) } \arguments{ -\item{object}{} +\item{sds}{sample dataset} + +\item{...}{Additional arguments to be passed.} } \description{ -Save an object to tsv, RDS or excel format +Save an sds to tsv, RDS or excel format +} +\seealso{ +{\link{sort.sampleDataset}} + +{\link{save.sampleDataset}} + +{\link{dim.sampleDataset}} + +{\link{print.sampleDataset}} } diff --git a/man/save.sampleDataset.Rd b/man/save.sampleDataset.Rd index 66c8499..1704269 100644 --- a/man/save.sampleDataset.Rd +++ b/man/save.sampleDataset.Rd @@ -4,10 +4,10 @@ \alias{save.sampleDataset} \title{Write sample dataset to tsv, RDS or excel files with S3 method save.} \usage{ -\method{save}{sampleDataset}(object, RDS = NULL, tsv = NULL, xls = NULL) +\method{save}{sampleDataset}(sds, RDS = NULL, tsv = NULL, xls = NULL) } \arguments{ -\item{object}{sample dataset} +\item{sds}{sample dataset} \item{RDS}{path and output name of RDS file} diff --git a/man/scatter.Rd b/man/scatter.Rd new file mode 100644 index 0000000..5bd4795 --- /dev/null +++ b/man/scatter.Rd @@ -0,0 +1,54 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{scatter} +\alias{scatter} +\title{Produce a scatter plot from a data frame} +\usage{ +scatter( + data, + x, + y, + strat, + xlab = NULL, + ylab = NULL, + outliers = NULL, + main = NULL, + legend = T, + primaryID = NULL +) +} +\arguments{ +\item{data}{a data.frame} + +\item{strat}{by which column to stratify} + +\item{xlab}{label of x axis} + +\item{ylab}{label of y axis} + +\item{outliers}{a vector of outliers} + +\item{main}{main title of the plot} + +\item{legend}{binary, whether to plot legend or not} + +\item{primaryID}{the primary ID used to} +} +\description{ +Produce a scatter plot from a data frame +} +\seealso{ +{\link{outlierPlots}} + +{\link{outlierPlots.default}} + +{\link{outlierPlots.sampleDataset}} + +{\link{PCplots}} + +{\link{multiplot}} + +{\link{multiplotWithSharedLegend}} + +{\link{geom_split_violin}} +} diff --git a/man/setAttr.Rd b/man/setAttr.Rd index 649d3a7..be17ff9 100644 --- a/man/setAttr.Rd +++ b/man/setAttr.Rd @@ -2,18 +2,27 @@ % Please edit documentation in R/setAttr.R \name{setAttr} \alias{setAttr} -\title{Update a Sample Data Set} +\title{Update a Sample Dataset} \usage{ -setAttr(object, ...) +setAttr(sds, ...) } \arguments{ -\item{object}{sample dataset object} +\item{sds}{A sample dataset object} -\item{...}{other arguments} +\item{attributes}{character vector specifying the attributes to add or update in the sample Dataset} + +\item{data}{data.frame, content to add to the dataframe} + +\item{primaryID}{primary key of input data frame} + +\item{overwrite}{logical, indicating whether to overwrite existing attributes if they already exist} } \value{ -object +An updated sample dataset } \description{ -Update entries of sample data set, such as the df, bamQcMetr, vcfQcMetr +Update entries of a sample dataset, such as the df, bamQcMetr, vcfQcMetr. +} +\seealso{ +{\link{setAttr.sampleDataset}} } diff --git a/man/setAttr.sampleDataset.Rd b/man/setAttr.sampleDataset.Rd index e9fe880..91678bd 100644 --- a/man/setAttr.sampleDataset.Rd +++ b/man/setAttr.sampleDataset.Rd @@ -4,20 +4,21 @@ \alias{setAttr.sampleDataset} \title{Set attributes of a sample dataset} \usage{ -\method{setAttr}{sampleDataset}(object, attributes, data, primaryID, - overwrite = F) +\method{setAttr}{sampleDataset}(sds, attributes, data, primaryID, overwrite = F) } \arguments{ -\item{object}{sampleDataset} +\item{sds}{sampleDataset} -\item{entry}{which entry to add to sample Dataset} +\item{attributes}{character vector specifying the attributes to add or update in the sample Dataset} -\item{dataframe}{content to add to the dataframe} +\item{data}{data.frame, content to add to the dataframe} -\item{by}{primary key of input data frame} +\item{primaryID}{primary key of input data frame} + +\item{overwrite}{logical, indicating whether to overwrite existing attributes if they already exist} } \value{ -updated sampleDataset object +updated sampleDataset sds } \description{ Set attributes of a sample dataset diff --git a/man/sort.sampleDataset.Rd b/man/sort.sampleDataset.Rd index 43d5cc2..6b339b8 100644 --- a/man/sort.sampleDataset.Rd +++ b/man/sort.sampleDataset.Rd @@ -4,15 +4,15 @@ \alias{sort.sampleDataset} \title{Update index of sample dataset by different annotation categories} \usage{ -\method{sort}{sampleDataset}(object, by) +\method{sort}{sampleDataset}(sds, by) } \arguments{ -\item{object}{sample dataset} +\item{sds}{sample dataset} \item{by}{sort by which category} } \value{ -an sample dataset object with updated index +A sample dataset `sds` with updated index. } \description{ Update index of sample dataset by different annotation categories