Skip to content

Commit

Permalink
v-0.99.11 (removed parallel functions by snow)
Browse files Browse the repository at this point in the history
  • Loading branch information
kokitsuyuzaki committed Nov 6, 2018
1 parent 73e671a commit e22630b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 63 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: scTensor
Type: Package
Title: Detection of cell-cell interaction within single-cell RNA-Seq data
Version: 0.99.10
Version: 0.99.11
Date: 2018-09-25
Authors@R: person("Koki", "Tsuyuzaki", role = c("aut", "cre"), email = "k.t.the-answer@hotmail.co.jp")
Depends: R (>= 3.5.0)
Imports: methods, igraph, S4Vectors, plotly, reactome.db, AnnotationDbi, SummarizedExperiment, SingleCellExperiment, nnTensor, rTensor, LRBaseDbi, abind, plotrix, heatmaply, tagcloud, rmarkdown, BiocStyle, knitr, biomaRt, MeSHDbi, grDevices, graphics, stats, utils, outliers, snow, Category
Imports: methods, igraph, S4Vectors, plotly, reactome.db, AnnotationDbi, SummarizedExperiment, SingleCellExperiment, nnTensor, rTensor, LRBaseDbi, abind, plotrix, heatmaply, tagcloud, rmarkdown, BiocStyle, knitr, biomaRt, MeSHDbi, grDevices, graphics, stats, utils, outliers, Category
Suggests: testthat, RSQLite, LRBase.Hsa.eg.db, MeSH.Hsa.eg.db, LRBase.Mmu.eg.db, MeSH.Mmu.eg.db
Description: The algorithm is based on the non-negative tucker decomposition (NTD) of nnTensor.
License: Artistic-2.0
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ importFrom(stats, cor, dist, na.omit, quantile, p.adjust, hclust, cutree)
importFrom(utils, browseURL, txtProgressBar, setTxtProgressBar)
importFrom(outliers, grubbs.test, chisq.out.test)
importFrom(nnTensor, NMF, NTD, recTensor)
importFrom(snow, clusterExport, parSapply, clusterEvalQ)
importFrom(Category, hyperGTest)

