Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
man pages update
  • Loading branch information
RuoxinLi committed Jun 13, 2019
1 parent e9fd922 commit 068d217
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 26 deletions.
10 changes: 6 additions & 4 deletions DESCRIPTION
@@ -1,5 +1,5 @@
Package: scBFA
Version: 0.99.916
Version: 0.99.913
Date: 2019-03-09
Title: A dimensionality reduction tool using gene detection pattern to mitigate noisy expression profile of scRNA-seq
Description: This package is designed to model gene detection pattern of scRNA-seq through a binary factor analysis model. This model allows user to pass into a cell level covariate matrix X and gene level covariate matrix Q to account for nuisance variance(e.g batch effect), and it will output a low dimensional embedding matrix for downstream analysis.
Expand All @@ -21,13 +21,15 @@ Imports: SingleCellExperiment,
Seurat,
MASS,
zinbwave,
stats
stats,
copula,
ggplot2,
DESeq2
Suggests:
knitr,
rmarkdown,
testthat,
Rtsne,
ggplot2
Rtsne
VignetteBuilder: knitr
SystemRequirements: R(>=3.6)
RoxygenNote: 6.1.1
Expand Down
9 changes: 9 additions & 0 deletions NAMESPACE
@@ -1,21 +1,30 @@
# Generated by roxygen2: do not edit by hand

export(BinaryPCA)
export(diagnose)
export(getLoading)
export(getScore)
export(scNoiseSim)
export(scbfa)
import(DESeq2)
import(MASS)
import(Seurat)
import(SingleCellExperiment)
import(ggplot2)
import(zinbwave)
importFrom(SummarizedExperiment,assay)
importFrom(SummarizedExperiment,mcols)
importFrom(copula,log1pexp)
importFrom(stats,lm)
importFrom(stats,loess)
importFrom(stats,optim)
importFrom(stats,prcomp)
importFrom(stats,predict)
importFrom(stats,quantile)
importFrom(stats,rbinom)
importFrom(stats,residuals)
importFrom(stats,rnbinom)
importFrom(stats,rnorm)
importFrom(stats,var)
importFrom(utils,data)
importFrom(zinbwave,orthogonalizeTraceNorm)
Binary file modified data/exprdata.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/BinaryPCA.Rd

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

39 changes: 39 additions & 0 deletions man/diagnose.Rd

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

22 changes: 22 additions & 0 deletions man/disperPlot.Rd

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

4 changes: 2 additions & 2 deletions man/exprdata.Rd

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

2 changes: 1 addition & 1 deletion man/scbfa.Rd

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

15 changes: 8 additions & 7 deletions tests/testthat/test-bfa.R
Expand Up @@ -2,19 +2,20 @@ context("scBFA")

test_that("bfa halts on numeric matrix input", {

library(Seurat)
library(SingleCellExperiment)
## Input expression profile, 5 genes x 3 cells

## Input expression profile, 100 genes x 30 cells

GeneExpr = matrix(rpois(3000,1),nrow = 100,ncol = 30)
GeneExpr = matrix(rpois(15,1),nrow = 5,ncol = 3)
rownames(GeneExpr) = paste0("gene",seq_len(nrow(GeneExpr)))
colnames(GeneExpr) = paste0("cell",seq_len(ncol(GeneExpr)))
celltype = as.factor(sample(c(1,2,3),30,replace = TRUE))
celltype = as.factor(sample(c(1,2,3),3,replace = TRUE))
#'
#'## Create cell level technical batches
#'
#'batch = sample(c("replicate 1","replicate 2","replicate 2"))

## Create cell level technical batches

batch = sample(rep(c("replicate 1","replicate 2"),each = 15))
batch = sample(c("replicate 1","replicate 2","replicate 2"))
X = matrix(NA,nrow = length(batch),ncol = 1)
X[which(batch =="replicate 1"), ] = 0
X[which(batch =="replicate 2"), ] = 1
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-scBFA.R
@@ -0,0 +1,3 @@
test_that("multiplication works", {
expect_equal(2 * 2, 4)
})
15 changes: 4 additions & 11 deletions vignettes/vignette.Rmd
Expand Up @@ -47,11 +47,8 @@ next we can load dependent packages

```{r,include=TRUE,results="hide",message=FALSE,warning=FALSE}
library(zinbwave)
library(MASS)
library(SingleCellExperiment)
library(Seurat)
library(ggplot2)
library(Rtsne)
library(scBFA)
```

Expand Down Expand Up @@ -110,17 +107,15 @@ the model object
We choose 3 as number of latent dimensions and project the gene detection
matrix on the embedding space.
```{r,include=TRUE,results="hide",message=FALSE}
bfa_model = scbfa(scData = sce, numFactors = 3)
bfa_model = scbfa(scData = sce, numFactors = 2)
```

We then visualize the low dimensional embedding of BFA in tSNE space.
Points are colored by their corresponding cell types.

```{r,fig.width=8, fig.height=6}
set.seed(5)
tsne_bfa = Rtsne(scale(bfa_model$ZZ),
initial_dims =3,perplexity =30,Steps = 5000)
df = as.data.frame(tsne_bfa$Y)
df = as.data.frame(bfa_model$ZZ)
df$celltype = celltype
p1 <- ggplot(df,aes(x = V1,y = V2,colour = celltype))
Expand Down Expand Up @@ -148,11 +143,9 @@ bpca = BinaryPCA(scData = sce)
We then visualize the low dimensional embedding of Binary PCA in tSNE space.
Points are colored by their corresponding cell types.
```{r,fig.width=8, fig.height=6}
set.seed(5)
tsne_bpca = Rtsne(scale(bpca$x[,c(1:3)]),
initial_dims =3, perplexity = 30,Steps = 5000)
df = as.data.frame(tsne_bpca$Y)
df = as.data.frame(bpca$x[,c(1:2)])
colnames(df) = c("V1","V2")
df$celltype = celltype
p1 <- ggplot(df,aes(x = V1,y = V2,colour = celltype))
Expand Down

0 comments on commit 068d217

Please sign in to comment.