Skip to content

Commit

Permalink
Merge pull request #243 from zhewa/master
Browse files Browse the repository at this point in the history
pull request #242
  • Loading branch information
zhewa committed Jan 13, 2020
2 parents bd7a4a4 + ba13c06 commit 467f809
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
27 changes: 19 additions & 8 deletions R/decon.R
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ setReplaceMethod(
verbose = verbose,
varGenes = varGenes,
dbscanEps = dbscanEps,
L = L
L = L,
seed = seed
)
} else {
withr::with_seed(
Expand All @@ -376,7 +377,8 @@ setReplaceMethod(
verbose = verbose,
varGenes = varGenes,
dbscanEps = dbscanEps,
L = L
L = L,
seed = seed
)
)
}
Expand Down Expand Up @@ -447,8 +449,7 @@ setReplaceMethod(
returnResult$decontXcounts <-
DelayedArray::DelayedArray(returnResult$decontXcounts)
} else {
try(
{
try({
if (canCoerce(returnResult$decontXcounts, class(counts))) {
returnResult$decontXcounts <-
as(returnResult$decontXcounts, class(counts))
Expand Down Expand Up @@ -481,6 +482,8 @@ setReplaceMethod(


# This function updates decontamination for one batch
# seed passed to this function is to be furhter passed to
# function .decontxInitializeZ()
.decontXoneBatch <- function(counts,
z = NULL,
batch = NULL,
Expand All @@ -492,7 +495,8 @@ setReplaceMethod(
verbose = TRUE,
varGenes = NULL,
dbscanEps = NULL,
L = NULL) {
L = NULL,
seed = 12345) {
.checkCountsDecon(counts)
.checkParametersDecon(proportionPrior = delta)

Expand Down Expand Up @@ -523,6 +527,7 @@ setReplaceMethod(
L = L,
dbscanEps = dbscanEps,
verbose = verbose,
seed = seed,
logfile = logfile
)
z <- celda.init$z
Expand Down Expand Up @@ -861,6 +866,7 @@ addLogLikelihood <- function(llA, llB) {
L = 50,
dbscanEps = 1.0,
verbose = TRUE,
seed = 12345,
logfile = NULL) {
if (!is(object, "SingleCellExperiment")) {
sce <- SingleCellExperiment::SingleCellExperiment(
Expand All @@ -870,6 +876,7 @@ addLogLikelihood <- function(llA, llB) {
}

sce <- scater::logNormCounts(sce, log = TRUE)
#sce <- scater::normalize(sce)

if (nrow(sce) <= varGenes) {
topVariableGenes <- seq_len(nrow(sce))
Expand All @@ -895,9 +902,13 @@ addLogLikelihood <- function(llA, llB) {
)
## Celda clustering using recursive module splitting
L <- min(L, nrow(countsFiltered))
if (is.null(seed)) {
initialModuleSplit <- recursiveSplitModule(countsFiltered,
initialL = L, maxL = L, perplexity = FALSE, verbose = FALSE
)
initialL = L, maxL = L, perplexity = FALSE, verbose = FALSE)
} else {
with_seed(seed, initialModuleSplit <- recursiveSplitModule(countsFiltered,
initialL = L, maxL = L, perplexity = FALSE, verbose = FALSE)
)}
initialModel <- subsetCeldaList(initialModuleSplit, list(L = L))

.logMessages(
Expand All @@ -913,7 +924,7 @@ addLogLikelihood <- function(llA, llB) {
# min_dist = 0.01, spread = 1)
# rm(fm)
resUmap <- celdaUmap(countsFiltered, initialModel,
minDist = 0.01, spread = 1, nNeighbors = nNeighbors
minDist = 0.01, spread = 1, nNeighbors = nNeighbors, seed = seed
)

.logMessages(
Expand Down
14 changes: 7 additions & 7 deletions man/decontX.Rd

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

1 comment on commit 467f809

@lintr-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R/decon.R:879:1: style: Use spaces to indent, not tabs.

#sce <- scater::normalize(sce)
^~

R/decon.R:909:1: style: Use spaces to indent, not tabs.

​			with_seed(seed, initialModuleSplit <- recursiveSplitModule(countsFiltered,
^~~

Please sign in to comment.