Skip to content

Commit

Permalink
v2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iaconogi committed Nov 28, 2019
1 parent e0c4e77 commit 7071221
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
5 changes: 2 additions & 3 deletions R/Functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -4452,8 +4452,6 @@ if ('counts' %in% assayNames(sce))
{
print('Computing cell to cell distances ...')
sce=setDistances(sce,modality = modality)
print('Computing the clusters ...')
sce=setClusters(sce)
}
else
{
Expand All @@ -4462,7 +4460,8 @@ if ('counts' %in% assayNames(sce))
}
sce=storeTsne(sce)
}


sce=setClusters(sce)
print('Computing the markers (slowest part) ...')
sce=computeMarkers(sce,speed.preset=speed.preset)
print('Organizing the markers ...')
Expand Down
60 changes: 38 additions & 22 deletions R/SingleCellMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -267,29 +267,45 @@ setMethod(f="setODgenes",
return(object)
}

if ('normcounts' %in% assayNames(object))
rounds=1
if (ncol(normcounts(object))>30000)
rounds=round(ncol(normcounts(object))/15000)
if (rounds>5) rounds=5
print(sprintf('Proceeding with %g rounds of search for driving genes',rounds))


for (k in 1:rounds)
{
out=calculate.ODgenes(expr.norm = normcounts(object),min_ODscore=min_ODscore,use.exp=use.exp)
else
out=calculate.ODgenes(expr.norm = object@int_metadata$expr.norm.big,min_ODscore=min_ODscore,use.exp=use.exp)

# print('Calculating ODgenes using normalized expression counts')
# tot.cells=ncol(normcounts(object))
# if (tot.cells>10000)
# {
# ix=sample(tot.cells,10000)
# out=calculate.ODgenes(expr.norm = normcounts(object)[,ix],...)
# }
# else
# out=calculate.ODgenes(expr.norm = normcounts(object),...)


# }
# else
# {
# print('Calculating ODgenes using expression counts NOT batch corrected')
# out=calculate.ODgenes(expr.data = counts(object),...)
# }
dummy=as.matrix(out[[1]])
if (k==1)
{
ODgenes=dummy[,1]
ODscores=dummy[,2]
}
else
{
ODgenes=cbind(ODgenes,dummy[,1])
ODscores=cbind(ODscores,dummy[,2])
}
}

#ODgenes.out<<-ODgenes
#ODscores.out<<-ODscores

if(rounds>1)
{
ODgenes=Rfast::rowsums(ODgenes)
ODgenes[which(ODgenes>0)]=1
ODscores=Rfast::rowmeans(ODscores)
print(sprintf('Union results in %g driving genes',sum(ODgenes)))
object@int_elementMetadata$ODgenes=ODgenes
object@int_elementMetadata$ODscore=ODscores
return(object)
}



object@int_metadata$ODgenes.plots=out[2:5]
dummy=as.matrix(out[[1]])
object@int_elementMetadata$ODgenes=dummy[,1]
Expand Down Expand Up @@ -506,7 +522,7 @@ setMethod(f="setClusters",
print("Calculating the clusters")


if (is.null(sce@int_metadata$D))
if (is.null(object@int_metadata$D))
{
#knn.norm = FNN::get.knn(dummy$v, k = knn)
knn.norm = FNN::get.knn(reducedDim(object, 'UMAP'), k = k.num)
Expand Down

0 comments on commit 7071221

Please sign in to comment.