exportMethods(cellCellSetting, cellCellRanks, cellCellDecomp, cellCellReport)
81 changes: 25 additions & 56 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,17 @@ setMethod("cellCellDecomp", signature(sce="SingleCellExperiment"),
setGeneric("cellCellReport", function(sce, reducedDimNames,
out.dir=tempdir(), html.open=FALSE,
title="The result of scTensor",
author="The person who runs this script", thr=40, top="full", cl=NULL){
author="The person who runs this script", thr=40, top="full"){
standardGeneric("cellCellReport")})
setMethod("cellCellReport", signature(sce="SingleCellExperiment"),
function(sce, reducedDimNames, out.dir, html.open, title, author,
thr, top, cl){
thr, top){
.cellCellReport(reducedDimNames, out.dir,
html.open, title, author, thr, top, cl, sce)})
html.open, title, author, thr, top, sce)})
.cellCellReport <- function(reducedDimNames,
out.dir=tempdir(), html.open=FALSE,
title="The result of scTensor",
author="The person who runs this script", thr=40, top="full", cl=NULL, ...){
author="The person who runs this script", thr=40, top="full", ...){
# Import from sce object
sce <- list(...)[[1]]
# algorithm-check
Expand Down Expand Up @@ -283,32 +283,11 @@ setMethod("cellCellReport", signature(sce="SingleCellExperiment"),
e$.eachRender <- .eachRender
e$.XYZ_HEADER1 <- .XYZ_HEADER1
e$.XYZ_HEADER2 <- .XYZ_HEADER2

if (!is.null(cl)) {
############ Parallel ############
# Package Loading in each node
invisible(clusterEvalQ(cl, {
requireNamespace("outliers")
requireNamespace("S4Vectors")
requireNamespace("tagcloud")
requireNamespace("plotrix")
requireNamespace("plotly")
requireNamespace("rmarkdown")
}))
clusterExport(cl, "e")
out.vecLR <- parSapply(cl, SelectedLR,
function(x, e){.eachVecLR(x, e)}, e=e)
colnames(out.vecLR) <- paste0("pattern", SelectedLR)
e$out.vecLR <- out.vecLR
clusterExport(cl, "e")
############ Parallel ############
}else{
out.vecLR <- vapply(SelectedLR,
function(x, e){.eachVecLR(x, e)},
FUN.VALUE=rep(list(0L), 8), e=e)
colnames(out.vecLR) <- paste0("pattern", SelectedLR)
e$out.vecLR <- out.vecLR
}
out.vecLR <- vapply(SelectedLR,
function(x, e){.eachVecLR(x)},
FUN.VALUE=rep(list(0L), 8), e=e)
colnames(out.vecLR) <- paste0("pattern", SelectedLR)
e$out.vecLR <- out.vecLR

# Plot(CCI Hypergraph)
png(filename=paste0(out.dir, "/figures/CCIHypergraph.png"),
Expand Down Expand Up @@ -394,19 +373,11 @@ setMethod("cellCellReport", signature(sce="SingleCellExperiment"),
render(paste0(out.dir, "/ligand.Rmd"), quiet=TRUE)
message("receptor.Rmd is compiled to index.html...")
render(paste0(out.dir, "/receptor.Rmd"), quiet=TRUE)
if (!is.null(cl)) {
message(paste0(length(selected),
" pattern_X_Y_Z.Rmd files will be created :"))
parSapply(cl, selected,
function(x, e, SelectedLR){.eachRender(x, e, SelectedLR)},
e=e, SelectedLR=SelectedLR)
}else{
message(paste0(length(selected),
" pattern_X_Y_Z.Rmd files will be created :"))
vapply(selected,
function(x, e, SelectedLR){
.eachRender(x, e, SelectedLR)}, "", e=e, SelectedLR=SelectedLR)
}
message(paste0(length(selected),
" pattern_X_Y_Z.Rmd files will be created :"))
vapply(selected,
function(x, e, SelectedLR){
.eachRender(x, e, SelectedLR)}, "", e=e, SelectedLR=SelectedLR)

# File copy
file.copy(
Expand All @@ -415,20 +386,18 @@ setMethod("cellCellReport", signature(sce="SingleCellExperiment"),
overwrite = TRUE)

# Output index.html
if(length(selected) != 0){
if(length(selected) == 1){
RMDFILES <- apply(t(index[selected, seq_len(3)]), 1,
function(x){
paste0(c("pattern", x), collapse="_")
})
}else{
RMDFILES <- apply(index[selected, seq_len(3)], 1,
function(x){
paste0(c("pattern", x), collapse="_")
})
}
RMDFILES <- paste0(RMDFILES, ".Rmd")
if(length(selected) == 1){
RMDFILES <- apply(t(index[selected, seq_len(3)]), 1,
function(x){
paste0(c("pattern", x), collapse="_")
})
}else{
RMDFILES <- apply(index[selected, seq_len(3)], 1,
function(x){
paste0(c("pattern", x), collapse="_")
})
}
RMDFILES <- paste0(RMDFILES, ".Rmd")
message("index.Rmd is created...")
outIdx <- file(paste0(out.dir, "/index.Rmd"), "w")
writeLines(.MAINHEADER(author, title), outIdx, sep="\n")
Expand Down
4 changes: 4 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
VERSION 0.99.11
------------------------
o Revised and modified some parts

VERSION 0.99.10
------------------------
o Revised and modified some parts
Expand Down
5 changes: 1 addition & 4 deletions man/cellCellReport.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The result is saved as HTML report which contains with multiple files.
cellCellReport(sce, reducedDimNames,
out.dir=tempdir(), html.open=FALSE,
title="The result of scTensor",
author="The person who runs this script", thr=40, top="full", cl=NULL)
author="The person who runs this script", thr=40, top="full")
}

\arguments{
Expand Down Expand Up @@ -44,9 +44,6 @@ The threshold for selection of top pecentage of core tensor elements
\item{top}{
top genes in each (*,*,*)-pattern which are selected and summarized in the report (Default: "full")
}
\item{cl}{
Cluster set by snow package. If the cl is set, report is calculated in parallel (Default: NULL)
}
}

\value{
Expand Down

0 comments on commit e22630b

Please sign in to comment.