R/plot.mtDNAaaf.R

Defines functions plot.mtDNAaaf

Documented in plot.mtDNAaaf

#' plot.mtDNAaaf function
#'
#' @description Produce a Diagnostic Scatter Plot to Visualize AAFs Generated by
#' mtAAF Function
#'
#' @param x a numeric matrix (16569 x N).
#' Rows correspond to loci and columns correspond to subjects.
#' It contains subject ID as the column names,
#' and the AAFs of all 16569 mtDNA loci for each subject.
#' It is generated from mtAAF function.
#' @param col color to be used in the plot.
#' @param pch plotting "character", i.e., symbol to use.
#' @param cex expansion factor for symbols used in the plot.
#' @param xlab a label for the x axis.
#' @param ylab a label for the y axis.
#' @param ... arguments to be passed to plot function.
#' @import graphics
#' @export
#' @examples
#'
#'\dontrun{
#' ## Read input data
#' allele_file <- "allele.csv"
#' freq_file   <- "freq.csv"
#'
#' allele <- as.matrix( read.csv(file=allele_file, sep=",", header=FALSE))
#' freq   <- as.matrix( read.csv(file=freq_file, sep=",", header=FALSE))
#'
#' aaf=mtAAF(allele, freq)
#' plot(aaf)
#'}
#'
plot.mtDNAaaf <- function(x, col="blue", pch='.', cex=0.2, xlab="", ylab="",
                          ...) {

    if(dim(x)[1] != .mtLength)
        stop("the AAF should have 16569 loci (rows)")

    non.zeros <- which(x != 0)
    plot(x=rep(seq_len(.mtLength), dim(x)[2])[non.zeros],
         y=as.vector(x[non.zeros]),
         col=col,
         pch=pch, cex=cex,
         xlab=xlab, ylab=ylab, ...)

    points(x=seq_len(.mtLength),
           y=rep(0, .mtLength),
           col=col,
           pch=pch, cex=cex,
           xlab=xlab, ylab=ylab, ...)

}
mtDNA-BU/ANNOmtDNA documentation built on Aug. 11, 2022, 1:46 p.m.