diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2ade79d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +*.tar.gz +*.Rd diff --git a/SCPattern.Rproj b/SCPattern.Rproj new file mode 100644 index 0000000..ca709de --- /dev/null +++ b/SCPattern.Rproj @@ -0,0 +1,22 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 4 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackagePath: package/SCPattern +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/package/SCPattern/DESCRIPTION b/package/SCPattern/DESCRIPTION index 22b5a85..f4daef4 100644 --- a/package/SCPattern/DESCRIPTION +++ b/package/SCPattern/DESCRIPTION @@ -1,16 +1,19 @@ Package: SCPattern Type: Package Title: SCPattern : single cell RNA-seq multiple condition analysis -Version: 0.0.4 -Date: 2015-12-15 -Author: Ning Leng -Maintainer: Ning Leng +Version: 0.0.5 +Date: 2017-03-19 +Authors@R: c( + person("Ning", "Leng", role = c("aut", "cre"), + email = "lengning1@gmail.com"), + person(given="Kevin", family="Rue-Albrecht", role = c("ctb")) + ) Depends: EBSeq, testthat, vioplot, gtools, DirichletReg Suggests: VGAM Description: SCPattern is a statistical method that classify genes into expression patterns in a multiple condition single cell RNA-seq experiment. License: Artistic-2.0 LazyLoad: yes -Collate:'BetaempH0.R' +Collate: 'BetaempH0.R' 'DirichletempH0.R' 'KSDir.R' 'KSNoDir.R' @@ -22,3 +25,4 @@ Collate:'BetaempH0.R' 'DirichletOptim.R' BuildVignettes: no biocViews: StatisticalMethod, RNASeq, Sequencing, GeneExpression +RoxygenNote: 6.0.1 diff --git a/package/SCPattern/R/VioFun.R b/package/SCPattern/R/VioFun.R index 863e74c..35f09e9 100644 --- a/package/SCPattern/R/VioFun.R +++ b/package/SCPattern/R/VioFun.R @@ -1,26 +1,30 @@ #' @title Plot violinplot -#' @usage VioFun(gene, Data, Conditions, Col, main_pre=NULL, Dropout.remove=FALSE, Dropout.upper=0, namecex=1, ylab="Expression", Log="") +#' @usage VioFun( +#' gene, Data, Conditions, Col, main_pre=NULL, Dropout.remove=FALSE, +#' Dropout.upper=0, namecex=1, ylab="Expression", Log="", ...) #' @param gene gene name of interest (character) #' @param Data input data, gene-by-sample matrix. Normalized expression is expected #' @param Conditions a vector of characters that indicates which condition the cells belong to #' @param Col colors #' @param main_pre prefix for main -#' @param namecex cex for x axis names +#' @param namecex cex for x axis names #' @param ylab y axis label #' @param Log whether plot in log scale -#' @param Droupout.remove,Dropout.upper For a given gene, whether cells with dropout will be +#' @param Droupout.remove,Dropout.upper For a given gene, whether cells with dropout will be #' ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to #' Dropout.upper will be ignored during the test. -#' @return violin plot +#' @param ... additional arguments passed on to methods (e.g., ylim for vioplot). +#' @return violin plot #' @examples Data<- abs(matrix(rnorm(20,100,2), nrow=2)) #' rownames(Data) <- paste0("gene",1:2) #' cond <- factor(rep(c("a","b"),each=5)) #' VioFun("gene1",Data, cond) #' @author Ning Leng -VioFun=function(gene, Data, Conditions, Col=NULL, main_pre=NULL, +VioFun=function(gene, Data, Conditions, Col=NULL, main_pre=NULL, Dropout.remove=FALSE, Dropout.upper=0, namecex=1, - ylab="Expression", Log=""){ + ylab="Expression", Log="", ...){ + dots <- list(...) SCMat <- Data SCCond <- Conditions if(!is.factor(SCCond))SCCond <- factor(SCCond, levels=unique(SCCond)) @@ -39,15 +43,27 @@ VioFun=function(gene, Data, Conditions, Col=NULL, main_pre=NULL, names(SCDataVio) <- paste0(levels(SCCond)," (",sapply(SCDataVio,length),")") tmpmin <- 0 - if(Log=="y")tmpmin <- 1 - plot(1,1,col="white",xlim=c(0,length(SCDataVio)+1), - ylim=c(tmpmin,(max(SCMat[gene,])+.1)*1.2), - xaxt="none",ylab=ylab, xlab="",main=paste(gene, mainpaste), - log=Log) + if (Log=="y"){ + tmpmin <- 1 + } + if ("ylim" %in% names(dots)){ + ylim <- dots[["ylim"]] + } else { + ylim=c(tmpmin,(max(SCMat[gene,])+.1)*1.2) + } + plot( + 1,1,col="white",xlim=c(0,length(SCDataVio)+1), + ylim = ylim, + xaxt="none",ylab=ylab, xlab="",main=paste(gene, mainpaste), + log=Log + ) mtext(side=1,at=1:length(SCDataVio),paste0(names(SCDataVio)," "), las=3,cex=namecex) - for(j in 1:length(SCDataVio)) - if(max(SCDataVio[[j]])>0)vioplot(SCDataVio[[j]],at=j, add=T,col=Col[j],colMed=NULL) + for(j in 1:length(SCDataVio)){ + if(max(SCDataVio[[j]])>0){ + vioplot(SCDataVio[[j]],at=j, add=T,col=Col[j],colMed=NULL) + } + } } diff --git a/package/SCPattern/man/BetaempH0.Rd b/package/SCPattern/man/BetaempH0.Rd index 071f97d..4f31245 100644 --- a/package/SCPattern/man/BetaempH0.Rd +++ b/package/SCPattern/man/BetaempH0.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/BetaempH0.R \name{BetaempH0} \alias{BetaempH0} @@ -24,9 +24,6 @@ BetaempH0(Data, DataShuffle,StateNames=c("EE","DE"),PiIn=NULL,Num=-100, iter=5, \value{ Output: posterior probabilities and estimated hyper-parameters } -\description{ -Compare empirical non-directional KS statistics to KS statistics of permuted data -} \examples{ tmp1 <- runif(10) mat1 <- cbind(tmp1, 1-tmp1) @@ -37,4 +34,3 @@ res <- BetaempH0(mat1, mat2) \author{ Ning Leng } - diff --git a/package/SCPattern/man/DirichletOptim.Rd b/package/SCPattern/man/DirichletOptim.Rd index 5205c2f..c832e4d 100644 --- a/package/SCPattern/man/DirichletOptim.Rd +++ b/package/SCPattern/man/DirichletOptim.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/DirichletOptim.R \name{DirichletOptim} \alias{DirichletOptim} @@ -14,10 +14,6 @@ DirichletOptim(ParamPool, InputPool) \value{ sum likelihood } -\description{ -Estimate parameters of a dirichlet distribution -} \author{ Ning Leng } - diff --git a/package/SCPattern/man/DirichletempH0.Rd b/package/SCPattern/man/DirichletempH0.Rd index 49a6416..59efe7e 100644 --- a/package/SCPattern/man/DirichletempH0.Rd +++ b/package/SCPattern/man/DirichletempH0.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/DirichletempH0.R \name{DirichletempH0} \alias{DirichletempH0} @@ -26,9 +26,6 @@ BetaempH0(Data, DataShuffle,PiIn=NULL,Num=-100, iter=5, UpdatePi=TRUE) \value{ Output: posterior probabilities and estimated hyper-parameters } -\description{ -Compare empirical non-directional KS statistics to KS statistics of permuted data -} \examples{ tmp1 <- runif(10) mat1 <- cbind(tmp1, 1-tmp1) @@ -39,4 +36,3 @@ res <- BetaempH0(mat1, mat2) \author{ Ning Leng } - diff --git a/package/SCPattern/man/KSDir.Rd b/package/SCPattern/man/KSDir.Rd index a022720..9a65391 100644 --- a/package/SCPattern/man/KSDir.Rd +++ b/package/SCPattern/man/KSDir.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/KSDir.R \name{KSDir} \alias{KSDir} @@ -16,18 +16,15 @@ prior to the analysis.} \item{pval}{whether output KS test raw p values} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ -Output contains KS statistics (up-regulate and down-regulate) -for each pairwise comparison. +Output contains KS statistics (up-regulate and down-regulate) +for each pairwise comparison. Note the order of conditions are defined by the order in the Cond factor. } -\description{ -Calculate directional KS-statistics of pair-wise comparisons -} \examples{ mat <- matrix(rnorm(40), ncol=10) tmp1 <- KSDir(mat, as.factor(rep(c("c1","c2"),each=5)) @@ -35,4 +32,3 @@ tmp1 <- KSDir(mat, as.factor(rep(c("c1","c2"),each=5)) \author{ Ning Leng } - diff --git a/package/SCPattern/man/KSNoDir.Rd b/package/SCPattern/man/KSNoDir.Rd index ab6f5bc..1a2119d 100644 --- a/package/SCPattern/man/KSNoDir.Rd +++ b/package/SCPattern/man/KSNoDir.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/KSNoDir.R \name{KSNoDir} \alias{KSNoDir} @@ -16,18 +16,15 @@ prior to the analysis.} \item{pval}{whether output KS test raw p values} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ -Output contains KS statistics (non-directional) -for each pairwise comparison. +Output contains KS statistics (non-directional) +for each pairwise comparison. Note the order of conditions are defined by the order in the Cond factor. } -\description{ -Calculate non-directional KS-statistics of pair-wise comparisons -} \examples{ mat <- matrix(rnorm(40), ncol=10) tmp1 <- KSNoDir(mat, as.factor(rep(c("c1","c2"),each=5)) @@ -35,4 +32,3 @@ tmp1 <- KSNoDir(mat, as.factor(rep(c("c1","c2"),each=5)) \author{ Ning Leng } - diff --git a/package/SCPattern/man/SCPTest.Rd b/package/SCPattern/man/SCPTest.Rd index 594b0cb..c213e4c 100644 --- a/package/SCPattern/man/SCPTest.Rd +++ b/package/SCPattern/man/SCPTest.Rd @@ -1,10 +1,10 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/SCPTest.R \name{SCPTest} \alias{SCPTest} \title{Perform directional or undirectional tests across two or more conditions} \usage{ -SCPTest <- function(Data, Conditions, sizeFactors,Directional = TRUE, +SCPTest <- function(Data, Conditions, sizeFactors,Directional = TRUE, maxround=5, NumPat=3, Circular=FALSE,Dropout.remove=FALSE, Dropout.upper=0, StateNames=c("EE","Down","Up"),UpdatePi=FALSE, Print=TRUE,SmallNum=1, Seed=10, LOD=50) } @@ -27,7 +27,7 @@ If it is false, NumPat will be ignored.} \item{maxround}{Number of iterations. The default value is 5.} \item{NumPat}{number of patterns to consider. Could be 2, 3 or 4. Default is 3. -When NumPat = 3, three states (no change (EE), down and up) are considered for each +When NumPat = 3, three states (no change (EE), down and up) are considered for each transition. When NumPat = 2, two stages (down and up) are considered. When NumPat = 4, four stages (no change, down, up and both directions) are considered. NumPat will be ignored if Directional is FALSE. In this case the possible states are @@ -46,16 +46,13 @@ the values. Default is 1.} \item{method}{one of DirReg, VGAM and optim. It defines the method to use to estimate hyper-parameters} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ Output: For each comparison, output posterior probabilities of being each state. } -\description{ -Perform directional or undirectional tests across two or more conditions -} \examples{ mat <- matrix(exp(rnorm(100,10,1)),ncol=10) Sizes <- MedianNorm(mat) @@ -64,4 +61,3 @@ tmp <- SCPTest(mat, rep(c("c1","c2"),each=5), Sizes, LOD=0) \author{ Ning Leng } - diff --git a/package/SCPattern/man/SCPairwiseDir.Rd b/package/SCPattern/man/SCPairwiseDir.Rd index 4ba5dfb..97fd879 100644 --- a/package/SCPattern/man/SCPairwiseDir.Rd +++ b/package/SCPattern/man/SCPairwiseDir.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/SCPairwiseDir.R \name{SCPairwiseDir} \alias{SCPairwiseDir} @@ -22,7 +22,7 @@ as the number of samples, with the same order as the columns of Data).} \item{maxround}{Number of iterations. The default value is 5.} \item{NumPat}{number of patterns to consider. Could be 3 or 2. Default is 3. -When NumPat = 3, three states (no change, down and up) are considered for each +When NumPat = 3, three states (no change, down and up) are considered for each transition. When NumPat = 2, two stages (down and up) are considered. When NumPat = 4, four stages (no change, down, up and both directions) are considered.} @@ -41,16 +41,13 @@ the values. Default is 1.} \item{method}{one of DirReg, VGAM and optim. It defines the method to use to estimate hyper-parameters} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ Output: For each comparison, output posterior probabilities of being each state. } -\description{ -Perform directional tests across two or more conditions -} \examples{ mat <- matrix(exp(rnorm(100,10,1)),ncol=10) Sizes <- MedianNorm(mat) @@ -59,4 +56,3 @@ tmp <- SCPairwiseDir(mat, rep(c("c1","c2"),each=5), Sizes, LOD=0) \author{ Ning Leng } - diff --git a/package/SCPattern/man/SCPairwiseNoDir.Rd b/package/SCPattern/man/SCPairwiseNoDir.Rd index 5262d57..d590806 100644 --- a/package/SCPattern/man/SCPairwiseNoDir.Rd +++ b/package/SCPattern/man/SCPairwiseNoDir.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/SCPairwiseNoDir.R \name{SCPairwiseNoDir} \alias{SCPairwiseNoDir} @@ -34,16 +34,13 @@ the values. Default is 1.} \item{LOD}{Genes with max value < LOD will be eliminated in the analysis.} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ Output: For each comparison, output posterior probabilities of being each state. } -\description{ -Perform non-directional tests across two or more conditions -} \examples{ mat <- matrix(exp(rnorm(100,10,1)),ncol=10) Sizes <- MedianNorm(mat) @@ -52,4 +49,3 @@ tmp <- SCPairwiseNoDir(mat, rep(c("c1","c2"),each=5), Sizes, LOD=0) \author{ Ning Leng } - diff --git a/package/SCPattern/man/VioFun.Rd b/package/SCPattern/man/VioFun.Rd index ea550db..4f2a850 100644 --- a/package/SCPattern/man/VioFun.Rd +++ b/package/SCPattern/man/VioFun.Rd @@ -1,10 +1,12 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/VioFun.R \name{VioFun} \alias{VioFun} \title{Plot violinplot} \usage{ -VioFun(gene, Data, Conditions, Col, main_pre=NULL, Dropout.remove=FALSE, Dropout.upper=0, namecex=1, ylab="Expression", Log="") +VioFun( + gene, Data, Conditions, Col, main_pre=NULL, Dropout.remove=FALSE, + Dropout.upper=0, namecex=1, ylab="Expression", Log="", ...) } \arguments{ \item{gene}{gene name of interest (character)} @@ -23,16 +25,15 @@ VioFun(gene, Data, Conditions, Col, main_pre=NULL, Dropout.remove=FALSE, Dropout \item{Log}{whether plot in log scale} -\item{Droupout.remove,Dropout.upper}{For a given gene, whether cells with dropout will be +\item{...}{additional arguments passed on to methods (e.g., ylim for vioplot).} + +\item{Droupout.remove, Dropout.upper}{For a given gene, whether cells with dropout will be ignored in the test. Defaulte is FALSE. If it is set to TRUE, values that are less or equal to Dropout.upper will be ignored during the test.} } \value{ violin plot } -\description{ -Plot violinplot -} \examples{ Data<- abs(matrix(rnorm(20,100,2), nrow=2)) rownames(Data) <- paste0("gene",1:2) @@ -42,4 +43,3 @@ VioFun("gene1",Data, cond) \author{ Ning Leng } - diff --git a/package/SCPattern/man/beta.mom.Rd b/package/SCPattern/man/beta.mom.Rd index f032df8..f23cfef 100644 --- a/package/SCPattern/man/beta.mom.Rd +++ b/package/SCPattern/man/beta.mom.Rd @@ -1,4 +1,4 @@ -% Generated by roxygen2 (4.1.1): do not edit by hand +% Generated by roxygen2: do not edit by hand % Please edit documentation in R/beta.mom.R \name{beta.mom} \alias{beta.mom} @@ -13,13 +13,9 @@ beta distribution.} \value{ Returns the estimation of alpha and beta. } -\description{ -Fits the beta distribution by method of moments. -} \examples{ beta.mom(rbeta(5,5,20)) } \author{ Ning Leng } - diff --git a/package/SCPattern_0.0.4.tar.gz b/package/SCPattern_0.0.4.tar.gz deleted file mode 100644 index ae99b62..0000000 Binary files a/package/SCPattern_0.0.4.tar.gz and /dev/null differ