Skip to content

Commit

Permalink
Merge pull request #2 from kevinrue/master
Browse files Browse the repository at this point in the history
VioFun supports ylim argument
  • Loading branch information
lengning committed Mar 20, 2017
2 parents 8ad4538 + f44c83f commit 6474809
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 82 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
*.tar.gz
*.Rd
22 changes: 22 additions & 0 deletions SCPattern.Rproj
Original file line number Diff line number Diff line change
@@ -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
14 changes: 9 additions & 5 deletions package/SCPattern/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <lengning1@gmail.com>
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'
Expand All @@ -22,3 +25,4 @@ Collate:'BetaempH0.R'
'DirichletOptim.R'
BuildVignettes: no
biocViews: StatisticalMethod, RNASeq, Sequencing, GeneExpression
RoxygenNote: 6.0.1
42 changes: 29 additions & 13 deletions package/SCPattern/R/VioFun.R
Original file line number Diff line number Diff line change
@@ -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))
Expand All @@ -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)
}
}
}


Expand Down
6 changes: 1 addition & 5 deletions package/SCPattern/man/BetaempH0.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package/SCPattern/man/DirichletOptim.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions package/SCPattern/man/DirichletempH0.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions package/SCPattern/man/KSDir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions package/SCPattern/man/KSNoDir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions package/SCPattern/man/SCPTest.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions package/SCPattern/man/SCPairwiseDir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 2 additions & 6 deletions package/SCPattern/man/SCPairwiseNoDir.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6474809

Please sign in to comment.